@@ -599,23 +599,22 @@ end
599599 # the correct solver.
600600 # `rhss` allows adding terms to the end of equations (only 2 equations allowed) to influence
601601 # the system type (brownian vars to turn it into an SDE).
602- @testset " $Problem with $(SciMLBase. parameterless_type (alg)) " for (System, Problem, alg, rhss) in [
603- (ModelingToolkit . System, ODEProblem, Tsit5 (), zeros (2 )),
604- (ModelingToolkit . System, SDEProblem, ImplicitEM (), [a, b]),
605- (ModelingToolkit . System, DDEProblem, MethodOfSteps (Tsit5 ()), [_x (t - 0.1 ), 0.0 ]),
606- (ModelingToolkit . System, SDDEProblem, ImplicitEM (), [_x (t - 0.1 ) + a, b])
602+ @testset " $Problem with $(SciMLBase. parameterless_type (alg)) " for (Problem, alg, rhss) in [
603+ (ODEProblem, Tsit5 (), zeros (2 )),
604+ (SDEProblem, ImplicitEM (), [a, b]),
605+ (DDEProblem, MethodOfSteps (Tsit5 ()), [_x (t - 0.1 ), 0.0 ]),
606+ (SDDEProblem, ImplicitEM (), [_x (t - 0.1 ) + a, b])
607607 ]
608608 function test_parameter (prob, sym, val)
609609 if prob. u0 != = nothing
610610 @test init (prob, alg). ps[sym] ≈ val
611611 end
612612 @test solve (prob, alg). ps[sym] ≈ val
613613 end
614- function test_initializesystem (sys, u0map, pmap, p, equation)
615- isys = ModelingToolkit. generate_initializesystem (
616- sys; u0map, pmap, guesses = ModelingToolkit. guesses (sys))
617- @test is_variable (isys, p)
618- @test equation in equations (isys) || (0 ~ - equation. rhs) in equations (isys)
614+ function test_initializesystem (prob, p, equation)
615+ isys = prob. f. initialization_data. initializeprob. f. sys
616+ @test is_variable (isys, p) || ModelingToolkit. has_observed_with_lhs (isys, p)
617+ @test equation in [equations (isys); observed (isys)]
619618 end
620619
621620 u0map = Dict (x => 1.0 , y => 1.0 )
635634 [D (x) ~ x + rhss[1 ], p ~ x + y + rhss[2 ]], t; defaults = [p => missing ], guesses = [p => 0.0 ])
636635 prob = Problem (sys, u0map, (0.0 , 1.0 ))
637636 test_parameter (prob, p, 2.0 )
638- test_initializesystem (sys, u0map, pmap, p, 0 ~ p - x - y)
637+ test_initializesystem (prob, p, p ~ x + y)
639638 prob2 = remake (prob; u0 = u0map)
640639 prob2. ps[p] = 0.0
641640 test_parameter (prob2, p, 2.0 )
646645 pmap[p] = missing
647646 prob = Problem (sys, u0map, (0.0 , 1.0 ), pmap)
648647 test_parameter (prob, p, 2.0 )
649- test_initializesystem (sys, u0map, pmap, p, 0 ~ 2 q - p )
648+ test_initializesystem (prob, p, p ~ 2 q)
650649 prob2 = remake (prob; u0 = u0map, p = pmap)
651650 prob2. ps[p] = 0.0
652651 test_parameter (prob2, p, 2.0 )
655654 [D (x) ~ x + rhss[1 ], p ~ x + y + rhss[2 ]], t; guesses = [p => 0.0 ])
656655 prob = Problem (sys, u0map, (0.0 , 1.0 ), pmap)
657656 test_parameter (prob, p, 2.0 )
658- test_initializesystem (sys, u0map, pmap, p, 0 ~ x + y - p )
657+ test_initializesystem (prob, p, p ~ x + y)
659658 prob2 = remake (prob; u0 = u0map, p = pmap)
660659 prob2. ps[p] = 0.0
661660 test_parameter (prob2, p, 2.0 )
666665 delete! (pmap, p)
667666 prob = Problem (sys, u0map, (0.0 , 1.0 ), pmap)
668667 test_parameter (prob, p, 2.0 )
669- test_initializesystem (sys, u0map, pmap, p, 0 ~ 2 q - p )
668+ test_initializesystem (prob, p, p ~ 2 q)
670669 prob2 = remake (prob; u0 = u0map, p = pmap)
671670 prob2. ps[p] = 0.0
672671 test_parameter (prob2, p, 2.0 )
677676 _pmap = merge (pmap, Dict (p => q))
678677 prob = Problem (sys, u0map, (0.0 , 1.0 ), _pmap)
679678 test_parameter (prob, p, _pmap[q])
680- test_initializesystem (sys, u0map, _pmap, p, 0 ~ q - p )
679+ test_initializesystem (prob, p, p ~ q)
681680 # Problem dependent value with guess, no `missing`
682681 @mtkbuild sys = System (
683682 [D (x) ~ y * q + p + rhss[1 ], D (y) ~ x * p + q + rhss[2 ]], t; guesses = [p => 0.0 ])
@@ -910,11 +909,11 @@ end
910909 @brownian a b
911910 x = _x (t)
912911
913- @testset " $Problem with $(SciMLBase. parameterless_type (typeof (alg))) " for (System, Problem, alg, rhss) in [
914- (ModelingToolkit . System, ODEProblem, Tsit5 (), zeros (2 )),
915- (ModelingToolkit . System, SDEProblem, ImplicitEM (), [a, b]),
916- (ModelingToolkit . System, DDEProblem, MethodOfSteps (Tsit5 ()), [_x (t - 0.1 ), 0.0 ]),
917- (ModelingToolkit . System, SDDEProblem, ImplicitEM (), [_x (t - 0.1 ) + a, b])
912+ @testset " $Problem with $(SciMLBase. parameterless_type (typeof (alg))) " for (Problem, alg, rhss) in [
913+ (ODEProblem, Tsit5 (), zeros (2 )),
914+ (SDEProblem, ImplicitEM (), [a, b]),
915+ (DDEProblem, MethodOfSteps (Tsit5 ()), [_x (t - 0.1 ), 0.0 ]),
916+ (SDDEProblem, ImplicitEM (), [_x (t - 0.1 ) + a, b])
918917 ]
919918 @mtkbuild sys = System (
920919 [D (x) ~ x + rhss[1 ], p ~ x + y + rhss[2 ]], t; defaults = [p => missing ], guesses = [
@@ -1194,13 +1193,13 @@ end
11941193 @test integ[x] ≈ 1 / cbrt (3 )
11951194 @test integ[y] ≈ 2 / cbrt (3 )
11961195 @test integ. ps[p] == 1.0
1197- @test integ. ps[q] ≈ 3 / cbrt (3 ) atol= 1e-5
1196+ @test integ. ps[q]≈ 3 / cbrt (3 ) atol= 1e-5
11981197 prob2 = remake (prob; u0 = [y => 3 x], p = [q => 2 x])
11991198 integ2 = init (prob2)
1200- @test integ2[x] ≈ cbrt (3 / 28 ) atol= 1e-5
1201- @test integ2[y] ≈ 3 cbrt (3 / 28 ) atol= 1e-5
1199+ @test integ2[x]≈ cbrt (3 / 28 ) atol= 1e-5
1200+ @test integ2[y]≈ 3 cbrt (3 / 28 ) atol= 1e-5
12021201 @test integ2. ps[p] == 1.0
1203- @test integ2. ps[q] ≈ 2 cbrt (3 / 28 ) atol= 1e-5
1202+ @test integ2. ps[q]≈ 2 cbrt (3 / 28 ) atol= 1e-5
12041203end
12051204
12061205function test_dummy_initialization_equation (prob, var)
@@ -1300,13 +1299,8 @@ end
13001299
13011300 u0s = [I => 1 , R => 0 ]
13021301 ps = [S0 => 999 , β => 0.01 , γ => 0.001 ]
1303- dprob = DiscreteProblem (js, u0s, (0.0 , 10.0 ), ps)
1304- @test_broken dprob. f. initialization_data != = nothing
1305- sol = solve (dprob, FunctionMap ())
1306- @test sol[S, 1 ] ≈ 999
1307- @test SciMLBase. successful_retcode (sol)
13081302
1309- jprob = JumpProblem (js, dprob )
1303+ jprob = JumpProblem (js, u0s, ( 0.0 , 10.0 ), ps )
13101304 sol = solve (jprob, SSAStepper ())
13111305 @test sol[S, 1 ] ≈ 999
13121306 @test SciMLBase. successful_retcode (sol)
0 commit comments