@@ -336,11 +336,11 @@ sys = structural_simplify(model)
336
336
@test isempty (ModelingToolkit. continuous_events (sys))
337
337
338
338
let
339
- function testsol (osys, u0, p, tspan; tstops = Float64[], kwargs... )
339
+ function testsol (osys, u0, p, tspan; tstops = Float64[], skipparamtest = false , kwargs... )
340
340
oprob = ODEProblem (osys, u0, tspan, p; kwargs... )
341
341
sol = solve (oprob, Tsit5 (); tstops = tstops, abstol = 1e-10 , reltol = 1e-10 )
342
342
@test isapprox (sol (1.0000000001 )[1 ] - sol (0.999999999 )[1 ], 1.0 ; rtol = 1e-6 )
343
- @test oprob. p[1 ] == 1.0
343
+ ! skipparamtest && ( @test oprob. p[1 ] == 1.0 )
344
344
@test isapprox (sol (4.0 )[1 ], 2 * exp (- 2.0 ))
345
345
sol
346
346
end
390
390
@named osys4 = ODESystem (eqs, t, [A], [k, t1], discrete_events = [cb1, cb2‵‵])
391
391
oprob4 = ODEProblem (osys4, u0, tspan, p)
392
392
testsol (osys4, u0, p, tspan; tstops = [1.0 ])
393
+
393
394
# mixing with symbolic condition in the func affect
394
395
cb2‵‵‵ = (t == t2) => (affect!, [], [k], nothing )
395
396
@named osys5 = ODESystem (eqs, t, [A], [k, t1, t2], discrete_events = [cb1, cb2‵‵‵])
396
397
testsol (osys5, u0, p, tspan; tstops = [1.0 , 2.0 ])
398
+ @named osys6 = ODESystem (eqs, t, [A], [k, t1, t2], discrete_events = [cb2‵‵‵, cb1])
399
+ testsol (osys6, u0, p, tspan; tstops = [1.0 , 2.0 ])
400
+
401
+ # mix a continuous event too
402
+ cond3 = A ~ .1
403
+ affect3 = [k ~ 0.0 ]
404
+ cb3 = cond3 => affect3
405
+ @named osys7 = ODESystem (eqs, t, [A], [k, t1, t2], discrete_events = [cb1, cb2‵‵‵],
406
+ continuous_events = [cb3])
407
+ sol = testsol (osys7, u0, p, (0.0 , 10.0 ); tstops = [1.0 , 2.0 ], skipparamtest = true )
408
+ @test isapprox (sol (10.0 )[1 ], .1 ; atol= 1e-10 , rtol= 1e-10 )
397
409
end
0 commit comments