Internal Abstract Types

The interfaces on this page are versioned developer APIs for BoundaryValueDiffEq solver implementations. They are not end-user extension points: applications should use a documented concrete solver algorithm instead of depending on these names.

Solvers

BoundaryValueDiffEqCore.AbstractBoundaryValueDiffEqAlgorithmType
AbstractBoundaryValueDiffEqAlgorithm

Developer-facing abstract type for boundary value problem algorithms.

Packages that implement a BoundaryValueDiffEq solver subtype this type and implement the SciML solve interface for that algorithm. This is a versioned developer interface for solver packages, not an end-user extension point. Solver users should select a concrete algorithm such as MIRK4() or Shooting() rather than subtype this interface.

Interface

For every concrete subtype Alg, define:

SciMLBase.__init(prob::SciMLBase.AbstractBVProblem, alg::Alg, args...; kwargs...)

The method must return a concrete AbstractBoundaryValueDiffEqCache whose prob field is the supplied problem. It must accept and interpret the positional and keyword arguments that the solver package supports. The matching cache type must implement SciMLBase.solve!(cache). SciMLBase.solve(prob, alg, args...; kwargs...) dispatches through these two methods in order; solve! returns the solver result. Do not add methods for algorithms owned by another package.

Examples

using BoundaryValueDiffEqCore, SciMLBase

struct MyBVPAlgorithm <: AbstractBoundaryValueDiffEqAlgorithm end
struct MyBVPCache{P} <: AbstractBoundaryValueDiffEqCache
    prob::P
end

SciMLBase.__init(prob::SciMLBase.AbstractBVProblem, ::MyBVPAlgorithm; kwargs...) =
    MyBVPCache(prob)
SciMLBase.solve!(cache::MyBVPCache) = cache.prob

SciMLBase.solve(prob, MyBVPAlgorithm()) # calls __init, then solve!

See the concrete solver packages in this repository for complete implementations.

source

Core Internal Interfaces

BoundaryValueDiffEqCore.AbstractBoundaryValueDiffEqCacheType
AbstractBoundaryValueDiffEqCache

Developer-facing abstract type for BoundaryValueDiffEq solver caches.

A solver package's SciMLBase.__init implementation returns a concrete subtype of this type. This is a versioned developer interface for solver implementations, not an end-user extension point.

Interface

  • Every cache must store the exact problem supplied to SciMLBase.__init in a field named prob. The default SciMLBase.isinplace(cache) delegates to that field.
  • Every cache must implement SciMLBase.solve!(cache) and return the solver result expected by its algorithm.
  • Define Base.eltype(cache) when the solver's implementation requires an element type.

The cache and its solve! method must be owned by the package that owns the corresponding algorithm subtype. Do not extend another solver package's cache type.

Examples

using BoundaryValueDiffEqCore, SciMLBase

struct MyBVPCache{P} <: AbstractBoundaryValueDiffEqCache
    prob::P
end

SciMLBase.solve!(cache::MyBVPCache) = cache.prob
source
BoundaryValueDiffEqCore.AbstractErrorControlType
AbstractErrorControl

Developer-facing abstract type for error-controller tags used by BoundaryValueDiffEq solver implementations.

This is a narrow versioned interface for solver packages. Subtypes classify how a solver's own adaptivity implementation manages error estimates; subtyping this type alone does not make a controller usable by MIRK, FIRK, or another concrete solver.

Extension Rules

A solver package that owns both an error controller and the corresponding adaptivity behavior may subtype AbstractErrorControl. It may extend __use_both_error_control for that subtype to declare whether its cache requires separate defect and global-error storage. The method must return a Bool, be side-effect free, and be defined only for the extending package's controller type. The default is false.

The concrete solver package remains responsible for implementing all controller-specific error estimation and mesh-selection behavior. Applications should use the documented concrete controllers rather than subtype this type.

Examples

struct MyCombinedControl <: AbstractErrorControl end

BoundaryValueDiffEqCore.__use_both_error_control(::MyCombinedControl) = true
source
BoundaryValueDiffEqCore.__FastShortcutNonlinearPolyalgFunction
__FastShortcutNonlinearPolyalg(T = Float64; concrete_jac = nothing, linsolve = nothing,
    autodiff = nothing)

Build the default nonlinear solver polyalgorithm used when a BVP algorithm does not supply an explicit nonlinear solver.

source
BoundaryValueDiffEqCore.__add_singular_term!Function
__add_singular_term!(K, singular_term, y, t)

