Description Usage Arguments Details See Also Examples
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.
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)
|
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
|
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 |
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
|
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.
integrate_const
, which uses these steppers to solve
systems of ODEs created by link{ode_system}
.
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)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.