Skip to content

Commit 8806b4f

Browse files
fix: fix initialization of DAEProblem test
1 parent 138146b commit 8806b4f

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

test/odesystem.jl

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -565,33 +565,32 @@ let
565565
eqs = [D(x[1]) ~ x[2]
566566
D(x[2]) ~ -x[1] - 0.5 * x[2] + k
567567
y ~ 0.9 * x[1] + x[2]]
568-
@named sys = System(eqs, t, vcat(x, [y]), [k], defaults = Dict(x .=> 0))
568+
@named sys = System(eqs, t, vcat(x, [y]), [k])
569569
sys = mtkcompile(sys)
570570

571571
u0 = x .=> [0.5, 0]
572572
du0 = D.(x) .=> 0.0
573-
prob = DAEProblem(sys, [du0; u0], (0, 50))
574-
@test prob[x] [0.5, 0.0]
573+
prob = DAEProblem(sys, du0, (0, 50); guesses = u0)
574+
@test prob[x] [0.5, 1.0]
575575
@test prob.du0 [0.0, 0.0]
576576
@test prob.p isa MTKParameters
577577
@test prob.ps[k] 1
578578
sol = solve(prob, IDA())
579579
@test sol[y] 0.9 * sol[x[1]] + sol[x[2]]
580580
@test isapprox(sol[x[1]][end], 1, atol = 1e-3)
581581

582-
prob = DAEProblem(sys, [D(y) => 0, D(x[1]) => 0, D(x[2]) => 0, x[1] => 0.5],
583-
(0, 50))
582+
prob = DAEProblem(sys, [D(y) => 0, D(x[1]) => 0, D(x[2]) => 0], (0, 50); guesses = u0)
584583

585-
@test prob[x] [0.5, 0]
584+
@test prob[x] [0.5, 1]
586585
@test prob.du0 [0, 0]
587586
@test prob.p isa MTKParameters
588587
@test prob.ps[k] 1
589588
sol = solve(prob, IDA())
590589
@test isapprox(sol[x[1]][end], 1, atol = 1e-3)
591590

592-
prob = DAEProblem(sys, [D(y) => 0, D(x[1]) => 0, D(x[2]) => 0, x[1] => 0.5, k => 2],
593-
(0, 50))
594-
@test prob[x] [0.5, 0]
591+
prob = DAEProblem(sys, [D(y) => 0, D(x[1]) => 0, D(x[2]) => 0, k => 2],
592+
(0, 50); guesses = u0)
593+
@test prob[x] [0.5, 3]
595594
@test prob.du0 [0, 0]
596595
@test prob.p isa MTKParameters
597596
@test prob.ps[k] 2
@@ -600,7 +599,7 @@ let
600599

601600
# no initial conditions for D(x[1]) and D(x[2]) provided
602601
@test_throws ModelingToolkit.MissingVariablesError prob=DAEProblem(
603-
sys, Pair[], (0, 50))
602+
sys, Pair[], (0, 50); guesses = u0)
604603

605604
prob = ODEProblem(sys, Pair[x[1] => 0], (0, 50))
606605
sol = solve(prob, Rosenbrock23())

0 commit comments

Comments
 (0)