Skip to content

Commit 30103b4

Browse files
committed
Add tests for event detection when step is exactly on event date
1 parent 8d9ad55 commit 30103b4

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

test/integrators/ode_event_tests.jl

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ callback = ContinuousCallback(condition, affect!)
2222
sol = solve(prob, Tsit5(), callback = callback)
2323
@test length(sol) < 20
2424

25+
# Force integrator to step on event
26+
sol = solve(prob, Tsit5(), callback = callback, tstops = [-2.95])
27+
2528
condition = function (out, u, t, integrator) # Event when event_f(u,t,k) == 0
2629
out[1] = -t - 2.95
2730
end
@@ -36,6 +39,9 @@ callback = VectorContinuousCallback(condition, affect!, 1)
3639

3740
sol = solve(prob, Tsit5(), callback = callback)
3841

42+
# Force integrator to step on event
43+
sol = solve(prob, Tsit5(), callback = callback, tstops = [-2.95])
44+
3945
f = function (du, u, p, t)
4046
du[1] = -u[1] + sin(t)
4147
end
@@ -54,6 +60,9 @@ callback = ContinuousCallback(condition, affect!)
5460

5561
sol = solve(prob, Tsit5(), callback = callback, abstol = 1e-8, reltol = 1e-6)
5662

63+
# Force integrator to step on event
64+
sol = solve(prob, Tsit5(), callback = callback, abstol = 1e-8, reltol = 1e-6, tstops = [2.95])
65+
5766
condition = function (out, u, t, integrator) # Event when event_f(u,t,k) == 0
5867
out[1] = t - 2.95
5968
end
@@ -68,6 +77,9 @@ callback = VectorContinuousCallback(condition, affect!, 1)
6877

6978
sol = solve(prob, Tsit5(), callback = callback, abstol = 1e-8, reltol = 1e-6)
7079

80+
# Force integrator to step on event
81+
sol = solve(prob, Tsit5(), callback = callback, abstol = 1e-8, reltol = 1e-6, tstops = [2.95])
82+
7183
f = function (du, u, p, t)
7284
du[1] = u[2]
7385
du[2] = -9.81

0 commit comments

Comments
 (0)