Skip to contents

Linearly implicit Rosenbrock methods for stiff problems and for differential algebraic equations in mass matrix form (index 1, singular mass matrices as produced by mtkcompile()), as in OrdinaryDiffEq.jl. Rosenbrock23() is the order 2(3) W-method of MATLAB's ode23s and Rosenbrock32() its order 3(2) counterpart, both with Shampine's interpolant; Rodas3(), Rodas3d() and ROS3P() are third order, Rodas3P() and the W-method Rodas23W() third order with a stiff aware interpolant, Rodas4(), Rodas42(), Rodas4P(), Rodas4P2() and the W-method Rodas4PW() fourth order, Rodas5(), Rodas5P(), Rodas5Pe() (another embedded method) and Rodas5Pr() (with a residual test of the interpolant) fifth order and Rodas6P() sixth order stiffly accurate methods with their stiff aware dense output. Each step uses the Jacobian prob$f$jac when present and differentiation otherwise, and prob$f$tgrad for non autonomous problems when present. The W-methods keep the Jacobian along accepted steps until it is max_jac_age steps old or the step size changes by more than jac_reuse_gamma_tol. After an accepted step Rosenbrock32() evaluates the derivative at the new solution for the next step; OrdinaryDiffEq.jl reuses the derivative at the second order point there, which costs one evaluation less per step.

Usage

Rosenbrock23(
  autodiff = NULL,
  concrete_jac = NULL,
  linsolve = NULL,
  step_limiter = NULL,
  stage_limiter = NULL,
  max_jac_age = 1L,
  jac_reuse_gamma_tol = 0.03
)

Rosenbrock32(
  autodiff = NULL,
  concrete_jac = NULL,
  linsolve = NULL,
  step_limiter = NULL,
  stage_limiter = NULL,
  max_jac_age = 1L,
  jac_reuse_gamma_tol = 0.03
)

ROS3P(
  autodiff = NULL,
  concrete_jac = NULL,
  linsolve = NULL,
  step_limiter = NULL,
  stage_limiter = NULL,
  max_jac_age = 20L,
  jac_reuse_gamma_tol = 0.03
)

Rodas3(
  autodiff = NULL,
  concrete_jac = NULL,
  linsolve = NULL,
  step_limiter = NULL,
  stage_limiter = NULL,
  max_jac_age = 20L,
  jac_reuse_gamma_tol = 0.03
)

Rodas3d(
  autodiff = NULL,
  concrete_jac = NULL,
  linsolve = NULL,
  step_limiter = NULL,
  stage_limiter = NULL,
  max_jac_age = 20L,
  jac_reuse_gamma_tol = 0.03
)

Rodas23W(
  autodiff = NULL,
  concrete_jac = NULL,
  linsolve = NULL,
  step_limiter = NULL,
  stage_limiter = NULL,
  max_jac_age = 20L,
  jac_reuse_gamma_tol = 0.03
)

Rodas3P(
  autodiff = NULL,
  concrete_jac = NULL,
  linsolve = NULL,
  step_limiter = NULL,
  stage_limiter = NULL,
  max_jac_age = 20L,
  jac_reuse_gamma_tol = 0.03
)

Rodas4(
  autodiff = NULL,
  concrete_jac = NULL,
  linsolve = NULL,
  step_limiter = NULL,
  stage_limiter = NULL,
  max_jac_age = 20L,
  jac_reuse_gamma_tol = 0.03
)

Rodas42(
  autodiff = NULL,
  concrete_jac = NULL,
  linsolve = NULL,
  step_limiter = NULL,
  stage_limiter = NULL,
  max_jac_age = 20L,
  jac_reuse_gamma_tol = 0.03
)

Rodas4P(
  autodiff = NULL,
  concrete_jac = NULL,
  linsolve = NULL,
  step_limiter = NULL,
  stage_limiter = NULL,
  max_jac_age = 20L,
  jac_reuse_gamma_tol = 0.03
)

Rodas4P2(
  autodiff = NULL,
  concrete_jac = NULL,
  linsolve = NULL,
  step_limiter = NULL,
  stage_limiter = NULL,
  max_jac_age = 20L,
  jac_reuse_gamma_tol = 0.03
)

Rodas4PW(
  autodiff = NULL,
  concrete_jac = NULL,
  linsolve = NULL,
  step_limiter = NULL,
  stage_limiter = NULL,
  max_jac_age = 20L,
  jac_reuse_gamma_tol = 0.03
)

Rodas5(
  autodiff = NULL,
  concrete_jac = NULL,
  linsolve = NULL,
  step_limiter = NULL,
  stage_limiter = NULL,
  max_jac_age = 20L,
  jac_reuse_gamma_tol = 0.03
)

Rodas5P(
  autodiff = NULL,
  concrete_jac = NULL,
  linsolve = NULL,
  step_limiter = NULL,
  stage_limiter = NULL,
  max_jac_age = 20L,
  jac_reuse_gamma_tol = 0.03
)

Rodas5Pe(
  autodiff = NULL,
  concrete_jac = NULL,
  linsolve = NULL,
  step_limiter = NULL,
  stage_limiter = NULL,
  max_jac_age = 20L,
  jac_reuse_gamma_tol = 0.03
)

Rodas5Pr(
  autodiff = NULL,
  concrete_jac = NULL,
  linsolve = NULL,
  step_limiter = NULL,
  stage_limiter = NULL,
  max_jac_age = 20L,
  jac_reuse_gamma_tol = 0.03
)

Rodas6P(
  autodiff = NULL,
  concrete_jac = NULL,
  linsolve = NULL,
  step_limiter = NULL,
  stage_limiter = NULL,
  max_jac_age = 20L,
  jac_reuse_gamma_tol = 0.03
)

Arguments

autodiff

How Jacobians are computed when the problem has no symbolic Jacobian: AutoForwardDiff() (dual numbers, as ForwardDiff; central differences when the function cannot run on them), AutoFiniteDiff(fdtype) or AutoSparse(ad); see AutoForwardDiff(). The default is AutoForwardDiff(), as in OrdinaryDiffEq.

concrete_jac, linsolve

Accepted for compatibility with OrdinaryDiffEq.jl; the linear systems are always solved densely.

step_limiter

A function limiter(u, integrator, p, t) returning the state after each accepted step, or NULL.

stage_limiter

Accepted for compatibility: as in OrdinaryDiffEq.jl, the out of place steps do not apply a stage limiter.

max_jac_age

Number of accepted steps after which a W-method evaluates the Jacobian again (1 for Rosenbrock23() and Rosenbrock32(), which then evaluate it at every step).

jac_reuse_gamma_tol

Relative change of dt * gamma above which a W-method evaluates the Jacobian again.

Value

An algorithm object.

Examples

vdp <- function(u, p, t) c(u[2], p * (1 - u[1]^2) * u[2] - u[1])
prob <- ODEProblem(vdp, c(2, 0), c(0, 1), p = 1000)
sol <- solve(prob, Rodas5P())
sol$retcode
#> [1] "Success"
solve(prob, Rosenbrock23())$stats$njacs
#> [1] 44