SciMLFunctions (Jacobians, Sparsity, Etc.)

The SciML ecosystem provides an extensive interface for declaring extra functions associated with the differential equation's data. In traditional libraries there is usually only one option: the Jacobian. However, we allow for a large array of pre-computed functions to speed up the calculations. This is offered via the SciMLFunction types which can be passed to the problems.

Definition of the AbstractSciMLFunction Interface

The following standard principles should be adhered to across all AbstractSciMLFunction instantiations.

Generic Usage Rules

Generic solver code must treat an AbstractSciMLFunction as a callable container and query its capability traits before using optional callbacks. The portable contract is:

  • call the function using the signature documented by its function family; do not infer the signature from the concrete wrapper's fields;
  • use isinplace(f) to select the mutating or returning call convention;
  • use has_jac, has_jvp, has_vjp, has_paramjac, has_observed, and the related has_* traits before reading an optional callback;
  • use unwrapped_f(f) only when an operation explicitly needs the underlying callable, and preserve the wrapper's in-place convention after wrapping;
  • treat optional callbacks as absent when the corresponding trait is false, rather than assuming a field exists on every concrete subtype.

An implementation of a new function container should be testable through these generic operations alone. A downstream package should therefore be able to write code such as:

function evaluate_model(f::SciMLBase.AbstractSciMLFunction, u, p, t)
    return (; value = f(u, p, t), has_jac = SciMLBase.has_jac(f))
end

The concrete function type remains responsible for documenting callback arguments, return values, and field layout. Generic code must not reach into those fields to discover capabilities.

Common Function Choice Definitions

The full interface available to the solvers is as follows:

  • jac: The Jacobian of the differential equation with respect to the state variable u at a time t with parameters p.
  • paramjac: The Jacobian of the differential equation with respect to p at state u at time t.
  • analytic: Defines an analytical solution using u0 at time t with p which will cause the solvers to return errors. Used for testing.
  • syms: Allows you to name your variables for automatic names in plots and other output.
  • jac_prototype: Defines the type to be used for any internal Jacobians within the solvers.
  • sparsity: Defines the sparsity pattern to be used for the sparse differentiation schemes. By default this is equal to jac_prototype. See the sparsity handling portion of this page for more information.
  • colorvec: The coloring pattern used by the sparse differentiator. See the sparsity handling portion of this page for more information.
  • observed: A function which allows for generating other observables from a solution.

Each function type additionally has some specific arguments, refer to their documentation for details.

In-place Specification and No-Recompile Mode

Each SciMLFunction type can be called with an "is inplace" (iip) choice.

ODEFunction(f)
ODEFunction{iip}(f)

which is a boolean for whether the function is in the inplace form (mutating to change the first value). This is automatically determined using the methods table but note that for full type-inferability of the AbstractSciMLProblem this iip-ness should be specified.

In-place Trait Contract

Every concrete AbstractSciMLFunction{iip} subtype must encode whether its primary callback mutates its first argument in the iip parameter. Generic solver and extension code must obtain this information through isinplace(f), rather than inspecting fields or type parameters. The generic trait returns true for in-place and false for out-of-place function containers; callers can therefore support new concrete subtypes without adding type-specific dispatches.

Specialization Choices

Each SciMLFunction type allows for specialization choices

ODEFunction{iip, specialization}(f)

which designates how the compiler should specialize on the model function f. For more details on specialization choices, see the SciMLProblems page.

Specifying Jacobian Types

The jac field of an inplace style SciMLFunction has the signature jac(J,u,p,t), which updates the Jacobian J in-place. The intended type for J can sometimes be inferred (e.g. when it is just a dense Matrix), but not in general. To supply the type information, you can provide a jac_prototype in the function's constructor.

The following example creates an inplace ODEFunction whose Jacobian is a Diagonal:

using LinearAlgebra
f = (du, u, p, t) -> du .= t .* u
jac = (J, u, p, t) -> (J[1, 1] = t; J[2, 2] = t; J)
jp = Diagonal(zeros(2))
fun = ODEFunction(f; jac, jac_prototype = jp)

