Skip to content

Commit ed82867

Browse files
Merge pull request #692 from oscardssmith/reduce-instability-sensitivity
only bail out as instable when dt is small or error is somewhat conrtolled
2 parents 541e7fd + ccf79ed commit ed82867

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/integrator_interface.jl

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -619,10 +619,15 @@ function check_error(integrator::DEIntegrator)
619619
end
620620
if integrator.opts.unstable_check(integrator.dt, integrator.u, integrator.p,
621621
integrator.t)
622-
if integrator.opts.verbose
623-
@warn("Instability detected. Aborting")
622+
bigtol = max(integrator.opts.reltol, integrator.opts.abstol)
623+
# only declare instability if the dt is very small
624+
# or we have at least one digit of accuracy in the solution
625+
if integrator.dt<eps(integrator.t) || isdefined(integrator, :EEst) && integrator.EEst * bigtol < .1
626+
if integrator.opts.verbose
627+
@warn("Instability detected. Aborting")
628+
end
629+
return ReturnCode.Unstable
624630
end
625-
return ReturnCode.Unstable
626631
end
627632
if last_step_failed(integrator)
628633
if integrator.opts.verbose

0 commit comments

Comments
 (0)