You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When defining callback events with PresetTimeCallback, I see strange behaviors that is different whether I include the 0 timepoint in the event times or define the callback event in ODEProblem or solve.
When 0 is included in the event times and the callback is defined within ODEProblem, the middle event is missed.
When 0 is included in the event times and the callback is defined within solve, all events are missed.
functionmod(du, u, p, t)
du[1] =-p[1]*u[1]
end
p = [1.0]
u0 = [10.0]
tspan = (0.0,72.0)
#dosetimes = [0.0:24.0:tspan[2];]
times1 =0.0:24.0:tspan[2]
times2 =24.0:24.0:tspan[2]
affect!(integrator) = integrator.u[1] +=10.0
cb1 =PresetTimeCallback(times1, affect!)
cb2 =PresetTimeCallback(times2, affect!)
# solve
prob1 =ODEProblem(mod, u0, tspan, p, callback=cb1)
prob2 =ODEProblem(mod, u0, tspan, p)
sol1 =solve(prob1)
sol2 =solve(prob2, callback=cb1)
plot(sol1, label="0 included in discrete times and callback defined in ODEProblem")
plot!(sol2, label="0 included in discrete times and callback defined in solve")
When 0 is removed from the event times and the callback is defined within ODEProblem, things look as expected.
When 0 is removed from the event times and the callback is defined within solve, all events are missed.
## remove 0 timepoint from callback times
prob1 =ODEProblem(mod, u0, tspan, p, callback=cb2)
prob2 =ODEProblem(mod, u0, tspan, p)
sol1 =solve(prob1)
sol2 =solve(prob2, callback=cb2)
plot(sol1, label="0 not included in discrete times and callback defined in ODEProblem")
plot!(sol2, label="0 not included in discrete times and callback defined in solve")
When defining callback events with
PresetTimeCallback
, I see strange behaviors that is different whether I include the 0 timepoint in the event times or define the callback event inODEProblem
orsolve
.When 0 is included in the event times and the callback is defined within
ODEProblem
, the middle event is missed.When 0 is included in the event times and the callback is defined within
solve
, all events are missed.When 0 is removed from the event times and the callback is defined within
ODEProblem
, things look as expected.When 0 is removed from the event times and the callback is defined within
solve
, all events are missed.The text was updated successfully, but these errors were encountered: