Skip to content

Commit b54b56f

Browse files
test: fix rootfinding tests
1 parent be61561 commit b54b56f

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

test/symbolic_events.jl

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -422,15 +422,15 @@ cond.rf_ip(out, [0, 1], p0, t0) # this should return 0
422422
cond.rf_ip(out, [0, 2], p0, t0)
423423
@test out[2] 1 # signature is u,p,t
424424

425-
sol = solve(prob, Tsit5())
425+
sol = solve(prob, Tsit5(); abstol = 1e-14, reltol = 1e-14)
426426
@test minimum(t -> abs(t - 1), sol.t) < 1e-10 # test that the solver stepped at the first root
427427
@test minimum(t -> abs(t - 2), sol.t) < 1e-10 # test that the solver stepped at the second root
428428

429429
@named sys = ODESystem(eqs, t, continuous_events = [x ~ 1, x ~ 2]) # two root eqs using the same unknown
430430
sys = complete(sys)
431431
prob = ODEProblem(sys, Pair[], (0.0, 3.0))
432432
@test get_callback(prob) isa ModelingToolkit.DiffEqCallbacks.VectorContinuousCallback
433-
sol = solve(prob, Tsit5())
433+
sol = solve(prob, Tsit5(); abstol = 1e-14, reltol = 1e-14)
434434
@test minimum(t -> abs(t - 1), sol.t) < 1e-10 # test that the solver stepped at the first root
435435
@test minimum(t -> abs(t - 2), sol.t) < 1e-10 # test that the solver stepped at the second root
436436

@@ -540,8 +540,8 @@ ev = [sin(20pi * t) ~ 0.0] => [vmeasured ~ v]
540540
sys = structural_simplify(sys)
541541
prob = ODEProblem(sys, zeros(2), (0.0, 5.1))
542542
sol = solve(prob, Tsit5())
543-
@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
544-
@test sol([0.25])[vmeasured][] == sol([0.23])[vmeasured][] # test the hold property
543+
@test all(minimum((0:0.05:5) .- sol.t', dims = 2) .< 0.0001) # test that the solver stepped every 0.05s as dictated by event
544+
@test sol([0.25 - eps()])[vmeasured][] == sol([0.23])[vmeasured][] # test the hold property
545545

546546
## https://github.com/SciML/ModelingToolkit.jl/issues/1528
547547
Dₜ = D

0 commit comments

Comments
 (0)