The prototype declares Jacobian shape, element type, and structure. It must support the operations required by the selected differentiation and linear solver, including writes for an in-place jac and any multiplication, diagonal-shift, or factorization operations that solver performs. Solvers may copy, allocate with similar, or convert the prototype, so code must not rely on its object identity or aliasing behavior.

When jac_prototype is an AbstractSciMLOperator and jac is omitted, the constructor creates a Jacobian update using update_coefficients! for the in-place form and update_coefficients for the out-of-place form. Refer to the SciMLOperators section for more information on setting up time/parameter dependent operators. The operator types and traits named here are re-exported by SciMLBase, so using SciMLBase is enough to build them; see Reexported API for the exact list and for what has to be imported from SciMLOperators directly.

Sparsity Handling

Solver packages select differentiation backends through their algorithm and option interfaces. Depending on that choice, they may use finite differences, automatic differentiation, sparse coloring, explicit derivative functions, or matrix-free Jacobian-vector and vector-Jacobian products. The function wrapper provides structural information without requiring a particular backend package.

Set jac_prototype to the concrete matrix or operator representation that should be used for the Jacobian. Set sparsity to the structural nonzero pattern used for sparse differentiation; it defaults to jac_prototype when omitted. Set colorvec to a column-color vector compatible with both that pattern and the selected backend, or leave it as nothing so coloring can be computed when needed. A prototype and color vector are performance and representation contracts, not substitutes for operations required by the selected linear solver.

Function Wrapper Rules

SciMLBase provides small wrapper types that turn an ODE-style model function into a one-variable callable for derivative code. These wrappers close over the fixed arguments and expose only the argument being differentiated.

  • Time wrappers fix u and p, then expose t.
  • State wrappers fix t and p, then expose u.
  • isinplace(wrapper) preserves the in-place convention detected from the wrapped function.
  • In-place wrappers support caller-provided output arrays. Their one-argument convenience calls allocate an output with similar to match the exposed state.
  • Wrapper trait queries forward to the underlying function where applicable, so derivative code should query traits instead of inspecting wrapper fields.

Traits

SciMLBase.isinplace — Function
isinplace(
    f, inplace_param_number, fname = "f", iip_preferred = true;
    has_two_dispatches = true,
    outofplace_param_number = inplace_param_number - 1
)
isinplace(f::AbstractSciMLFunction[, inplace_param_number])

Check whether a user callback follows the in-place SciML convention.

For an AbstractSciMLFunction, isinplace returns the iip type parameter without inspecting methods. For an ordinary callable, it inspects the method table and compares available arities to the expected in-place and out-of-place signatures.

Arguments

  • f: An AbstractSciMLFunction or callback whose calling convention is being queried.
  • inplace_param_number: Number of positional arguments in the in-place callback signature. For example, an ODE right-hand side uses 4 for f!(du, u, p, t).
  • fname: Name used to identify f in an argument-convention error.
  • iip_preferred: Convention selected when f provides both accepted arities.

Keywords

  • has_two_dispatches: Whether the interface accepts both in-place and out-of-place callback signatures. Set this to false for interfaces with only one accepted arity, such as optimization objectives.
  • isoptimization: Whether errors should use optimization-specific wording.
  • outofplace_param_number: Number of positional arguments in the out-of-place callback signature. It defaults to inplace_param_number - 1; the ODE out-of-place form is therefore f(u, p, t).

Returns

Returns true for the in-place convention and false for the out-of-place convention. Concrete AbstractSciMLFunction subtypes must expose their convention through this trait; generic solver code must query isinplace(f) and must not inspect subtype fields or type parameters directly.

If neither accepted arity is present, isinplace throws a function-argument error that uses fname to identify the offending callback. If both accepted arities are present, iip_preferred = true chooses the in-place interpretation and iip_preferred = false chooses the out-of-place interpretation.

Examples

f!(du, u, p, t) = (du .= u)
f(u, p, t) = u

isinplace(f!, 4) # true
isinplace(f, 4)  # false

See also