Helper function to add the singular term contribution S * y / t to K for t > 0. Used in collocation residual computation for singular BVPs of the form y' = S*y/t + f(t,y).

source
BoundaryValueDiffEqCore.__build_costFunction
__build_cost(fun, cache, mesh, M; tune_parameters = false, p = nothing)

Build the objective function used by optimization-based BVP solves from a user supplied cost functional.

source
BoundaryValueDiffEqCore.__build_solutionFunction
__build_solution(prob, odesol, nonlinear_or_optimization_solution)

Combine the interpolating ODE-style solution with the internal nonlinear or optimization solver result and propagate the appropriate retcode.

source
BoundaryValueDiffEqCore.__concrete_kwargsFunction
__concrete_kwargs(nlsolve, optimize, nlsolve_kwargs, optimize_kwargs[, bvp_verbose])

Select and normalize the keyword arguments forwarded to the active internal nonlinear or optimization solver.

source
BoundaryValueDiffEqCore.__concrete_solve_algorithmFunction
__concrete_solve_algorithm(prob, nlsolve_alg, optimize_alg)

Automatic solver choosing according to the input solver. If none of the solvers are specified, we use nonlinear solvers from NonlinearSolve.jl. If both of the nonlinear solver and optimization solver are specified, we throw an error. If only one of the nonlinear solver and optimization solver is specified, we use that solver.

source
BoundaryValueDiffEqCore.__construct_internal_problemFunction
__construct_internal_problem

Constructs the internal problem according to the specified boundary value problem and the selected algorithm. Depending on the formulation, it returns either a NonlinearProblem or an OptimizationProblem.

source
BoundaryValueDiffEqCore.__flatten_initial_guessFunction
__flatten_initial_guess(u₀) -> Union{AbstractMatrix, AbstractVector, Nothing}

Flattens the initial guess into a matrix. For a function u₀, it returns nothing. For no initial guess, it returns vec(u₀).

source
BoundaryValueDiffEqCore.__maybe_matmul!Function
__maybe_matmul!(z, A, b, alpha = one(eltype(z)), beta = zero(eltype(z)))

Compute z = alpha * A * b + beta * z, using a fallback loop for array types where mul! is not appropriate.

source
BoundaryValueDiffEqCore.__resize!Function
__resize!(x, n, M)

Resizes the input x to length n and returns the resized array. If n is less than the length of x, it truncates the array. If n is greater than the length of x, it appends zeros to the array.

Note

We use last since the first might not conform to the same structure. For example, in the case of residuals

source
BoundaryValueDiffEqCore.__split_kwargsFunction
__split_kwargs(; abstol, adaptive, controller, verbose = DEFAULT_VERBOSE, kwargs...)

Split BVP solve keywords into cache fields and the keyword set forwarded to internal solvers.

source
BoundaryValueDiffEqCore.__use_both_error_controlFunction
__use_both_error_control(controller) -> Bool

Return whether an error controller requires separate defect and global-error storage.

This developer hook is used while a solver cache is constructed. The default implementation returns false. Solver packages may extend it only for their own AbstractErrorControl subtype, return a concrete Bool, and perform no mutation. A true result reserves storage for both estimates; it does not by itself add support for a custom controller to a concrete solver.

Examples

struct MyCombinedControl <: AbstractErrorControl end

BoundaryValueDiffEqCore.__use_both_error_control(::MyCombinedControl) = true
source
BoundaryValueDiffEqCore.__vec_so_bcFunction
__vec_so_bc(dsol, sol, p, t, bc, u_size)

Call an out-of-place second-order boundary condition on reshaped derivative and state storage and vectorize the result.

source
BoundaryValueDiffEqCore.concrete_jacobian_algorithmFunction
concrete_jacobian_algorithm(jac_alg, prob, alg)
concrete_jacobian_algorithm(jac_alg, problem_type, prob, alg)

If user provided all the required fields, then return the user provided algorithm. Otherwise, based on the problem type and the algorithm, decide the missing fields.

For example, for TwoPointBVProblem, the bc_diffmode is set to AutoSparse(AutoForwardDiff()) while for StandardBVProblem, the bc_diffmode is set to AutoForwardDiff().

source
BoundaryValueDiffEqCore.eval_bc_residual!Function
eval_bc_residual!(resid, problem_type, bc!, sol, p, t)

Evaluate an in-place boundary condition residual into resid for standard, two-point, and second-order boundary value problem forms.

source