Drift implicit methods of StochasticDiffEq.jl for stiff SDEs and for SDEs
with algebraic equations (a singular mass matrix, as mtkcompile() leaves
when an algebraic equation cannot be solved explicitly). ImplicitEM() is
the drift implicit Euler-Maruyama method (theta method; theta = 1/2 is
STrapezoid() and symplectic = TRUE the implicit midpoint rule
SImplicitMidpoint()), ImplicitEulerHeun() its Stratonovich
counterpart, and ImplicitRKMil() the drift implicit Runge-Kutta Milstein
method (strong order 1, diagonal or scalar noise). ISSEM() and
ISSEulerHeun() are the split step variants: the drift step is implicit
and the noise is added after it. SKenCarp() is the stochastic ESDIRK
method of Kennedy and Carpenter for additive noise (strong order 1.5,
order 2 for the drift). All adapt their step size (or take adaptive = FALSE and dt). As in StochasticDiffEq, mass matrices need theta = 1
or symplectic = TRUE; explicit methods do not accept them. The default
algorithm follows StochasticDiffEq's default_algorithm, with the
alg_hints option of solve() ("stiff", "stratonovich",
"commutative", "additive"): with a mass matrix or "stiff" it is
ImplicitRKMil() for diagonal noise, ISSEM() (or ImplicitEulerHeun()
for Stratonovich) for other noise and SKenCarp() for additive noise.
Events inside a step are located on the linear interpolant of the step,
as StochasticDiffEq does for every method.
Usage
ImplicitEM(
theta = 1,
symplectic = FALSE,
autodiff = NULL,
concrete_jac = NULL,
linsolve = NULL,
nlsolve = NLNewton(),
extrapolant = "constant",
new_jac_conv_bound = 0.001
)
STrapezoid(
autodiff = NULL,
concrete_jac = NULL,
linsolve = NULL,
nlsolve = NLNewton(),
extrapolant = "constant",
new_jac_conv_bound = 0.001
)
SImplicitMidpoint(
autodiff = NULL,
concrete_jac = NULL,
linsolve = NULL,
nlsolve = NLNewton(),
extrapolant = "constant",
new_jac_conv_bound = 0.001
)
ImplicitEulerHeun(
theta = 1,
symplectic = FALSE,
autodiff = NULL,
concrete_jac = NULL,
linsolve = NULL,
nlsolve = NLNewton(),
extrapolant = "constant",
new_jac_conv_bound = 0.001
)
SKenCarp(
autodiff = NULL,
concrete_jac = NULL,
linsolve = NULL,
nlsolve = NLNewton(),
smooth_est = TRUE,
extrapolant = "min_correct",
new_jac_conv_bound = 0.001,
ode_error_est = TRUE
)
ISSEM(
theta = 1,
symplectic = FALSE,
autodiff = NULL,
concrete_jac = NULL,
linsolve = NULL,
nlsolve = NLNewton(),
extrapolant = "constant",
new_jac_conv_bound = 0.001
)
ISSEulerHeun(
theta = 1,
symplectic = FALSE,
autodiff = NULL,
concrete_jac = NULL,
linsolve = NULL,
nlsolve = NLNewton(),
extrapolant = "constant",
new_jac_conv_bound = 0.001
)
ImplicitRKMil(
theta = 1,
symplectic = FALSE,
interpretation = c("Ito", "Stratonovich"),
autodiff = NULL,
concrete_jac = NULL,
linsolve = NULL,
nlsolve = NLNewton(),
extrapolant = "constant",
new_jac_conv_bound = 0.001
)Arguments
- theta
Implicitness of the drift.
- symplectic
Use the implicit midpoint rule.
- autodiff
The Jacobian backend of the Newton iteration (default
AutoForwardDiff()).- concrete_jac, linsolve, new_jac_conv_bound
Stored as upstream; the stage systems are solved densely.
- nlsolve
The nonlinear solver of the implicit stages:
NLNewton(),NLFunctional(),NLAnderson(),NonlinearSolveAlg()orHomotopyNonlinearSolveAlg().- extrapolant
The start of the stage solves;
SKenCarp()takes"min_correct"(from zero) or"trivial"(from the previous stage). The other methods start from the same guess for every value, as the out of place methods of StochasticDiffEq do.- smooth_est
Smooth the error estimate of
SKenCarp()withW.- ode_error_est
Use the embedded drift error estimate of
SKenCarp();FALSEtakes the sum of the stage increments.- interpretation
"Ito"or"Stratonovich"forImplicitRKMil().
Examples
f <- function(u, p, t) c(-u[1] + u[2], u[2] - 2 * u[1])
g <- function(u, p, t) c(0.1 * u[1], 0)
prob <- SDEProblem(SDEFunction(f, g, mass_matrix = diag(c(1, 0))), c(1, 2), c(0, 1))
sol <- solve(prob, ImplicitEM(), dt = 0.01, adaptive = FALSE, seed = 1)
tail(sol$u, 1)
#> [[1]]
#> [1] 2.923177 5.846353
#>