Skip to contents

Fixed step second order implicit explicit two step methods for a SplitODEProblem() du/dt = f1(u, p, t) + f2(u, p, t): the first part f1 is treated implicitly by the Crank-Nicolson rule (Newton's method with the Jacobian of f1: SplitFunction(f1, f2, jac = J1), else finite differences), the second part f2 explicitly.

Usage

CNAB2(autodiff = NULL, extrapolant = "linear")

CNLF2(autodiff = NULL, extrapolant = "linear")

Arguments

autodiff

As for ImplicitEuler(): how the Jacobian of f1 is formed when none is given.

extrapolant

The initial guess of the Newton iteration; only "linear" (the default of OrdinaryDiffEq, which starts from dt * f1(u)) is used by these methods.

Value

An ODE algorithm.

Details

  • CNAB2(): Crank-Nicolson Adams-Bashforth (He and Li 2010).

  • CNLF2(): Crank-Nicolson leapfrog (Jiang, Kubacki, Layton, Moraiti and Tran 2015).

The first step, and the first step after an event that changes the state, use the one step startup formula. Give dt; the methods are not adaptive. As in OrdinaryDiffEq, f2 enters through the difference of the derivative f1 + f2 carried from the previous step and f1.

Examples

prob <- SplitODEProblem(function(u, p, t) -9 * u, function(u, p, t) -u, 1, c(0, 1))
sol <- solve(prob, CNAB2(), dt = 0.05)
sol$u[[length(sol$u)]]
#> [1] 4.247664e-05
solve(prob, CNLF2(), dt = 0.05)$u[[21]]
#> [1] 1.017739e-05