Skip to contents

IRKC() integrates a SplitODEProblem() du/dt = f1(u, p, t) + f2(u, p, t): each of its Chebyshev stages solves the stiff part f1 implicitly (modified Newton, with the Jacobian of f1: SplitFunction(f1, f2, jac = J1), else finite differences) and takes the mildly stiff part f2 explicitly. Second order, with an error estimate of first order and the integral controller (gamma = 0.8).

Usage

IRKC(eigen_est = NULL, autodiff = NULL)

Arguments

eigen_est

An upper bound on the spectral radius of the Jacobian of f2: a number or a function function(u, p, t). By default the nonlinear power iteration on f2 estimates it every step.

autodiff

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

Value

An ODE algorithm.

Details

As in OrdinaryDiffEq, the cache fixes the number of stages at 50 (its smallest and largest degree are both 50), so every step takes 50 stages whatever the spectral radius of f2; the radius, by the power iteration on f2 every step or from eigen_est, only enters the stage count formula. sol$stats$nf2 counts the evaluations of f2.

Examples

# a stiff linear decay (implicit) with a mild explicit forcing
prob <- SplitODEProblem(function(u, p, t) -50 * u, function(u, p, t) -u + cos(t),
                        c(1, 2), c(0, 1))
sol <- solve(prob, IRKC(), reltol = 1e-4, abstol = 1e-6)
sol$u[[length(sol$u)]]
#> [1] 0.01953307 0.02832475