Jacobians, Gradients, etc.
The DiffEq 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 DiffEqFunction types which can be passed to the problems.
Built-In Jacobian Options
This subsection on Jacobian options only applies to the Julia-based solvers (OrdinaryDiffEq.jl, StochasticDiffEq.jl, etc.). Wrappers of traditional C/Fortran codes, such as Sundials.jl, always default to finite differencing using the in-solver code.
All applicable stiff differential equation solvers in the Julia ecosystem (OrdinaryDiffEq.jl, StochasticDiffEq.jl, DelayDiffEq.jl, etc.) take an autodiff keyword for handling automatic Jacobian construction. This takes an ADTypes object, which means every AD backend in the Julia ecosystem is supported through the same interface:
autodiff: Specifies the AD backend to use for Jacobian / gradient construction via the ADTypes.jl interface. Common choices includeAutoForwardDiff()(default),AutoFiniteDiff()(numerical fallback),AutoEnzyme(),AutoZygote(), andAutoMooncake().AutoForwardDiffandAutoFiniteDiffaccept their own tuning kwargs (e.g.AutoForwardDiff(chunksize=12), orAutoFiniteDiff(fdtype=Val(:central))), which replace the old per-solverchunk_size/diff_typekwargs.concrete_jac: Specifies whether a Jacobian should be constructed. Defaults tonothing, which means it will be chosen true/false depending on circumstances of the solver, such as whether a Krylov subspace method is used forlinsolve.
Passing Jacobian Function Definitions
If one wishes to define a Jacobian function directly for use in the solver, then the defined method is passed to the AbstractSciMLFunction type associated with the DEProblem. For example, ODEProblem definitions have a spot for jac in the ODEFunction specification. For more information on how to define Jacobians for the specific problems, see the appropriate problem type page, for example, the ODE problem page.