source
isinplace(prob::AbstractSciMLProblem)

Return the in-place convention encoded by a SciML problem.

true means the primary model callback mutates its first argument, such as f(du, u, p, t) for an ODE or f(resid, u, p) for a nonlinear problem. false means the callback returns its computed value, such as f(u, p, t). Concrete problem types store this choice as a type parameter so solvers can dispatch without re-inspecting user methods.

Constructors infer this value from raw callables with isinplace, but users and problem builders can specify the type parameter explicitly for type stability. Remake, problem conversion, display, initialization, and solver setup code should query this trait instead of re-detecting callback arity.

Subtypes of AbstractSciMLProblem should implement this by returning their stored in-place type parameter. Wrapper problems should forward to the wrapped problem when the wrapper does not define its own model convention.

source
SciMLBase.unwrapped_f — Function
unwrapped_f(f)

Return the underlying user function with any function-wrapper layers removed. When f has been wrapped (e.g. by FunctionWrapperSpecialize specialization, which specializes f to a fixed (u, p, t) signature via a FunctionWrappersWrapper), this recovers the original unwrapped function so it can be called on other argument types. If f is not wrapped, it is returned unchanged.

source
SciMLBase.has_analytic — Function
has_analytic(f::AbstractSciMLFunction)

Return whether f carries a non-nothing analytic solution callback.

Analytic callbacks are optional and are mainly used by solvers and tests to compare numerical and exact solutions. The expected callback signature depends on the concrete function type, matching the independent variables described by that type's docstring.

source
SciMLBase.has_jac — Function
has_jac(f::AbstractSciMLFunction)

Return whether f carries a non-nothing Jacobian callback.

For differential equation functions this is usually the Jacobian with respect to the state variable. For implicit functions such as DAEs, the concrete function docstring defines the Jacobian convention. Solver code should query this trait before accessing f.jac.

source
SciMLBase.has_jvp — Function
has_jvp(f::AbstractSciMLFunction)

Return whether f carries a non-nothing Jacobian-vector product callback.

When true, solvers may use f.jvp to apply the Jacobian to a direction without materializing the full Jacobian. The callback must follow the in-place or out-of-place convention of the concrete function wrapper.

source
SciMLBase.has_vjp — Function
has_vjp(f::AbstractSciMLFunction)

Return whether f carries a non-nothing vector-Jacobian product callback.

When true, solvers or sensitivity algorithms may use f.vjp to apply the adjoint Jacobian action without materializing the full Jacobian. The callback signature is defined by the concrete function type.

source
SciMLBase.has_tgrad — Function
has_tgrad(f::AbstractSciMLFunction)

Return whether f carries a non-nothing time-gradient callback.

The time-gradient callback represents the derivative of the model function with respect to the independent variable while holding the state and parameters fixed. It is only meaningful for function types with an explicit independent variable.

source
SciMLBase.has_paramjac — Function
has_paramjac(f::AbstractSciMLFunction) -> Bool

Return whether f carries a non-nothing parameter-Jacobian callback.

When this returns true, sensitivity or solver code may use f.paramjac to evaluate the derivative of the model function with respect to parameters without selecting an automatic-differentiation fallback. The callback must follow the in-place or out-of-place convention of f.

source
SciMLBase.has_vjp_p — Function
has_vjp_p(f::AbstractSciMLFunction) -> Bool

Return whether f carries a non-nothing parameter vector-Jacobian-product callback.

When this returns true, sensitivity or solver code may use f.vjp_p to apply the adjoint derivative with respect to parameters without materializing a parameter Jacobian. The callback must follow the in-place or out-of-place convention of f.

source
SciMLBase.has_observed — Function
has_observed(f::AbstractSciMLFunction) -> Bool

Return whether f carries a non-default observed-quantity callback.

Observed callbacks define derived quantities evaluated from a problem state, parameters, and independent variable. A true result means downstream code may use the documented observed-function interface; a false result means it must not inspect f.observed.

source
SciMLBase.has_initialization_data — Function
has_initialization_data(f)

