Skip to contents

DefaultODEAlgorithm() is what solve() uses when no algorithm is given, as in OrdinaryDiffEqDefault. With an identity mass matrix it starts with Tsit5() (Vern7() when reltol < 1e-6) and switches to a stiff method when stiffness is detected: Rosenbrock23() (Rodas5P() when reltol < 1e-6) up to 50 states and FBDF() above, switching back when the problem becomes nonstiff. With a non identity mass matrix it uses Rodas5P() up to 50 states and FBDF() above, without switching. sol$alg_choice records the method of every step (1 Tsit5, 2 Vern7, 3 Rosenbrock23, 4 Rodas5P, 5 FBDF).

Usage

DefaultODEAlgorithm(stiffalgfirst = FALSE)

DefaultImplicitODEAlgorithm(stol = 0, ntol = Inf)

Arguments

stiffalgfirst

Start with the stiff method.

stol, ntol

Stiffness thresholds while the stiff and the nonstiff method runs.

Value

A composite algorithm.

Details

DefaultImplicitODEAlgorithm() starts with the stiff method and compares the stiffness estimate with stol while stiff and ntol while nonstiff; with the defaults 0 and Inf it keeps the stiff method.

Examples

prob <- ODEProblem(function(u, p, t) -u, 1, c(0, 1))
sol <- solve(prob)
unique(sol$alg_choice)
#> [1] 1
sol <- solve(ODEProblem(function(u, p, t) -1000 * u, 1, c(0, 1)), DefaultImplicitODEAlgorithm())
unique(sol$alg_choice)
#> [1] 3