@@ -587,7 +587,7 @@ sol = solve(oprob_2nd_order_2, Rosenbrock23()) # retcode: Success
587587 pmap = Dict ()
588588 pmap[q] = 1.0
589589 # `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 ] )
591591 pmap[p] = 2 q
592592 prob = ODEProblem (sys, u0map, (0.0 , 1.0 ), pmap)
593593 test_parameter (prob, p, 2.0 )
@@ -605,7 +605,7 @@ sol = solve(oprob_2nd_order_2, Rosenbrock23()) # retcode: Success
605605 test_parameter (prob2, p, 2.0 )
606606
607607 # `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 ] )
609609 pmap[p] = missing
610610 prob = ODEProblem (sys, u0map, (0.0 , 1.0 ), pmap)
611611 test_parameter (prob, p, 2.0 )
@@ -652,9 +652,6 @@ sol = solve(oprob_2nd_order_2, Rosenbrock23()) # retcode: Success
652652 @mtkbuild sys = ODESystem ([D (x) ~ x, p ~ x + y], t; guesses = [p => 0.0 ])
653653 @test_throws ModelingToolkit. MissingParametersError ODEProblem (
654654 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 )
658655
659656 @testset " Null system" begin
660657 @variables x (t) y (t) s (t)
726723 @test init (prob2, Tsit5 ())[x] ≈ 0.5
727724 @test_nowarn solve (prob2, Tsit5 ())
728725end
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