Skip to content

Commit ce17627

Browse files
test: cap dt in the marginal continuous-callback crossing-time tests
The three `solve(prob, Tsit5())` calls in "Additional SymbolicContinuousCallback options" assert event times to 1.0e-4 while integrating at the default `reltol = 1.0e-3`. For `c2 = cos(3t)` that leaves no room: the numerical trajectory carries ~2e-4 of error, and since `dc2/dt = ±3` at the crossings the recorded event time inherits ~7e-5 of it -- a 1.4x margin against the assertion. The rootfind itself is exact (the condition value at the recorded time is ~1e-16), so what these tests actually measured was default-tolerance quadrature error, not event handling. OrdinaryDiffEqCore 4.12.0 (SciML/OrdinaryDiffEq.jl#3720) reinitializes the step-size controller after any continuous callback with `maybe_discontinuity = true`, which is correct -- a PI controller's history is meaningless across a discontinuity -- but it changes the step sequence, and the c2 error grew to ~8e-4, pushing the crossing times to 2.6e-4 and over the threshold. Pass `dtmax = 0.01` as the other four solves in the same testset already do. Crossing times land within ~1e-12, so the assertions now test the rootfind rather than the controller. Co-Authored-By: Chris Rackauckas <accounts@chrisrackauckas.com> Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01TNqmRywBbj51czPQgoiEC7
1 parent 3533298 commit ce17627

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

lib/ModelingToolkitBase/test/symbolic_events.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -722,7 +722,7 @@ end
722722
@named trigsys = System(eqs, t; continuous_events = [evt1, evt2])
723723
trigsys_ss = mtkcompile(trigsys)
724724
prob = ODEProblem(trigsys_ss, [], (0.0, 2π))
725-
sol = solve(prob, Tsit5())
725+
sol = solve(prob, Tsit5(); dtmax = 0.01)
726726
required_crossings_c1 =/ 2, 3 * π / 2]
727727
required_crossings_c2 =/ 6, π / 2, 5 * π / 6, 7 * π / 6, 3 * π / 2, 11 * π / 6]
728728
@test maximum(abs.(first.(cr1) .- required_crossings_c1)) < 1.0e-4
@@ -841,7 +841,7 @@ end
841841
@named trigsys = System(eqs, t; continuous_events = [evt1, evt2])
842842
trigsys_ss = mtkcompile(trigsys)
843843
prob = ODEProblem(trigsys_ss, [], (0.0, 2π))
844-
sol = solve(prob, Tsit5())
844+
sol = solve(prob, Tsit5(); dtmax = 0.01)
845845
@test maximum(abs.(first.(cr1) .- required_crossings_c1)) < 1.0e-4
846846
@test maximum(abs.(first.(cr2) .- required_crossings_c2)) < 1.0e-4
847847
@test sign.(cos.(required_crossings_c1 .- 1.0e-6)) == sign.(last.(cr1))
@@ -861,7 +861,7 @@ end
861861
@named trigsys = System(eqs, t; continuous_events = [evt2, evt1])
862862
trigsys_ss = mtkcompile(trigsys)
863863
prob = ODEProblem(trigsys_ss, [], (0.0, 2π))
864-
sol = solve(prob, Tsit5())
864+
sol = solve(prob, Tsit5(); dtmax = 0.01)
865865
@test maximum(abs.(first.(cr1) .- required_crossings_c1)) < 1.0e-4
866866
@test maximum(abs.(first.(cr2) .- required_crossings_c2)) < 1.0e-4
867867
@test sign.(cos.(required_crossings_c1 .- 1.0e-6)) == sign.(last.(cr1))

0 commit comments

Comments
 (0)