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
It seems like the retcode of ODESolution does not change after reinit!, even if in the new initial condition the retcode should be :Success.
In this code I check for u if it is positive, and then terminate. But then I change the initial condition and the retcode is still :Terminated (although the solution is perfectly good).
using DifferentialEquations
f(u,p,t) = 2*u
# the solution is positive or negative depends on the initial condition
u_positive(u,t,integrator) = u > 0
terminate_if_u_pos = DiscreteCallback(u_positive, terminate!)
prob = ODEProblem(f, 1.0, (0.0, 1.0)) # positive initial condition > positive u > :Terminated
integrator = init(prob, Tsit5(), callback=terminate_if_u_pos)
sol1 = solve!(integrator)
@show sol1.retcode # should be :Terminated
# julia> sol1.retcode = :Terminated
reinit!(integrator, -1.0) # negative initial condition > negative u > :Success!
sol2 = solve!(integrator)
@show sol2.retcode
# julia> sol2.retcode = :Terminated
# but should be :Success like as to following code:
prob = ODEProblem(f, -1.0,(0.0, 1.0)) # negative initial condition > negative u > :Success!
integrator = init(prob, Tsit5(), callback=terminate_if_u_pos)
sol3 = solve!(integrator)
@show sol3.retcode
# julia> sol3.retcode = :Success
Hi all,
It seems like the
retcode
ofODESolution
does not change afterreinit!
, even if in the new initial condition theretcode
should be:Success
.In this code I check for
u
if it is positive, and then terminate. But then I change the initial condition and theretcode
is still:Terminated
(although the solution is perfectly good).Link for discourse discussion.
Thanks!
The text was updated successfully, but these errors were encountered: