-
-
Notifications
You must be signed in to change notification settings - Fork 221
Unexpected behavior when dtchangeable=false #2668
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
@ChrisRackauckas do you have thoughts on the intended behavior here? |
The issue here is actually that Euler should be dtchangable 😅. If not dtchangable, definitely makes sense to error in most of these situations. We could allow for fudging dt close to So, the issue is... why did Euler become !dtchangable? That might be a bug from the package split. I'll probably fix this in a second. |
In that case, this is a bad reduction. This was originally found from a SplitIntegrator that truly isn't dtchangable. The other place this becomes tricky is that if you shrink dt (e.g. with a callbacack) in a non-adaptive, but dtchangable, method there is no mechanism for dt to go back to the previous value which can lead to dt getting ridiculously small. |
It is. Please note that I just forced dtchangeable=false here in an attempt to have a minimal example. The error should also be reproducible with algorithms who have dtchangeable=false by default. |
I see. Yeah we should allow for the epsilon changes with non-dtchangable methods.
We need to mark those as not dtchangable. 😅 Just noticed that. But okay how to do this. There is a routine for fixing small nudges around tstops: OrdinaryDiffEq.jl/lib/OrdinaryDiffEqCore/src/integrators/integrator_utils.jl Lines 289 to 302 in 5509482
What we need to do is allow it to stop to the tstop if the condition is met OrdinaryDiffEq.jl/lib/OrdinaryDiffEqCore/src/integrators/integrator_utils.jl Lines 47 to 51 in 5509482
and also not error here if the condition is met OrdinaryDiffEq.jl/lib/OrdinaryDiffEqCore/src/integrators/integrator_utils.jl Lines 395 to 396 in 5509482
So not difficult to fix. |
what do we want to do in the case where we have something like |
Not sure if that is the full story. There are two more things to consider here IIUC. First, there is a potential dtmin, which needs to be taken into account here. Second, we need to recover the old dt after doing the eps step. |
dtmin mostly doesn't exist anymore (unless you specifically ask for it). Also, IIUC Chris's suggestion was to take a slightly bigger step the step before (which we already do for adaptive integrators). Currently for adaptive integrators, we will take a step that is within a tolerance of the requested dt if it lets us hit a tstop exactly, and the argument is that we possibly should do that for non-adaptive ones as well. |
So we do not actually touch dt, but only adjust the new t?
I also thought that "overstepping", interpolating back and potentially resetting parts of the cache (e.g. for multipstep methods) should be the actual thing that happens. But that is definitely overkill for the scenario that we miss the tstop due to float point error accumulation. |
We do this: OrdinaryDiffEq.jl/lib/OrdinaryDiffEqCore/src/integrators/integrator_utils.jl Lines 464 to 466 in 5509482
Though we should probably automate the reinit like: OrdinaryDiffEq.jl/lib/OrdinaryDiffEqCore/src/integrators/integrator_interface.jl Lines 468 to 473 in 5509482
non-dtchangable methods are probably the least used and tested so we might want to do a few things here.
The system is already setup to do those checks and tweaks.
Yes exactly. The system already has a thing where if a tstop is nearby, it can just tweak to step to that. |
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
with
While this code here ignores that
dtchangeable=false
without error(set in this line
OrdinaryDiffEq.jl/lib/OrdinaryDiffEqCore/src/integrators/integrator_interface.jl
Line 19 in 125184e
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.
The text was updated successfully, but these errors were encountered: