DiffEqBase API
This page lists the user-facing DiffEqBase API documented with OrdinaryDiffEq. Solver-author hooks, callback machinery, and cache types are documented separately in the developer extension API.
Specialization levels
DiffEqBase implements parameter-container specialization levels owned and documented by SciMLBase. They are re-exported from OrdinaryDiffEq for use with a plain using OrdinaryDiffEq.
AutoDespecialize accepts arbitrary parameter objects. During solver concretization, DiffEqBase stores p in a SciMLBase.DespecializedParameters container with a stable outer type. SciML function calls recover the original concrete parameter at a dynamic function barrier, allowing precompiled solver code to be shared across parameter layouts. AutoSpecialize retains its existing behavior and does not select this container.
AutoRespecialize is the constrained, non-dynamic policy formerly named AutoDePSpecialize. Supported paths pack compatible parameters into an opaque container and recover the original concrete type without dynamic dispatch. The deprecated AutoDePSpecialize name remains available as an alias.
OrdinaryDiffEq re-exports AutoDespecialize, AutoRespecialize, and the deprecated AutoDePSpecialize alias. Their canonical API documentation is on the linked SciMLBase specialization-level page.
OrdinaryDiffEq.AutoDespecialize — Type
AutoDespecializeUse a stable dynamic parameter container so compiled solver code can be shared across different concrete parameter layouts. The original parameter is recovered at the SciML function call barrier.
OrdinaryDiffEq.AutoRespecialize — Type
AutoRespecializeUse the constrained non-dynamic parameter policy, which recovers the original concrete parameter type from an opaque container on supported solver paths.
OrdinaryDiffEq.AutoDePSpecialize — Type
AutoDePSpecializeDeprecated alias for AutoRespecialize.
SciMLBase.AutoDePSpecialize — Type
AutoDePSpecializeDeprecated name for AutoRespecialize. New code should use AutoRespecialize.
SciMLBase.AutoRespecialize — Type
struct AutoRespecialize <: SciMLBase.AbstractSpecializationAutoRespecialize extends AutoSpecialize by additionally de-specializing the parameter object. Solver paths with a supported opaque-parameter strategy pack an isbits, non-NullParametersp into a fixed-type opaque container (e.g. RespecializeParams.OpaqueParams) and install callable wrappers whose signatures carry the opaque container type in the p slot instead of typeof(p). The concretized problem type — and with it the solver's compilation — then becomes independent of the user's parameter struct type, so a single compiled (and precompiled) solve is shared across all isbits parameter types. Inside the user's f, p is recovered at its original concrete type via a type-stable, allocation-free unpack, so the model function itself remains fully specialized.
AutoRespecialize is the recommended choice for latency-sensitive workflows that construct many problems with differently-typed parameter structs (parameter studies over configuration structs, package test suites, teaching setups).
Support is solver-specific, like all specialization levels. Where a solver path has no opaque-parameter strategy — or where p is not isbits or is NullParameters — behavior falls back to plain AutoSpecialize. Solvers that apply the packing keep the opaque container in the concretized problem (e.g. sol.prob.p), since installed wrappers may be re-invoked with it; consult the solver's documentation for how to recover the original value.
Example
struct MyParams
k::Float64
end
f(du, u, p, t) = (du .= p.k .* u)
ODEProblem{true, SciMLBase.AutoRespecialize}(f, [1.0], (0.0, 1.0), MyParams(2.0))Default callback behavior
DiffEqBase.ODE_DEFAULT_ISOUTOFDOMAIN — Function
ODE_DEFAULT_ISOUTOFDOMAIN(u, p, t)The default isoutofdomain predicate used by the integrators. It always returns false, i.e. no state is considered out of the problem's domain. Pass a custom predicate via the isoutofdomain solver keyword to reject steps whose proposed state leaves a valid domain.
DiffEqBase.ODE_DEFAULT_NORM — Function
ODE_DEFAULT_NORM(u, t)
ODE_DEFAULT_NORM(f, u, t)The default internal norm used by the integrators for error estimation and step-size control. It is the (optionally f-weighted) RMS norm: roughly sqrt(sum(abs2, u) / length(u)), which scales with the magnitude of the state but not its dimensionality, with specialized methods for scalars, Arrays, static arrays, and nested array types. Pass a custom callable via the internalnorm solver keyword to override it.
DiffEqBase.ODE_DEFAULT_PROG_MESSAGE — Function
ODE_DEFAULT_PROG_MESSAGE(dt, u, p, t)The default progress-bar message builder used by the integrators when progress = true. It returns a short multi-line string reporting the current dt, t, and the largest-magnitude component of the state u. Pass a custom callable via the progress_message solver keyword to override it.
DiffEqBase.ODE_DEFAULT_UNSTABLE_CHECK — Function
ODE_DEFAULT_UNSTABLE_CHECK(dt, u, p, t) -> BoolReturn whether the default ODE instability check considers the current state unstable.
The generic fallback returns false. Numeric scalars, arrays, and ArrayPartitions return true when any state entry is infinite or non-finite. This is the default used by OrdinaryDiffEq solvers when no unstable_check callback is supplied.
Arguments
dt: Current step size.u: Current state.p: Problem parameters.t: Current time.
Returns
Bool:truewhen the state should be treated as unstable.
DiffEqBase.NAN_CHECK — Function
NAN_CHECK(x)Recursively test whether x holds a NaN. The integrators use this to detect a step that produced NaN and reject it.
Methods are provided for numbers, AbstractArrays, RecursiveArrayTools.AbstractVectorOfArrays and RecursiveArrayTools.ArrayPartitions; nested containers are descended into, so a state made of arrays of arrays reports true if any leaf is NaN. Enum values always report false, which keeps discrete components of a mixed state vector from being sent through isnan. Add a method to make the check reach the elements of a custom state type:
DiffEqBase.NAN_CHECK(x::MyStateType) = any(DiffEqBase.NAN_CHECK, x.parts)NaN is only one of the ways a step can go bad; Inf and overflow are handled separately by ODE_DEFAULT_UNSTABLE_CHECK.
Runge-Kutta tableau types
DiffEqBase.Tableau — Type
abstract type TableauDiffEqBase.ODERKTableau — Type
abstract type ODERKTableau <: DiffEqBase.TableauDiffEqBase.ExplicitRKTableau — Type
mutable struct ExplicitRKTableau{MType<:(AbstractMatrix), VType<:(AbstractVector), CType<:(AbstractVector), S, IType} <: DiffEqBase.ODERKTableauHolds a tableau which defines an explicit Runge-Kutta method.
DiffEqBase.ImplicitRKTableau — Type
mutable struct ImplicitRKTableau{MType<:(AbstractMatrix), VType<:(AbstractVector), CType<:(AbstractVector)} <: DiffEqBase.ODERKTableauHolds a tableau which defines an implicit Runge-Kutta method.
Cost and convergence helpers
DiffEqBase.ConvergenceSetup — Type
struct ConvergenceSetup{P, C}DiffEqBase.DECostFunction — Type
abstract type DECostFunctionDAE initialization
DiffEqBase.DefaultInit — Type
struct DefaultInit <: DAEInitializationAlgorithmThe default initialization algorithm for DAEs. This will use heuristics to determine the most appropriate initialization based on the problem type.
For Sundials, this will use:
OverrideInitif the problem hasinitialization_data(typically from ModelingToolkit)CheckInitotherwise
DiffEqBase.BrownFullBasicInit — Type
struct BrownFullBasicInit{T, F} <: DAEInitializationAlgorithmThe Brown full basic initialization algorithm for DAEs. This implementation is based on the algorithm described in:
Peter N. Brown, Alan C. Hindmarsh, and Linda R. Petzold, "Consistent Initial Condition Calculation for Differential-Algebraic Systems", SIAM Journal on Scientific Computing, Vol. 19, No. 5, pp. 1495-1512, 1998. DOI: https://doi.org/10.1137/S1064827595289996
This method modifies the algebraic variables and their derivatives to be consistent with the DAE constraints, while keeping the differential variables fixed. It uses Newton's method to solve for consistent initial values.
This is the default initialization for many DAE solvers when differential_vars is provided, allowing the solver to distinguish between differential and algebraic variables.
Parameters
abstol: Absolute tolerance for the nonlinear solver (default: 1e-10)nlsolve: Custom nonlinear solver to use (optional)
DiffEqBase.ShampineCollocationInit — Type
struct ShampineCollocationInit{T, F} <: DAEInitializationAlgorithmThe Shampine collocation initialization algorithm for DAEs. This implementation is based on the algorithm described in:
Lawrence F. Shampine, "Consistent Initial Condition for Differential-Algebraic Systems", SIAM Journal on Scientific Computing, Vol. 22, No. 6, pp. 2007-2026, 2001. DOI: https://doi.org/10.1137/S1064827599355049
This method uses collocation on the first two steps to find consistent initial conditions. It modifies both the differential and algebraic variables to satisfy the DAE constraints. This is more general than BrownBasicInit but may be more expensive computationally.
This method is useful when you need to modify all variables (both differential and algebraic) to achieve consistency, rather than just the algebraic ones.
Parameters
initdt: Initial time step to use in the collocation method (optional)nlsolve: Custom nonlinear solver to use (optional)
Sensitivity passthrough
DiffEqBase.SensitivityADPassThrough — Type
Ignores all adjoint definitions (i.e. sensealg) and proceeds to do standard AD through the solve functions. Generally only used internally for implementing discrete sensitivity algorithms.