@@ -270,11 +270,11 @@ end
270270 cb = ModelingToolkit. generate_continuous_callbacks (sys)
271271 cond = cb. condition
272272 out = [0.0 ]
273- cond. f_iip. contents (out, [0 ], p0, t0)
273+ cond. f_iip (out, [0 ], p0, t0)
274274 @test out[] ≈ - 1 # signature is u,p,t
275- cond. f_iip. contents (out, [1 ], p0, t0)
275+ cond. f_iip (out, [1 ], p0, t0)
276276 @test out[] ≈ 0 # signature is u,p,t
277- cond. f_iip. contents (out, [2 ], p0, t0)
277+ cond. f_iip (out, [2 ], p0, t0)
278278 @test out[] ≈ 1 # signature is u,p,t
279279
280280 prob = ODEProblem (sys, Pair[], (0.0 , 2.0 ))
@@ -302,20 +302,20 @@ end
302302 cond = cb. condition
303303 out = [0.0 , 0.0 ]
304304 # the root to find is 2
305- cond. f_iip. contents (out, [0 , 0 ], p0, t0)
305+ cond. f_iip (out, [0 , 0 ], p0, t0)
306306 @test out[1 ] ≈ - 2 # signature is u,p,t
307- cond. f_iip. contents (out, [1 , 0 ], p0, t0)
307+ cond. f_iip (out, [1 , 0 ], p0, t0)
308308 @test out[1 ] ≈ - 1 # signature is u,p,t
309- cond. f_iip. contents (out, [2 , 0 ], p0, t0) # this should return 0
309+ cond. f_iip (out, [2 , 0 ], p0, t0) # this should return 0
310310 @test out[1 ] ≈ 0 # signature is u,p,t
311311
312312 # the root to find is 1
313313 out = [0.0 , 0.0 ]
314- cond. f_iip. contents (out, [0 , 0 ], p0, t0)
314+ cond. f_iip (out, [0 , 0 ], p0, t0)
315315 @test out[2 ] ≈ - 1 # signature is u,p,t
316- cond. f_iip. contents (out, [0 , 1 ], p0, t0) # this should return 0
316+ cond. f_iip (out, [0 , 1 ], p0, t0) # this should return 0
317317 @test out[2 ] ≈ 0 # signature is u,p,t
318- cond. f_iip. contents (out, [0 , 2 ], p0, t0)
318+ cond. f_iip (out, [0 , 2 ], p0, t0)
319319 @test out[2 ] ≈ 1 # signature is u,p,t
320320
321321 sol = solve (prob, Tsit5 ())
@@ -376,14 +376,14 @@ end
376376 cb = get_callback (prob)
377377 @test cb isa ModelingToolkit. DiffEqCallbacks. VectorContinuousCallback
378378 @test getfield (ball, :continuous_events )[1 ] ==
379- SymbolicContinuousCallback (Equation[x ~ 0 ], Equation[vx ~ - vx ])
379+ SymbolicContinuousCallback (Equation[x ~ 0 ], Equation[vx ~ - Pre (vx) ])
380380 @test getfield (ball, :continuous_events )[2 ] ==
381- SymbolicContinuousCallback (Equation[y ~ - 1.5 , y ~ 1.5 ], Equation[vy ~ - vy ])
381+ SymbolicContinuousCallback (Equation[y ~ - 1.5 , y ~ 1.5 ], Equation[vy ~ - Pre (vy) ])
382382 cond = cb. condition
383383 out = [0.0 , 0.0 , 0.0 ]
384384 p0 = 0.
385385 t0 = 0.
386- cond. f_iip. contents (out, [0 , 0 , 0 , 0 ], p0, t0)
386+ cond. f_iip (out, [0 , 0 , 0 , 0 ], p0, t0)
387387 @test out ≈ [0 , 1.5 , - 1.5 ]
388388
389389 sol = solve (prob, Tsit5 ())
394394 @test 0 <= minimum (sol_nosplit[x]) <= 1e-10 # the ball never went through the floor but got very close
395395 @test minimum (sol_nosplit[y]) ≈ - 1.5 # check wall conditions
396396 @test maximum (sol_nosplit[y]) ≈ 1.5 # check wall conditions
397- end
398397
399- # # Test multi-variable affect
400- # in this test, there are two variables affected by a single event.
401- @testset " Multi-variable affect" begin
398+ # # Test multi-variable affect
399+ # in this test, there are two variables affected by a single event.
402400 events = [[x ~ 0 ] => [vx ~ - Pre (vx), vy ~ - Pre (vy)]]
403401
404402 @named ball = ODESystem ([D (x) ~ vx
@@ -422,19 +420,19 @@ end
422420
423421# issue https://github.com/SciML/ModelingToolkit.jl/issues/1386
424422# tests that it works for ODAESystem
425- @testset " ODAESystem" begin
426- @variables vs (t) v (t) vmeasured (t)
427- eq = [vs ~ sin (2pi * t)
428- D (v) ~ vs - v
429- D (vmeasured) ~ 0.0 ]
430- ev = [sin (20pi * t) ~ 0.0 ] => [vmeasured ~ Pre (v)]
431- @named sys = ODESystem (eq, t, continuous_events = ev)
432- sys = structural_simplify (sys)
433- prob = ODEProblem (sys, zeros (2 ), (0.0 , 5.1 ))
434- sol = solve (prob, Tsit5 ())
435- @test all (minimum ((0 : 0.1 : 5 ) .- sol. t' , dims = 2 ) .< 0.0001 ) # test that the solver stepped every 0.1s as dictated by event
436- @test sol ([0.25 ])[vmeasured][] == sol ([0.23 ])[vmeasured][] # test the hold property
437- end
423+ # @testset "ODAESystem" begin
424+ # @variables vs(t) v(t) vmeasured(t)
425+ # eq = [vs ~ sin(2pi * t)
426+ # D(v) ~ vs - v
427+ # D(vmeasured) ~ 0.0]
428+ # ev = [sin(20pi * t) ~ 0.0] => [vmeasured ~ Pre(v)]
429+ # @named sys = ODESystem(eq, t, continuous_events = ev)
430+ # sys = structural_simplify(sys)
431+ # prob = ODEProblem(sys, zeros(2), (0.0, 5.1))
432+ # sol = solve(prob, Tsit5())
433+ # @test all(minimum((0:0.1:5) .- sol.t', dims = 2) .< 0.0001) # test that the solver stepped every 0.1s as dictated by event
434+ # @test sol([0.25])[vmeasured][] == sol([0.23])[vmeasured][] # test the hold property
435+ # end
438436
439437# # https://github.com/SciML/ModelingToolkit.jl/issues/1528
440438@testset " Handle Empty Events" begin
513511 testsol (osys, u0, p, tspan; tstops = [1.0 , 2.0 ], paramtotest = k)
514512
515513 cond1a = (t == t1)
516- affect1a = [A ~ A + 1 , B ~ A]
514+ affect1a = [A ~ Pre (A) + 1 , B ~ A]
517515 cb1a = cond1a => affect1a
518516 @named osys1 = ODESystem (eqs, t, [A, B], [k, t1, t2], discrete_events = [cb1a, cb2])
519517 u0′ = [A => 1.0 , B => 0.0 ]
589587 testsol (ssys, u0, p, tspan; tstops = [1.0 , 2.0 ], paramtotest = k)
590588
591589 cond1a = (t == t1)
592- affect1a = [A ~ Pre (A) + 1 , B ~ Pre (A) ]
590+ affect1a = [A ~ Pre (A) + 1 , B ~ A ]
593591 cb1a = cond1a => affect1a
594592 @named ssys1 = SDESystem (eqs, [0.0 ], t, [A, B], [k, t1, t2],
595593 discrete_events = [cb1a, cb2])
640638end
641639
642640@testset " JumpSystem Discrete Callbacks" begin
643- rng = rng
644641 function testsol (jsys, u0, p, tspan; tstops = Float64[], paramtotest = nothing ,
645642 N = 40000 , kwargs... )
646643 jsys = complete (jsys)
671668 testsol (jsys, u0, p, tspan; tstops = [1.0 , 2.0 ], rng, paramtotest = k)
672669
673670 cond1a = (t == t1)
674- affect1a = [A ~ Pre (A) + 1 , B ~ Pre (A) ]
671+ affect1a = [A ~ Pre (A) + 1 , B ~ A ]
675672 cb1a = cond1a => affect1a
676673 @named jsys1 = JumpSystem (eqs, t, [A, B], [k, t1, t2], discrete_events = [cb1a, cb2])
677674 u0′ = [A => 1 , B => 0 ]
0 commit comments