File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -220,6 +220,8 @@ function solve!(integrator::SimpleIntegratorSSP)
220
220
end
221
221
end
222
222
223
+ unstable_check (integrator. dt, integrator. u, integrator)
224
+
223
225
# respect maximum number of iterations
224
226
if integrator. iter >= integrator. opts. maxiters && ! integrator. finalstep
225
227
@warn " Interrupted. Larger maxiters is needed."
@@ -258,6 +260,14 @@ function get_proposed_dt(integrator::SimpleIntegratorSSP)
258
260
return ifelse (integrator. opts. adaptive, integrator. dt, integrator. dtcache)
259
261
end
260
262
263
+ function unstable_check (dt, u_ode, integrator:: SimpleIntegratorSSP )
264
+ if ! isfinite (dt) || isnan (dt) || ! all (isfinite .(u_ode)) || any (isnan .(u_ode))
265
+ @warn " Instability detected. Aborting"
266
+ terminate! (integrator)
267
+ end
268
+ return nothing
269
+ end
270
+
261
271
# stop the time integration
262
272
function terminate! (integrator:: SimpleIntegratorSSP )
263
273
integrator. finalstep = true
You can’t perform that action at this time.
0 commit comments