stepper: Create ODE Stepper

Description Usage Arguments Details See Also Examples

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.

Usage

1
2
3
4
5
6
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.

Details

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

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:

See Also

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

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
## The three stepper categories are:
stepper_categories()

## To return valid algorithms, use stepper_algorithms(category):
stepper_algorithms("controlled")

## 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)

## To build a stepper use the "make_stepper" function:
s <- make_stepper("controlled", "runge_kutta_dopri5")
print(s)

## 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)

richfitz/rodeint documentation built on May 27, 2019, 8:42 a.m.