Skip to content

Commit 2ec0999

Browse files
committed
Add tests
1 parent 5a8fcb4 commit 2ec0999

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

test/odesystem.jl

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,3 +192,23 @@ prob = ODEProblem(lotka,[1.0,1.0],(0.0,1.0),[1.5,1.0,3.0,1.0])
192192

193193
de = modelingtoolkitize(prob)
194194
ODEFunction(de)(similar(prob.u0), prob.u0, prob.p, 0.1)
195+
196+
# automatic state detection for DAEs
197+
@parameters t k₁ k₂ k₃
198+
@variables y₁(t) y₂(t) y₃(t)
199+
@derivatives D'~t
200+
# reorder the system just to be a little spicier
201+
eqs = [D(y₁) ~ -k₁*y₁+k₃*y₂*y₃,
202+
0 ~ y₁ + y₂ + y₃ - 1,
203+
D(y₂) ~ k₁*y₁-k₂*y₂^2-k₃*y₂*y₃]
204+
sys = ODESystem(eqs)
205+
u0 = [y₁ => 1.0,
206+
y₂ => 0.0,
207+
y₃ => 0.0]
208+
p = [k₁ => 0.04,
209+
k₂ => 3e7,
210+
k₃ => 1e4]
211+
tspan = (0.0,100000.0)
212+
prob = ODEProblem(sys,u0,tspan,p)
213+
sol = solve(prob, Rodas5())
214+
@test all(x->sum(x) 1.0, sol.u)

0 commit comments

Comments
 (0)