Return whether f carries non-nothing initialization metadata.

Initialization data stores problem-level initialization hooks such as an initialization problem, an updater for that problem, and parameter/state mapping functions. Solvers should query this trait before using those hooks.

source
SciMLBase.has_sys — Function
has_sys(f::AbstractSciMLFunction)

Return whether f carries a non-nothing symbolic system.

The system is the symbolic description the function was generated from, such as a ModelingToolkit system or a SymbolicIndexingInterface.SymbolCache. It backs symbolic indexing and the initialization pipeline, so code that must keep a problem's u0/p in a form those paths can read should query this trait rather than inspecting f.sys, which is absent on function types that carry no system.

source

AbstractSciMLFunction API

Abstract SciML Functions

SciMLBase.AbstractSciMLFunction — Type
abstract type AbstractSciMLFunction{iip}

Base interface for callable model-function containers used by SciML problems.

The iip type parameter records the in-place convention for the primary model function and is returned by isinplace. Subtypes with iip == true write their result into the first argument and usually return nothing; subtypes with iip == false return the computed value. Concrete function wrappers should be callable with the same signature as their stored model function, and should store optional derivative, sparsity, symbolic, and initialization metadata in fields that the public has_* traits can query.

Subtypes should document the primary call signature, any auxiliary callbacks such as Jacobians or vector-Jacobian products, the meaning of each prototype field, and which optional callbacks must follow the same in-place convention as the primary function. When optional data is unavailable, constructors should either omit the field for that subtype or store nothing so that the corresponding trait returns false.

source
SciMLBase.AbstractDiffEqFunction — Type
abstract type AbstractDiffEqFunction{iip} <: SciMLBase.AbstractSciMLFunction{iip}

Base interface for function containers that define differential equation dynamics.

Concrete subtypes describe right-hand sides, residuals, maps, boundary-condition systems, stochastic drift/diffusion pairs, or related decompositions used by AbstractDEProblem subtypes. They follow the AbstractSciMLFunction in-place contract and additionally standardize optional differential-equation metadata such as mass matrices, analytic solutions, Jacobians, time gradients, Jacobian-vector products, vector-Jacobian products, W-factorization callbacks, parameter Jacobians, sparsity/coloring prototypes, symbolic systems, and initialization data. The exact primary call signature is determined by the concrete subtype, for example ODE functions use f(u, p, t) or f(du, u, p, t), while DAE functions use residual signatures involving du, u, p, and t.

source
SciMLBase.AbstractODEFunction — Type
abstract type AbstractODEFunction{iip} <: SciMLBase.AbstractDiffEqFunction{iip}

Interface for ODE right-hand-side containers.

Subtypes represent equations of the form du/dt = f(u, p, t) or mass-matrix variants M * du/dt = f(u, p, t). They should support either f(du, u, p, t) for in-place functions or f(u, p, t) for out-of-place functions according to the iip type parameter. Optional callbacks such as jac, tgrad, jvp, vjp, Wfact, Wfact_t, paramjac, and vjp_p must follow the same in-place convention as the primary function when present. Mass matrices, Jacobian prototypes, sparsity patterns, color vectors, symbolic systems, observed quantities, and initialization data are exposed through fields on concrete wrappers such as ODEFunction, SplitFunction, and DynamicalODEFunction.

source
SciMLBase.AbstractSDEFunction — Type
abstract type AbstractSDEFunction{iip} <: SciMLBase.AbstractDiffEqFunction{iip}

Interface for stochastic differential equation function containers.

Subtypes represent drift/diffusion systems such as du = f(u, p, t) dt + g(u, p, t) dW. The drift and diffusion callbacks must use a consistent in-place convention: f(du, u, p, t) and g(du, u, p, t) for in-place functions, or f(u, p, t) and g(u, p, t) for out-of-place functions. Optional Jacobian-like callbacks describe the drift unless the concrete subtype documents otherwise; Milstein-style diffusion derivatives are carried by ggprime when supported.

source
SciMLBase.AbstractDDEFunction — Type
abstract type AbstractDDEFunction{iip} <: SciMLBase.AbstractDiffEqFunction{iip}

