The SciML init and solve Functions
solve function has the default definition
solve(args...; kwargs...) = solve!(init(args...; kwargs...))The interface for the three functions is as follows:
init(::ProblemType, args...; kwargs...)::IteratorType
solve!(::IteratorType)::SolutionTypewhere ProblemType, IteratorType, and SolutionType are the types defined in your package.
To avoid method ambiguity, the first argument of solve, solve!, and initmust be dispatched on the type defined in your package. For example, do not define a method such as
init(::AbstractVector, ::AlgorithmType)init and the Iterator Interface
init's return gives an IteratorType which is designed to allow the user to have more direct handling over the internal solving process. Because of this internal nature, the IteratorType has a less unified interface across problem types than other portions like ProblemType and SolutionType. For example, for differential equations this is the Integrator Interface designed for mutating solutions in a manner for callback implementation, which is distinctly different from the LinearSolve init interface which is designed for caching efficiency with reusing factorizations.
__solve and High-Level Handling
While init and solve are the common entry point for users, solver packages will mostly define dispatches on SciMLBase.__init and SciMLBase.__solve. The reason is because this allows for SciMLBase.init and SciMLBase.solve to have common implementations across all solvers for doing things such as checking for common errors and throwing high level messages. Solvers can opt-out of the high level error handling by directly defining SciMLBase.init and SciMLBase.solve instead, though this is not recommended in order to allow for uniformity of the error messages.
Low-Level Integrator Interface
SciMLBase.DEIntegrator — Type
abstract type DEIntegrator{Alg, IIP, U, T}SciMLBase.AbstractODEIntegrator — Type
abstract type AbstractODEIntegrator{Alg, IIP, U, T} <: SciMLBase.DEIntegrator{Alg, IIP, U, T}SciMLBase.AbstractSDEIntegrator — Type
abstract type AbstractSDEIntegrator{Alg, IIP, U, T} <: SciMLBase.DEIntegrator{Alg, IIP, U, T}SciMLBase.AbstractRODEIntegrator — Type
abstract type AbstractRODEIntegrator{Alg, IIP, U, T} <: SciMLBase.DEIntegrator{Alg, IIP, U, T}SciMLBase.AbstractDDEIntegrator — Type
abstract type AbstractDDEIntegrator{Alg, IIP, U, T} <: SciMLBase.DEIntegrator{Alg, IIP, U, T}SciMLBase.AbstractDAEIntegrator — Type
abstract type AbstractDAEIntegrator{Alg, IIP, U, T} <: SciMLBase.DEIntegrator{Alg, IIP, U, T}SciMLBase.AbstractSDDEIntegrator — Type
abstract type AbstractSDDEIntegrator{Alg, IIP, U, T} <: SciMLBase.DEIntegrator{Alg, IIP, U, T}SciMLBase.DECache — Type
abstract type DECacheSciMLBase.check_error! — Function
check_error!(integrator)Same as check_error but also set solution's return code (integrator.sol.retcode) and run postamble!.
SciMLBase.initialize_dae! — Function
initialize_dae!(integrator::DEIntegrator,initializealg = integrator.initializealg)Runs the DAE initialization to find a consistent state vector. The optional argument initializealg can be used to specify a different initialization algorithm to use.
SciMLBase.has_reinit — Function
has_reinit(i::DEIntegrator)Return whether i supports reinitialization through reinit!.
Initialization Interface
SciMLBase.get_initial_values — Function
get_initial_values(prob, valp, f, alg, isinplace; kwargs...)Return the initial u0 and p for the given SciMLProblem and initialization algorithm, and a boolean indicating whether the initialization process was successful. Keyword arguments to this function are dependent on the initialization algorithm. prob is only required for dispatching. valp refers the appropriate data structure from which the current state and parameter values should be obtained. valp is a non-timeseries value provider as defined by SymbolicIndexingInterface.jl. f is the SciMLFunction for the problem. alg is the initialization algorithm to use. isinplace is either Val{true} if valp and the SciMLFunction are inplace, and Val{false} otherwise.
Argument Validation
SciMLBase.numargs — Function
numargs(f)
Returns the number of arguments of f for each method.
SciMLBase.FunctionArgumentsError — Type
FunctionArgumentsErrorException thrown when a model function's methods do not match the accepted SciML problem interface signatures.
SciMLBase.TooFewArgumentsError — Type
TooFewArgumentsErrorException thrown when a model function defines methods with fewer arguments than the SciML problem interface requires.
SciMLBase.TooManyArgumentsError — Type
TooManyArgumentsErrorException thrown when a model function defines methods with more arguments than the SciML problem interface accepts.