@@ -587,7 +587,7 @@ sol = solve(oprob_2nd_order_2, Rosenbrock23()) # retcode: Success
587
587
pmap = Dict ()
588
588
pmap[q] = 1.0
589
589
# `missing` default, equation from ODEProblem
590
- @mtkbuild sys = ODESystem ([D (x) ~ x * q, D (y) ~ y * p], t; defaults = [p => missing ])
590
+ @mtkbuild sys = ODESystem ([D (x) ~ x * q, D (y) ~ y * p], t; defaults = [p => missing ], guesses = [p => 1.0 ] )
591
591
pmap[p] = 2 q
592
592
prob = ODEProblem (sys, u0map, (0.0 , 1.0 ), pmap)
593
593
test_parameter (prob, p, 2.0 )
@@ -605,7 +605,7 @@ sol = solve(oprob_2nd_order_2, Rosenbrock23()) # retcode: Success
605
605
test_parameter (prob2, p, 2.0 )
606
606
607
607
# `missing` to ODEProblem, equation from default
608
- @mtkbuild sys = ODESystem ([D (x) ~ x * q, D (y) ~ y * p], t; defaults = [p => 2 q])
608
+ @mtkbuild sys = ODESystem ([D (x) ~ x * q, D (y) ~ y * p], t; defaults = [p => 2 q], guesses = [p => 1.0 ] )
609
609
pmap[p] = missing
610
610
prob = ODEProblem (sys, u0map, (0.0 , 1.0 ), pmap)
611
611
test_parameter (prob, p, 2.0 )
@@ -652,9 +652,6 @@ sol = solve(oprob_2nd_order_2, Rosenbrock23()) # retcode: Success
652
652
@mtkbuild sys = ODESystem ([D (x) ~ x, p ~ x + y], t; guesses = [p => 0.0 ])
653
653
@test_throws ModelingToolkit. MissingParametersError ODEProblem (
654
654
sys, [x => 1.0 , y => 1.0 ], (0.0 , 1.0 ))
655
- @mtkbuild sys = ODESystem ([D (x) ~ x, p ~ x + y], t)
656
- @test_throws [" Invalid setup" , " parameter p" , " guess" ] ModelingToolkit. generate_initializesystem (
657
- sys; u0map = Dict (x => 1.0 , y => 1.0 ), pmap = Dict (p => missing ), check_defguess = true )
658
655
659
656
@testset " Null system" begin
660
657
@variables x (t) y (t) s (t)
726
723
@test init (prob2, Tsit5 ())[x] ≈ 0.5
727
724
@test_nowarn solve (prob2, Tsit5 ())
728
725
end
726
+
727
+ @testset " Equations for dependent parameters" begin
728
+ @variables x (t)
729
+ @parameters p q = 5 r
730
+ @mtkbuild sys = ODESystem (D (x) ~ 2 x + r, t; parameter_dependencies = [r ~ p + 2 q, q ~ p + 3 ], guesses = [p => 1.0 ])
731
+ prob = ODEProblem (sys, [x => 1.0 ], (0.0 , 1.0 ), [p => missing ])
732
+ @test length (equations (ModelingToolkit. get_parent (prob. f. initializeprob. f. sys))) == 4
733
+ integ = init (prob, Tsit5 ())
734
+ @test integ. ps[p] ≈ 2
735
+ end
0 commit comments