Interface for delay differential equation function containers.

Subtypes represent right-hand sides that depend on the current state and a history object, using f(du, u, h, p, t) for in-place functions or f(u, h, p, t) for out-of-place functions. The history object is supplied by the DDE/SDDE integrator and should be queried using the delay-problem history interface. Optional derivative, sparsity, mass-matrix, symbolic, and initialization fields follow the same conventions as AbstractODEFunction, with callback signatures extended by the h argument.

source
SciMLBase.AbstractDAEFunction — Type
abstract type AbstractDAEFunction{iip} <: SciMLBase.AbstractDiffEqFunction{iip}

Interface for fully implicit differential-algebraic equation function containers.

DAE functions represent residuals G(du, u, p, t) = 0, using f(resid, du, u, p, t) for in-place functions or f(du, u, p, t) for out-of-place functions. Jacobian callbacks may provide the combined solver Jacobian gamma * dG/d(du) + dG/du, or separate jac_du and jac_u components when supported. Optional derivative, sparsity, symbolic, and initialization metadata follow the AbstractSciMLFunction trait contract.

source
SciMLBase.AbstractRODEFunction — Type
abstract type AbstractRODEFunction{iip} <: SciMLBase.AbstractDiffEqFunction{iip}

Interface for random ordinary differential equation function containers.

RODE functions use a solver-supplied noise/history value W in addition to the ODE arguments, with signatures f(du, u, p, t, W) or f(u, p, t, W). Concrete subtypes should document whether analytic callbacks are pointwise in W or operate on the full solution/noise history, and which derivative callbacks are supported for the random input convention.

source
SciMLBase.AbstractDiscreteFunction — Type
abstract type AbstractDiscreteFunction{iip} <: SciMLBase.AbstractDiffEqFunction{iip}

Interface for discrete dynamical-system function containers.

Explicit discrete functions update a state sequence through signatures such as f(du, u, p, t) or f(u, p, t). Implicit discrete functions represent residual equations for the next state, commonly f(resid, u_next, u, p, t) or f(u_next, u, p, t). Concrete subtypes should document which map or residual signature they implement, whether an analytic solution callback is available, and any residual prototype needed by solvers.

source
SciMLBase.AbstractSDDEFunction — Type
abstract type AbstractSDDEFunction{iip} <: SciMLBase.AbstractDiffEqFunction{iip}

Interface for stochastic delay differential equation function containers.

SDDE functions combine the SDE drift/diffusion convention with a delay history argument, using f(du, u, h, p, t) and g(du, u, h, p, t) for in-place functions or f(u, h, p, t) and g(u, h, p, t) for out-of-place functions. Concrete subtypes should document their history queries, noise-rate shape, and which optional derivative callbacks are defined for the delayed drift.

source
SciMLBase.AbstractNonlinearFunction — Type
abstract type AbstractNonlinearFunction{iip} <: SciMLBase.AbstractSciMLFunction{iip}

Interface for nonlinear system function containers.

Subtypes represent systems f(u, p) = 0, using f(resid, u, p) for in-place functions or f(u, p) for out-of-place functions. Optional callbacks include analytic solutions, Jacobians, Jacobian-vector and vector-Jacobian products, parameter Jacobians, mass-matrix-like metadata, residual prototypes, sparsity and coloring data, symbolic systems, observed quantities, and initialization data.

source
SciMLBase.AbstractIntervalNonlinearFunction — Type
abstract type AbstractIntervalNonlinearFunction{iip} <: SciMLBase.AbstractSciMLFunction{iip}

Interface for one-dimensional interval nonlinear function containers.

Subtypes represent scalar or residual-valued equations over an interval variable, using f(out, t, p) for in-place functions or f(t, p) for out-of-place functions. Concrete wrappers should document their analytic callback and symbolic metadata conventions.

source
SciMLBase.AbstractIntegralFunction — Type
abstract type AbstractIntegralFunction{iip} <: SciMLBase.AbstractSciMLFunction{iip}

