Steady State Callbacks
These callbacks are designed to automatically terminate integration when a steady state is reached.
DiffEqCallbacks.TerminateSteadyState — Function
TerminateSteadyState(abstol = 1.0e-8, reltol = 1.0e-6, test = allDerivPass;
min_t = nothing, wrap_test::Val = Val(true)) -> DiscreteCallbackTerminateSteadyState can be used to solve the problem for the steady-state by running the solver until the derivatives of the problem converge to 0 or tspan[2] is reached. This is an alternative approach to root finding; see the Steady State Solvers documentation.
Arguments
abstol = 1.0e-8: absolute termination tolerance. It may be a scalar or an array with the same length as the state.reltol = 1.0e-6: relative termination tolerance. It may be a scalar or an array with the same length as the state.test = allDerivPass: function that evaluates the termination condition. By default, every derivative must be smaller thanabstolor the corresponding state magnitude timesreltol. A custom wrapped test must acceptintegrator,abstol,reltol, andmin_t.
Keywords
min_t = nothing: optional minimum integration time before termination is allowed.wrap_test::Val = Val(true): withVal(true), calltestastest(integrator, abstol, reltol, min_t). WithVal(false), usetestdirectly as the callback conditiontest(u, t, integrator).
Returns
DiscreteCallback: a callback that terminates the integrator whentestreturnstrue.
Examples
using DiffEqCallbacks, OrdinaryDiffEq
f(u, p, t) = 1 - u
prob = ODEProblem(f, 0.0, (0.0, 100.0))
cb = TerminateSteadyState(1.0e-8, 1.0e-8)
sol = solve(prob, Tsit5(); callback = cb)