Skip to content

Commit e608d99

Browse files
author
dd
committed
added a test for set-time discrete event
1 parent ed2bab5 commit e608d99

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

test/root_equations.jl

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -357,4 +357,17 @@ let
357357
@test isapprox(sol(1.0000000001)[1] - sol(0.999999999)[1], 1.0; rtol = 1e-6)
358358
@test oprob.p[1] == 1.0
359359
@test isapprox(sol(4.0)[1], 2 * exp(-2.0))
360+
361+
# same as above - but with set-time event syntax
362+
cb1‵ = [1.0,] => affect1 # needs to be a Vector for the event to happen only once
363+
cb2‵ = [2.0,] => affect2
364+
365+
@named osys‵ = ODESystem(eqs, t, [A], [k, t1, t2], discrete_events = [cb1‵, cb2‵])
366+
oprob‵ = ODEProblem(osys‵, u0, tspan, p)
367+
sol‵ = solve(oprob‵, Tsit5(); abstol = 1e-10, reltol = 1e-10)
368+
369+
@test isapprox(sol‵(1.0000000001)[1] - sol‵(0.999999999)[1], 1.0; rtol = 1e-6)
370+
@test oprob‵.p[1] == 1.0
371+
@test isapprox(sol‵(4.0)[1], 2 * exp(-2.0))
360372
end
373+

0 commit comments

Comments
 (0)