Base interface for integral and quadrature integrand containers.

Concrete subtypes wrap scalar, array-valued, or batched integrands. Out-of-place integrands return the integrand value, while in-place integrands write into an output container supplied by the algorithm. In-place integrands must carry an integrand_prototype so solvers can allocate correctly typed temporary storage; batched integrands reserve their last array dimension for the batch axis.

source
SciMLBase.AbstractOptimizationFunction — Type
abstract type AbstractOptimizationFunction{iip} <: SciMLBase.AbstractSciMLFunction{iip}

Base interface for optimization objective containers.

Concrete subtypes wrap scalar or multi-objective cost functions together with optional derivatives, Hessian-vector products, constraint callbacks, sparsity prototypes, coloring metadata, observed quantities, and symbolic systems. The iip parameter records whether auxiliary derivative/constraint callbacks mutate their first argument, while the objective itself follows the documented OptimizationFunction call convention.

source
SciMLBase.AbstractODEInputFunction — Type
abstract type AbstractODEInputFunction{iip} <: SciMLBase.AbstractDiffEqFunction{iip}

Interface for ODE right-hand sides with an explicit input/control argument.

Concrete subtypes represent systems such as dx/dt = f(x, u, p, t), where x is the state and u is an external input or control. In-place functions use f(dx, x, u, p, t) and out-of-place functions use f(x, u, p, t). Optional jac callbacks differentiate with respect to x, while controljac callbacks differentiate with respect to the input/control argument. Other derivative, prototype, sparsity, symbolic, and initialization fields follow the ODE-function conventions.

source
SciMLBase.AbstractBVPFunction — Type
abstract type AbstractBVPFunction{iip, twopoint} <: SciMLBase.AbstractDiffEqFunction{iip}

Interface for boundary-value problem function containers.

Concrete subtypes combine a differential equation callback with boundary condition residuals. The iip parameter records the in-place convention for the dynamic function, and the twopoint parameter records whether the boundary conditions are supplied as separate left/right endpoint callbacks. Boundary condition callbacks and their Jacobians must use a convention compatible with the stored prototypes. Concrete wrappers should document the signatures for f, bc, bcjac, optional least-squares/cost callbacks, boundary residual prototypes, and coloring metadata.

source
SciMLBase.AbstractParameterizedFunction — Type
abstract type AbstractParameterizedFunction{iip} <: SciMLBase.AbstractODEFunction{iip}

Compatibility supertype for ODE-like function containers that carry explicit parameterization metadata. New implementations should generally subtype a more specific AbstractODEFunction wrapper and expose symbolic or parameter metadata through public fields and SymbolicIndexingInterface methods.

source
SciMLBase.AbstractHistoryFunction — Type
abstract type AbstractHistoryFunction

Base interface for objects that provide delay-equation history values.

History functions are queried for state values before the initial time and for delayed arguments during DDE/SDDE solves. Implementations should support the call signatures required by the corresponding problem type, commonly h(p, t) or h(out, p, t), optional derivative queries such as h(p, t, Val{i}), and indexing keywords accepted by delay solvers. Returned values must match the state shape expected by the problem's function.

source

Concrete SciML Function Reference

Concrete function wrappers and their family-specific callback contracts are grouped in the following reference pages:

Automatic Differentiation Markers

SciMLBase.NoAD — Type
struct NoAD <: ADTypes.AbstractADType

An ADTypes.AbstractADType marker indicating that no automatic differentiation backend has been selected. It is the default adtype of an OptimizationFunction constructed without specifying a backend, signaling that derivatives must be supplied manually or chosen by the solver rather than generated via automatic differentiation.

source

Function Wrappers

SciMLBase.TimeDerivativeWrapper — Type
mutable struct TimeDerivativeWrapper{iip, F, uType, P} <: SciMLBase.AbstractWrappedFunction{iip}

Fix state and parameters while exposing time as the differentiated variable.

TimeDerivativeWrapper(f, u, p) is the fixed-state, fixed-parameter view used by derivative code that expects a function of t alone. For out-of-place functions it calls f(u, p, t). For in-place functions, wrapper(out, t) calls f(out, u, p, t), while wrapper(t) allocates similar(u) and returns the filled value.

