@@ -161,7 +161,27 @@ function step_accept_controller!(integrator, cache::Union{QNDFCache, QNDFConstan
161161 h / q
162162 end
163163 end
164- return is_disco ? min ((integrator. disco_checkpoint - integrator. t) / 4 , new_dt) : new_dt
164+ if is_disco
165+ return min ((integrator. disco_checkpoint - integrator. t) / 4 , new_dt)
166+ end
167+ return new_dt
168+ end
169+
170+ """
171+ bdf_restart_estimates!(cache)
172+
173+ Restart the order and constant-step estimates for a step that straddles a derivative
174+ discontinuity, where the history behind it and the solution ahead belong to different
175+ regimes. We do this because the BDF step-size and order logic is based on the history of the solution,
176+ and we have effectively entered a new regime where old estimates no longer apply.
177+ """
178+ function bdf_restart_estimates! (cache)
179+ cache. order = 1
180+ cache. nconsteps = 0
181+ if hasfield (typeof (cache), :qwait )
182+ cache. qwait = 3
183+ end
184+ return nothing
165185end
166186
167187function bdf_step_reject_controller! (integrator, cache, EEst1)
@@ -438,7 +458,11 @@ function step_accept_controller!(
438458 cache. qwait -= 1 # countdown
439459 end
440460 new_dt = integrator. dt / q
441- return is_disco ? min ((integrator. disco_checkpoint - integrator. t) / 4 , new_dt) : new_dt
461+ if is_disco
462+ bdf_restart_estimates! (cache)
463+ return min ((integrator. disco_checkpoint - integrator. t) / 4 , new_dt)
464+ end
465+ return new_dt
442466end
443467
444468function step_reject_controller! (integrator, alg:: DFBDF )
@@ -607,5 +631,9 @@ function step_accept_controller!(
607631 cache. qwait -= 1 # countdown
608632 end
609633 new_dt = integrator. dt / q
610- return is_disco ? min ((integrator. disco_checkpoint - integrator. t) / 4 , new_dt) : new_dt
634+ if is_disco
635+ bdf_restart_estimates! (cache)
636+ return min ((integrator. disco_checkpoint - integrator. t) / 4 , new_dt)
637+ end
638+ return new_dt
611639end
0 commit comments