Create ODE Stepper

Usage

make_stepper(category, algorithm, abs_tol = 1e-06, rel_tol = 1e-06, has_jacobian = NA)
stepper_categories()
stepper_algorithms(category, has_jacobian = FALSE)

Arguments

category
Broad stepper strategy: "basic", "controlled" or "dense" (see details below)
algorithm
The stepper algorithm (e.g. "runge_kutta_dopri5" or "rosenbrock4"). Possible values are returned by stepper_algorithms and are described in the details below.
abs_tol
Absolute tolerance, used in the adaptive step size. See the odeint documentation for interpretation, but bigger numbers allow bigger steps at the cost of lower absolute accuracy.
rel_tol
As for abs_tol, but for relative tolerance.
has_jacobian
Logical, indicating on whether the stepper should use the internal data structures required by the stiff systems. This is likely to disappear soon, as it depends entirely on the system itself. The default, NA, will switch based on the algorithm argument -- rosenbrock4 is the stiff system stepper, and on the ode system itself. To use other steppers with the stiff system, we need to set up normal steppers similarly. At runtime we rebuild steppers if they are specfied incorrectly, so this argument will disappear soon.

Create ODE Stepper

Description

These functions, and the class stepper create a "stepper" object for solving a system of ordinary differential equations created with ode_system. They cannot yet be used for directly manually stepping a system of ODEs, but essentially act as placeholders collecting information about algorithms.

Details

There are three "categories" of stepper. These are the broadest class of distinctions between approaches

  • basic: step with a fixed step size
  • controlled: step with a step size that is tuned based on errors reported by the stepper
  • dense: as for controlled, but it can make use of "dense output" to interpolate points between steps where needed.

These correspond to the concepts "Stepper", "Controlled Stepper", and "Dense Output Stepper" in the odeint documentation.

Within steppers there are "algorithms" - these are the mathematical rules used to advance the system. Almost all the algorithms in odeint are supported by rodeint. There are many possible algorithms!

The function stepper_algorithms return vectors of valid algorithms for a given category.

The runge_kutta_dopri5 stepper is described by odint as possibly "the best default stepper", so probably start with that and see the odeint documentation for when the other types might be more appropriate. If your system has a Jacobian associated with it, you can also use the rosenbrock4 algorithm (for any of the three categories).

Steppers in the "controlled" and "dense" categories adjust their step size according the detected error, in an effort to take as big a step as possible while keeping the error to within some specified bounds. The precise that this affects the stepper depends on the algorithm, and is described in the odeint documentation. The parameter abs_tol changes the tolerance for absolute error while abs_tol changes the tolerance for relative error. For the Runge Kutta steppers the interpretation is similar to deSolve, though I believe not identical.

Some algorithms in odeint are not supported yet:

  • Any of the multistep steppers (adams_bashforth, adams_moulton, adams_bashforth_moulton) because these require explicit initialisation from another stepper and so represent an interface challenge. However, they are apparently good for expensive functions, so might end up in the package soon.
  • Any of the "symplectic" steppers (symplectic_euler, symplectic_rkn_sb3a_mclachlan, symplectic_rkn_sb3a_m4_mclachlan) because I've never done any work with Hamiltonian systems. If these are implemented they will get a new category.
  • The velocity_verlet stepper for second order systems.
  • The implicit_euler stepper for stiff systems.

Examples

## The three stepper categories are: stepper_categories()
[1] "basic" "controlled" "dense"
## To return valid algorithms, use stepper_algorithms(category): stepper_algorithms("controlled")
[1] "runge_kutta_cash_karp54" "runge_kutta_fehlberg78" [3] "runge_kutta_dopri5" "bulirsch_stoer"
## If you add has_jacobian=TRUE to this call you'll get the ## "rosenbrock4" stepper added to the list stepper_algorithms("controlled", has_jacobian=TRUE)
[1] "runge_kutta_cash_karp54" "runge_kutta_fehlberg78" [3] "runge_kutta_dopri5" "bulirsch_stoer" [5] "rosenbrock4"
## To build a stepper use the "make_stepper" function: s <- make_stepper("controlled", "runge_kutta_dopri5") print(s)
A stepper for solving ordinary differential equations This object has no useful methods Pass this stepper to functions in ?rodeint_integrate Details: category: controlled algorithm: runge_kutta_dopri5 abs_tol: 1e-06 rel_tol: 1e-06
## The tolerances can be adjusted by passing in optional arguments ## "abs_tol" and "rel_tol" s <- make_stepper("controlled", "runge_kutta_dopri5", abs_tol=1e-4, rel_tol=1e-8) print(s)
A stepper for solving ordinary differential equations This object has no useful methods Pass this stepper to functions in ?rodeint_integrate Details: category: controlled algorithm: runge_kutta_dopri5 abs_tol: 1e-04 rel_tol: 1e-08

See also

integrate_const, which uses these steppers to solve systems of ODEs created by link{ode_system}.