Fields

  • f::Any

  • u::Any

  • p::Any

source
SciMLBase.TimeGradientWrapper — Type
mutable struct TimeGradientWrapper{iip, fType, uType, P} <: SciMLBase.AbstractWrappedFunction{iip}

Expose time as the only free argument of an ODE-style model function.

TimeGradientWrapper(f, uprev, p) fixes the state and parameters of f and returns a callable object over t. For out-of-place functions it calls f(uprev, p, t). For in-place functions, wrapper(out, t) calls f(out, uprev, p, t), while wrapper(t) allocates similar(uprev) and returns the filled value. This form is used when AD code needs a one-argument function for the time gradient.

Fields

  • f::Any

  • uprev::Any

  • p::Any

source
SciMLBase.UDerivativeWrapper — Type
mutable struct UDerivativeWrapper{iip, F, tType, P} <: SciMLBase.AbstractWrappedFunction{iip}

Fix time and parameters while exposing the state as the differentiated variable.

UDerivativeWrapper(f, t, p) is the fixed-time, fixed-parameter view used by derivative code that expects a function of u alone. For out-of-place functions it calls f(u, p, t). For in-place functions, wrapper(out, u) calls f(out, u, p, t), while wrapper(u) allocates similar(u) and returns the filled value.

Fields

  • f::Any

  • t::Any

  • p::Any

source
SciMLBase.UJacobianWrapper — Type
mutable struct UJacobianWrapper{iip, fType, tType, P} <: SciMLBase.AbstractWrappedFunction{iip}

Expose the state as the free argument of an ODE-style model function.

UJacobianWrapper(f, t, p) fixes time and parameters and returns a callable object over u. For out-of-place functions it calls f(u, p, t). For in-place functions, wrapper(out, u) calls f(out, u, p, t), while wrapper(u) allocates similar(u) and returns the filled value.

The overloads wrapper(u, p, t) and wrapper(out, u, p, t) let callers reuse the same wrapper while overriding the closed-over parameters and time.

Fields

  • f::Any

  • t::Any

  • p::Any

source
SciMLBase.ParamJacobianWrapper — Type
ParamJacobianWrapper(f, t, u)
ParamJacobianWrapper{iip}(f, t, u)

Wrap an ODE-style function as a function of parameters alone.

Arguments

  • f: An in-place f(du, u, p, t) or out-of-place f(u, p, t) model function.
  • t: The fixed independent-variable value.
  • u: The fixed state value.
  • iip: Whether f follows the in-place convention. The unparameterized constructor infers it from f.

Fields

  • f: The wrapped model function.
  • t: The fixed independent-variable value.
  • u: The fixed state value.

Type Parameters

  • iip: Whether the wrapped function is in-place.
  • fType: Type of the wrapped function.
  • tType: Type of the fixed independent-variable value.
  • uType: Type of the fixed state value.

Usage

pf = ParamJacobianWrapper((u, p, t) -> p .* u, 0.0, [2.0])
pf([3.0]) # [6.0]

Developer Interface

Sensitivity and solver packages use this wrapper when differentiating a model with respect to p. Call pf(p) to allocate an output or pf(out, p) to fill a provided output buffer. The fixed u and t values must be valid inputs for f; downstream code must use the callable interface rather than depending on the mutable field layout.

source
SciMLBase.Void — Type
Void(f)

Wrap f so every call returns nothing after evaluating f.

Arguments

  • f: A callable whose side effects should be preserved while its return value is discarded.

Returns

A callable wrapper with the same positional arguments as f that always returns nothing.

Usage

values = Int[]
push_nothing = Void(x -> push!(values, x))
push_nothing(1) # nothing

Developer Interface

Use this wrapper when an in-place SciML callback must have nothing return semantics, including AD integration code that distinguishes mutation from an out-of-place return. f is still evaluated exactly once. Do not use Void to hide exceptions or to change the calling convention of f.

source