Termination Conditions

Provides a API to specify termination conditions for NonlinearProblem and SteadyStateProblem. For details on the various termination modes:

Termination Conditions

The termination condition is constructed as:

cache = init(du, u, AbsSafeBestTerminationMode(); abstol = 1e-9, reltol = 1e-9)

If abstol and reltol are not supplied, then we choose a default based on the element types of du and u.

We can query the cache using DiffEqBase.get_termination_mode, DiffEqBase.get_abstol and DiffEqBase.get_reltol.

To test for termination simply call the cache:

terminated = cache(du, u, uprev)

Absolute Tolerance

DiffEqBase.AbsTerminationModeType
AbsTerminationMode <: AbstractNonlinearTerminationMode

Terminates if $all \left( | \frac{\partial u}{\partial t} | \leq abstol \right)$.

DiffEqBase.AbsSafeTerminationModeType
AbsSafeTerminationMode <: AbstractSafeNonlinearTerminationMode

Essentially AbsNormTerminationMode + terminate if there has been no improvement for the last patience_steps + terminate if the solution blows up (diverges).

Constructor

AbsSafeTerminationMode(; protective_threshold = nothing, patience_steps = 100,
    patience_objective_multiplier = 3, min_max_factor = 1.3, max_stalled_steps = nothing)
DiffEqBase.AbsSafeBestTerminationModeType
AbsSafeBestTerminationMode <: AbstractSafeBestNonlinearTerminationMode

Essentially AbsSafeTerminationMode, but caches the best solution found so far.

Constructor

AbsSafeBestTerminationMode(; protective_threshold = nothing, patience_steps = 100,
    patience_objective_multiplier = 3, min_max_factor = 1.3, max_stalled_steps = nothing)

Relative Tolerance

DiffEqBase.RelTerminationModeType
RelTerminationMode <: AbstractNonlinearTerminationMode

Terminates if $all \left(| \frac{\partial u}{\partial t} | \leq reltol \times | u | \right)$.

DiffEqBase.RelNormTerminationModeType
RelNormTerminationMode <: AbstractNonlinearTerminationMode

Terminates if $\| \frac{\partial u}{\partial t} \| \leq reltol \times \| \frac{\partial u}{\partial t} + u \|$

DiffEqBase.RelSafeTerminationModeType
RelSafeTerminationMode <: AbstractSafeNonlinearTerminationMode

Essentially RelNormTerminationMode + terminate if there has been no improvement for the last patience_steps + terminate if the solution blows up (diverges).

Constructor

RelSafeTerminationMode(; protective_threshold = nothing, patience_steps = 100,
    patience_objective_multiplier = 3, min_max_factor = 1.3, max_stalled_steps = nothing)
DiffEqBase.RelSafeBestTerminationModeType
RelSafeBestTerminationMode <: AbstractSafeBestNonlinearTerminationMode

Essentially RelSafeTerminationMode, but caches the best solution found so far.

Constructor

RelSafeBestTerminationMode(; protective_threshold = nothing, patience_steps = 100,
    patience_objective_multiplier = 3, min_max_factor = 1.3, max_stalled_steps = nothing)

Both Absolute and Relative Tolerance

DiffEqBase.NormTerminationModeType
NormTerminationMode <: AbstractNonlinearTerminationMode

Terminates if $\| \frac{\partial u}{\partial t} \| \leq reltol \times \| \frac{\partial u}{\partial t} + u \|$ or $\| \frac{\partial u}{\partial t} \| \leq abstol$

DiffEqBase.SteadyStateDiffEqTerminationModeType
SteadyStateDiffEqTerminationMode <: AbstractNonlinearTerminationMode

Check if all values of the derivative is close to zero wrt both relative and absolute tolerance.

The default used in SteadyStateDiffEq.jl! Not recommended for large problems, since the convergence criteria is very strict and never reliably satisfied for most problems.

The following was named to match an older version of SimpleNonlinearSolve. It is currently not used as a default anywhere.

DiffEqBase.SimpleNonlinearSolveTerminationModeType
SimpleNonlinearSolveTerminationMode <: AbstractNonlinearTerminationMode

Check if all values of the derivative is close to zero wrt both relative and absolute tolerance. Or check that the value of the current and previous state is within the specified tolerances.

The default used in SimpleNonlinearSolve.jl! Not recommended for large problems, since the convergence criteria is very strict and never reliably satisfied for most problems.

Return Codes (Deprecated)

These are deprecated and will be removed in a future release. Use the use_deprecated_retcodes = Val(false) option to SciMLBase.init to use the new return ReturnCode versions.

DiffEqBase.NonlinearSafeTerminationReturnCodeModule
NonlinearSafeTerminationReturnCode

Return Codes for the safe nonlinear termination conditions.

These return codes have been deprecated. Termination Conditions will return SciMLBase.Retcode.T starting from v7.