| Home | Libraries | People | FAQ | More

## Class template runge_kutta_dopri5

boost::numeric::odeint::runge_kutta_dopri5 — The Runge-Kutta Dormand-Prince 5 method.

## Synopsis

    // In header: <boost/numeric/odeint/stepper/runge_kutta_dopri5.hpp>

    template<typename State, typename Value = double, typename Deriv = State,
             typename Time = Value,
             typename Algebra = typename algebra_dispatcher< State >::algebra_type,
             typename Operations = typename operations_dispatcher< State >::operations_type,
             typename Resizer = initially_resizer>
    class runge_kutta_dopri5 : public explicit_error_stepper_fsal_base {
    public:
      // types
      typedef explicit_error_stepper_fsal_base< runge_kutta_dopri5< ... >,... > stepper_base_type;
      typedef stepper_base_type::state_type                                     state_type;
      typedef stepper_base_type::value_type                                     value_type;
      typedef stepper_base_type::deriv_type                                     deriv_type;
      typedef stepper_base_type::time_type                                      time_type;
      typedef stepper_base_type::algebra_type                                   algebra_type;
      typedef stepper_base_type::operations_type                                operations_type;
      typedef stepper_base_type::resizer_type                                   resizer_type;

      // public member functions
      runge_kutta_dopri5(const algebra_type & = algebra_type());
      template<typename System, typename StateIn, typename DerivIn,
               typename StateOut, typename DerivOut>
        void do_step_impl(System, const StateIn &, const DerivIn &, time_type,
                          StateOut &, DerivOut &, time_type);
      template<typename System, typename StateIn, typename DerivIn,
               typename StateOut, typename DerivOut, typename Err>
        void do_step_impl(System, const StateIn &, const DerivIn &, time_type,
                          StateOut &, DerivOut &, time_type, Err &);
      template<typename StateOut, typename StateIn1, typename DerivIn1,
               typename StateIn2, typename DerivIn2>
        void calc_state(time_type, StateOut &, const StateIn1 &, const DerivIn1 &,
                        time_type, const StateIn2 &, const DerivIn2 &, time_type) const;
      template<typename StateIn> void adjust_size(const StateIn &);

      // private member functions
      template<typename StateIn> bool resize_k_x_tmp_impl(const StateIn &);
      template<typename StateIn> bool resize_dxdt_tmp_impl(const StateIn &);
    };

## Description

The Runge-Kutta Dormand-Prince 5 method is a very popular method for solving ODEs, see . The method is explicit and fulfills the Error Stepper concept. Step size control is provided but continuous output is available which make this method favourable for many applications.

This class derives from explicit_error_stepper_fsal_base and inherits its interface via CRTP (current recurring template pattern). The method possesses the FSAL (first-same-as-last) property. See explicit_error_stepper_fsal_base for more details.

### Template Parameters

1.     typename State

   The state type.

2.     typename Value = double

   The value type.

3.     typename Deriv = State

   The type representing the time derivative of the state.

4.     typename Time = Value

   The time representing the independent variable - the time.

5.     typename Algebra = typename algebra_dispatcher< State >::algebra_type

   The algebra type.

6.     typename Operations = typename operations_dispatcher< State >::operations_type

   The operations type.

7.     typename Resizer = initially_resizer

   The resizer policy type.

### `runge_kutta_dopri5` public member functions

1.     runge_kutta_dopri5(const algebra_type & algebra = algebra_type());

   Constructs the runge_kutta_dopri5 class. This constructor can be used as a default constructor if the algebra has a default constructor.

   Parameters: |
   `algebra` | A copy of algebra is made and stored inside explicit_stepper_base.

2.     template<typename System, typename StateIn, typename DerivIn,
                typename StateOut, typename DerivOut>
         void do_step_impl(System system, const StateIn & in,
                           const DerivIn & dxdt_in, time_type t, StateOut & out,
                           DerivOut & dxdt_out, time_type dt);

   This method performs one step. The derivative `dxdt_in` of `in` at the time `t` is passed to the method. The result is updated out-of-place, hence the input is in `in` and the output in `out`. Furthermore, the derivative is update out-of-place, hence the input is assumed to be in `dxdt_in` and the output in `dxdt_out`. Access to this step functionality is provided by explicit_error_stepper_fsal_base and `do_step_impl` should not be called directly.

   Parameters: |
   `system` | The system function to solve, hence the r.h.s. of the ODE. It must fulfill the Simple System concept.
   `in` | The state of the ODE which should be solved. in is not modified in this method
   `dxdt_in` | The derivative of x at t. dxdt_in is not modified by this method
   `t` | The value of the time, at which the step should be performed.
   `out` | The result of the step is written in out.
   `dxdt_out` | The result of the new derivative at time t+dt.
   `dt` | The step size.

3.     template<typename System, typename StateIn, typename DerivIn,
                typename StateOut, typename DerivOut, typename Err>
         void do_step_impl(System system, const StateIn & in,
                           const DerivIn & dxdt_in, time_type t, StateOut & out,
                           DerivOut & dxdt_out, time_type dt, Err & xerr);

   This method performs one step. The derivative `dxdt_in` of `in` at the time `t` is passed to the method. The result is updated out-of-place, hence the input is in `in` and the output in `out`. Furthermore, the derivative is update out-of-place, hence the input is assumed to be in `dxdt_in` and the output in `dxdt_out`. Access to this step functionality is provided by explicit_error_stepper_fsal_base and `do_step_impl` should not be called directly. An estimation of the error is calculated.

   Parameters: |
   `system` | The system function to solve, hence the r.h.s. of the ODE. It must fulfill the Simple System concept.
   `in` | The state of the ODE which should be solved. in is not modified in this method
   `dxdt_in` | The derivative of x at t. dxdt_in is not modified by this method
   `t` | The value of the time, at which the step should be performed.
   `out` | The result of the step is written in out.
   `dxdt_out` | The result of the new derivative at time t+dt.
   `dt` | The step size.
   `xerr` | An estimation of the error.

4.     template<typename StateOut, typename StateIn1, typename DerivIn1,
                typename StateIn2, typename DerivIn2>
         void calc_state(time_type t, StateOut & x, const StateIn1 & x_old,
                         const DerivIn1 & deriv_old, time_type t_old,
                         const StateIn2 &, const DerivIn2 & deriv_new,
                         time_type t_new) const;

   This method is used for continuous output and it calculates the state `x` at a time `t` from the knowledge of two states `old_state` and `current_state` at time points `t_old` and `t_new`. It also uses internal variables to calculate the result. Hence this method must be called after two successful `do_step` calls.

5.     template<typename StateIn> void adjust_size(const StateIn & x);

   Adjust the size of all temporaries in the stepper manually.

   Parameters: |
   `x` | A state from which the size of the temporaries to be resized is deduced.

### `runge_kutta_dopri5` private member functions

1.     template<typename StateIn> bool resize_k_x_tmp_impl(const StateIn & x);

2.     template<typename StateIn> bool resize_dxdt_tmp_impl(const StateIn & x);