Skip to content
This repository was archived by the owner on Jul 19, 2023. It is now read-only.

Commit 4d60c21

Browse files
committed
using NonlinearSolve. Removing DifferentialEquations.
1 parent ca54409 commit 4d60c21

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

Project.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ version = "4.27.0"
77
BandedMatrices = "aae01518-5342-5314-be14-df237901396f"
88
BlockBandedMatrices = "ffab5731-97b5-5995-9138-79e8c1846df0"
99
DiffEqBase = "2b5f629d-d688-5b77-993f-72d75c75574e"
10-
DifferentialEquations = "0c46a032-eb83-5123-abaf-570d42b7fbaa"
1110
DomainSets = "5b8099bc-c8ec-5219-889f-1d9e522a28bf"
1211
ForwardDiff = "f6369f11-7733-5829-9624-2563aa707210"
1312
LazyArrays = "5078a376-72f3-5289-bfd5-ec5146d43c02"
1413
LazyBandedMatrices = "d7e5e226-e90b-4449-9968-0f923699bf6f"
1514
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
1615
ModelingToolkit = "961ee093-0014-501f-94e3-6117800e7a78"
1716
NNlib = "872c559c-99b0-510c-b3b7-b6c96a88d5cd"
17+
NonlinearSolve = "8913a72c-1f9b-4ce2-8d82-65094dcecaec"
1818
RuntimeGeneratedFunctions = "7e49a35a-f44a-4d26-94aa-eba1b4ca6b47"
1919
SciMLBase = "0bca4576-84f4-4d90-8ffe-ffa030f20462"
2020
SparseArrays = "2f01184e-e22b-5df5-ae63-d93ebab69eaf"

test/MOL/MOL_NonlinearProblem.jl

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# 1D diffusion problem
22

33
# Packages and inclusions
4-
using ModelingToolkit,DiffEqOperators,LinearAlgebra,Test,OrdinaryDiffEq
4+
using ModelingToolkit,DiffEqOperators,LinearAlgebra,Test
55
using ModelingToolkit: Differential
6-
using DifferentialEquations
6+
using NonlinearSolve
77
using DomainSets
88

99

@@ -17,7 +17,7 @@ using DomainSets
1717
ns = NonlinearSystem(eqs, [a, b, c, d], [])
1818
f = eval(generate_function(ns, [a, b, c, d])[2])
1919
prob = NonlinearProblem(ns, zeros(4), [])
20-
sol = solve(prob)
20+
sol = NonlinearSolve.solve(prob, NewtonRaphson())
2121
@test sol.u ones(4)
2222
end
2323

@@ -39,7 +39,7 @@ end
3939
pdesys = PDESystem([eq],bcs,domains,[x],[u(x)])
4040
discretization = MOLFiniteDifference([x=>dx], nothing, centered_order=2)
4141
prob = discretize(pdesys,discretization)
42-
sol = solve(prob)
42+
sol = NonlinearSolve.solve(prob, NewtonRaphson())
4343

4444
@test sol.u ones(4)
4545
end
@@ -62,7 +62,7 @@ end
6262
pdesys = PDESystem([eq],bcs,domains,[x],[u(x)])
6363
discretization = MOLFiniteDifference([x=>dx], nothing, centered_order=2)
6464
prob = discretize(pdesys,discretization)
65-
sol = solve(prob)
65+
sol = NonlinearSolve.solve(prob, NewtonRaphson())
6666

6767
@test sol.u 1.0:0.1:2.0
6868
end
@@ -95,20 +95,20 @@ end
9595
discretization = MOLFiniteDifference([x=>dx,y=>dy], nothing, centered_order=2)
9696

9797
prob = discretize(pdesys,discretization)
98-
sol = solve(prob)
98+
sol = NonlinearSolve.solve(prob, NewtonRaphson())
9999
xs,ys = [infimum(d.domain):dx:supremum(d.domain) for d in domains]
100100
u_sol = reshape(sol.u, (length(xs),length(ys)))
101101

102102
# test boundary
103-
@test all(u_sol[:,1] .< eps())
104-
@test all(u_sol[1,:] .< eps())
103+
@test all(abs.(u_sol[:,1]) .< eps(Float32))
104+
@test all(abs.(u_sol[1,:]) .< eps(Float32))
105105
@test u_sol[:,end] 0:dy:1.0
106106
@test u_sol[end,:] 0:dx:1.0
107107

108108
# test interior with finite differences
109109
interior = CartesianIndices((axes(xs)[1], axes(ys)[1]))[2:end-1,2:end-1]
110110
fd = map(interior) do I
111-
u_sol[(I - CartesianIndex(1, 0))] + u_sol[(I + CartesianIndex(1,0))] - 2*u_sol[I] < eps(Float32)
111+
abs(u_sol[(I - CartesianIndex(1, 0))] + u_sol[(I + CartesianIndex(1,0))] - 2*u_sol[I]) < eps(Float32)
112112
end
113113
@test all(fd)
114114
end

0 commit comments

Comments
 (0)