Celeritas
0.5.0-56+6b053cd
|
Integrate the field ODEs using the 4th order classical Runge-Kutta method. More...
#include <RungeKuttaStepper.hh>
Public Types | |
Type aliases | |
using | result_type = FieldStepperResult |
Public Member Functions | |
CELER_FUNCTION | RungeKuttaStepper (EquationT &&eq) |
Construct with the equation of motion. | |
CELER_FUNCTION result_type | operator() (real_type step, OdeState const &beg_state) const |
Numerically integrate and return the updated state with estimated error. | |
Integrate the field ODEs using the 4th order classical Runge-Kutta method.
This method estimates the updated state from an initial state and evaluates the truncation error, with fourth-order accuracy based on description in Numerical Recipes in C, The Art of Scientific Computing, Sec. 16.2, Adaptive Stepsize Control for Runge-Kutta.
For a magnetic field equation f along a charged particle trajectory with state y, which includes position and momentum but may also include time and spin. For N-variables (i = 1, ... N), the right hand side of the equation
\[ \difd{y_{i}}{s} = f_i (s, y_{i}) \]
and the fouth order Runge-Kutta solution for a given step size, h is
\[ y_{n+1} - y_{n} = h f(x_n, y_n) = \frac{h}{6} (k_1 + 2 k_2 + 2 k_3 + k_4) \]
which is the average slope at four different points, The truncation error is the difference of the final states of one full step (y1) and two half steps (y2)
\[ \Delta = y_2 - y_1, y(x+h) = y_2 + \frac{\Delta}{15} + \mathrm{O}(h^{6}) \]