For ODE integration, we suggest using the boost libraries whenever possible.
More...
Detailed Description
For ODE integration, we suggest using the boost libraries whenever possible.
Details
Here we describe briefly the suggested setup to use a boost ODE integrator in SpECTRE. The boost utilities have a number of more elaborate features, including features that may result in simpler function calls than the specific recipes below. For full documentation, see the Boost odeint documentation: https://www.boost.org/doc/libs/1_72_0/libs/numeric/odeint/doc/html/boost_numeric_odeint/
The integration methods can be used largely as in the boost documentation. We summarize the salient points necessary to get an example running. The main steps in using a boost integrator are:
define the system
construct the stepper
initialize (might be performed implicitly, depending on the stepper)
perform steps
(compute dense output, for dense-output steppers)
For most cases the Dormand-Prince fifth order controlled, dense-output stepper is recommended. That stepper is used in the section "SpECTRE vectors
or `std::array` thereof in boost integrators" below.
Fundamental types or <tt>std::array</tt> thereof in fixed-step integrators
Let us consider a simple oscillator system, which we'll declare as a lambda:
Note that the first argument is a const lvalue reference to the state type, std::array<double, 2>, the second argument is an lvalue reference for the time derivatives that is written to by the system function, and the final argument is the current time.
The construction and initialization of the stepper is simple:
Fundamental types or <tt>std::array</tt> thereof in Dense-output integrators
The dense-output and controlled-step-size ODE integrators in boost comply with a somewhat different interface, as significantly more state information must be managed. The result is a somewhat simpler, but more opaque, interface to the user code.
Once again, we start by constructing the system we'd like to integrate,
It is important to take note of the tolerance arguments, as the defaults are 1.0e-6, which is often looser than we want for calculations in SpECTRE.
We then perform the step supplying the system function, and can retrieve the dense output state with calc_state, which returns by reference by the second argument.
SpECTRE vectors or <tt>std::array</tt> thereof in boost integrators
The additional template specializations present in the OdeIntegration.hpp file ensure that the boost ODE methods work transparently for SpECTRE vectors as well. We'll run through a brief example to emphasize the functionality.