@@ -490,19 +490,21 @@ end
490
490
@testset " Initialization of parameters" begin
491
491
function test_parameter (prob, sym, val, initialval = zero (val))
492
492
@test prob. ps[sym] ≈ initialval
493
- @test init (prob). ps[sym] ≈ val
494
- @test solve (prob). ps[sym] ≈ val
493
+ @test init (prob, Tsit5 () ). ps[sym] ≈ val
494
+ @test solve (prob, Tsit5 () ). ps[sym] ≈ val
495
495
end
496
496
@variables x (t) y (t)
497
497
@parameters p
498
498
_p = ModelingToolkit. setdefault (p, missing )
499
+ _p = ModelingToolkit. setguess (_p, 0.0 )
499
500
@mtkbuild sys = ODESystem ([D (x) ~ x, _p ~ x + y], t)
500
501
prob = ODEProblem (sys, [x => 1.0 , y => 1.0 ], (0.0 , 1.0 ))
501
502
test_parameter (prob, _p, 2.0 )
502
- @mtkbuild sys = ODESystem ([D (x) ~ x, p ~ x + y], t; defaults = [p => missing ])
503
+ @mtkbuild sys = ODESystem (
504
+ [D (x) ~ x, p ~ x + y], t; defaults = [p => missing ], guesses = [p => 0.0 ])
503
505
prob = ODEProblem (sys, [x => 1.0 , y => 1.0 ], (0.0 , 1.0 ))
504
506
test_parameter (prob, p, 2.0 )
505
- @mtkbuild sys = ODESystem ([D (x) ~ x, p ~ x + y], t)
507
+ @mtkbuild sys = ODESystem ([D (x) ~ x, p ~ x + y], t; guesses = [p => 0.0 ] )
506
508
prob = ODEProblem (sys, [x => 1.0 , y => 1.0 ], (0.0 , 1.0 ), [p => missing ])
507
509
test_parameter (prob, p, 2.0 )
508
510
516
518
@testset " Null system" begin
517
519
@variables x (t) y (t) s (t)
518
520
@parameters x0 y0
519
- @mtkbuild sys = ODESystem ([x ~ x0, y ~ y0, s ~ x + y], t)
521
+ @mtkbuild sys = ODESystem ([x ~ x0, y ~ y0, s ~ x + y], t; guesses = [y0 => 0.0 ] )
520
522
prob = ODEProblem (sys, [s => 1.0 ], (0.0 , 1.0 ), [x0 => 0.3 , y0 => missing ])
521
523
test_parameter (prob, y0, 0.7 )
522
524
end
0 commit comments