Steady State Callbacks

These callbacks are designed to automatically terminate integration when a steady state is reached.

DiffEqCallbacks.TerminateSteadyStateFunction
TerminateSteadyState(abstol = 1.0e-8, reltol = 1.0e-6, test = allDerivPass;
    min_t = nothing, wrap_test::Val = Val(true)) -> DiscreteCallback

TerminateSteadyState 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 than abstol or the corresponding state magnitude times reltol. A custom wrapped test must accept integrator, abstol, reltol, and min_t.

Keywords

  • min_t = nothing: optional minimum integration time before termination is allowed.
  • wrap_test::Val = Val(true): with Val(true), call test as test(integrator, abstol, reltol, min_t). With Val(false), use test directly as the callback condition test(u, t, integrator).

Returns

  • DiscreteCallback: a callback that terminates the integrator when test returns true.

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)
source