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
Copy file name to clipboardExpand all lines: src/integrator_interface.jl
+39-28Lines changed: 39 additions & 28 deletions
Original file line number
Diff line number
Diff line change
@@ -584,53 +584,64 @@ function check_error(integrator::DEIntegrator)
584
584
if integrator.sol.retcode ∉ (ReturnCode.Success, ReturnCode.Default)
585
585
return integrator.sol.retcode
586
586
end
587
+
opts = integrator.opts
588
+
verbose = opts.verbose
587
589
# This implementation is intended to be used for ODEIntegrator and
588
590
# SDEIntegrator.
589
591
ifisnan(integrator.dt)
590
-
ifintegrator.opts.verbose
592
+
if verbose
591
593
@warn("NaN dt detected. Likely a NaN value in the state, parameters, or derivative value caused this outcome.")
592
594
end
593
595
return ReturnCode.DtNaN
594
596
end
595
-
if integrator.iter >integrator.opts.maxiters
596
-
ifintegrator.opts.verbose
597
+
if integrator.iter > opts.maxiters
598
+
if verbose
597
599
@warn("Interrupted. Larger maxiters is needed. If you are using an integrator for non-stiff ODEs or an automatic switching algorithm (the default), you may want to consider using a method for stiff equations. See the solver pages for more details (e.g. https://docs.sciml.ai/DiffEqDocs/stable/solvers/ode_solve/#Stiff-Problems).")
598
600
end
599
601
return ReturnCode.MaxIters
600
602
end
601
603
602
604
# The last part:
603
-
# If you are close to the end, don't exit: let the user hit the end!
604
-
# However, if we try that and the step fails, exit instead of infinite loop
EEst =", and step error estimate = $(integrator.EEst)"
619
+
else
620
+
EEst =""
621
+
end
622
+
@warn("dt($(integrator.dt)) <= dtmin($(opts.dtmin)) at t=$(integrator.t)$EEst. Aborting. There is either an error in your model specification or the true solution is unstable.")
615
623
end
616
-
@warn("dt($(integrator.dt)) <= dtmin($(integrator.opts.dtmin)) at t=$(integrator.t)$EEst. Aborting. There is either an error in your model specification or the true solution is unstable.")
617
-
end
618
-
return ReturnCode.DtLessThanMin
619
-
end
620
-
if integrator.opts.unstable_check(integrator.dt, integrator.u, integrator.p,
# 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")
624
+
return ReturnCode.DtLessThanMin
625
+
elseif!step_accepted && integrator.t isa AbstractFloat &&abs(integrator.dt) <=abs(eps(integrator.t))
626
+
if verbose
627
+
ifisdefined(integrator, :EEst)
628
+
EEst =", and step error estimate = $(integrator.EEst)"
629
+
else
630
+
EEst =""
631
+
end
632
+
@warn("dt($(integrator.dt)) <= eps(t)($(integrator.t)) $EEst. Aborting. There is either an error in your model specification or the true solution is unstable (or the true solution can not be represented in the precision of $(eltype(integrator.u))).")
628
633
end
629
634
return ReturnCode.Unstable
630
635
end
631
636
end
637
+
if step_accepted && opts.unstable_check(integrator.dt, integrator.u, integrator.p, integrator.t)
638
+
if verbose
639
+
@warn("Instability detected. Aborting")
640
+
end
641
+
return ReturnCode.Unstable
642
+
end
632
643
iflast_step_failed(integrator)
633
-
ifintegrator.opts.verbose
644
+
if verbose
634
645
@warn("Newton steps could not converge and algorithm is not adaptive. Use a lower dt.")
0 commit comments