Description
Describe the bug 🐞
Long-running ODE solves can accumulate round-off errors in the current time (i.e. integrator.t
). Having dtchangeable=false behaves in an unexpected ways when hitting tstops which are very slighly off.
This code here errors
using OrdinaryDiffEqCore, OrdinaryDiffEqLowOrderRK
f(x,p,t) = -x
dt = 0.01
tspan = (0.0,1005.0)
prob = ODEProblem(f,[0.0],tspan)
integrator = init(prob, Euler(), dt=dt)
integrator.dtchangeable = false
add_tstop!(integrator, 1000.0)
solve!(integrator)
with
ERROR: The current setup does not allow for changing dt.
While this code here ignores that dtchangeable=false
without error
using OrdinaryDiffEqCore, OrdinaryDiffEqLowOrderRK
f(x,p,t) = -x
dt = 0.01
tspan = (0.0,1000.0)
prob = ODEProblem(f,[0.0],tspan)
integrator = init(prob, Euler(), dt=dt)
integrator.dtchangeable = false
solve!(integrator)
(set in this line
)Expected behavior
I would expect that either both error, or that dt is not touched. Changing dt here looks like a dangerous endavour, as some time integration algorithms rely on the fact that dt will not change.
Minimal Reproducible Example 👇
See above. Can reproduce this in master (and older versions).
Additional context
Not sure if this is a bug or if this is just undocumented behavior. I understand why it happens and why the current logic is designed the way it is, but I think we should settle on a consistent behavior here.