| Home | Libraries | People | FAQ | More

## Class template controlled_runge_kutta<ErrorStepper, ErrorChecker, StepAdjuster, Resizer, explicit_error_stepper_fsal_tag>

boost::numeric::odeint::controlled_runge_kutta<ErrorStepper, ErrorChecker, StepAdjuster, Resizer, explicit_error_stepper_fsal_tag> — Implements step size control for Runge-Kutta FSAL steppers with error estimation.

## Synopsis

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

    template<typename ErrorStepper, typename ErrorChecker, typename StepAdjuster,
             typename Resizer>
    class controlled_runge_kutta<ErrorStepper, ErrorChecker, StepAdjuster, Resizer, explicit_error_stepper_fsal_tag> {
    public:
      // types
      typedef ErrorStepper                         stepper_type;
      typedef stepper_type::state_type             state_type;
      typedef stepper_type::value_type             value_type;
      typedef stepper_type::deriv_type             deriv_type;
      typedef stepper_type::time_type              time_type;
      typedef stepper_type::algebra_type           algebra_type;
      typedef stepper_type::operations_type        operations_type;
      typedef Resizer                              resizer_type;
      typedef ErrorChecker                         error_checker_type;
      typedef StepAdjuster                         step_adjuster_type;
      typedef explicit_controlled_stepper_fsal_tag stepper_category;

      // public member functions
      controlled_runge_kutta(const error_checker_type & = error_checker_type(),
                             const step_adjuster_type & = step_adjuster_type(),
                             const stepper_type & = stepper_type());
      template<typename System, typename StateInOut>
        controlled_step_result
        try_step(System, StateInOut &, time_type &, time_type &);
      template<typename System, typename StateInOut>
        controlled_step_result
        try_step(System, const StateInOut &, time_type &, time_type &);
      template<typename System, typename StateIn, typename StateOut>
        boost::disable_if< boost::is_same< StateIn, time_type >, controlled_step_result >::type
        try_step(System, const StateIn &, time_type &, StateOut &, time_type &);
      template<typename System, typename StateInOut, typename DerivInOut>
        controlled_step_result
        try_step(System, StateInOut &, DerivInOut &, time_type &, time_type &);
      template<typename System, typename StateIn, typename DerivIn,
               typename StateOut, typename DerivOut>
        controlled_step_result
        try_step(System, const StateIn &, const DerivIn &, time_type &,
                 StateOut &, DerivOut &, time_type &);
      void reset(void);
      template<typename DerivIn> void initialize(const DerivIn &);
      template<typename System, typename StateIn>
        void initialize(System, const StateIn &, time_type);
      bool is_initialized(void) const;
      template<typename StateType> void adjust_size(const StateType &);
      stepper_type & stepper(void);
      const stepper_type & stepper(void) const;

      // private member functions
      template<typename StateIn> bool resize_m_xerr_impl(const StateIn &);
      template<typename StateIn> bool resize_m_dxdt_impl(const StateIn &);
      template<typename StateIn> bool resize_m_dxdt_new_impl(const StateIn &);
      template<typename StateIn> bool resize_m_xnew_impl(const StateIn &);
      template<typename System, typename StateInOut>
        controlled_step_result
        try_step_v1(System, StateInOut &, time_type &, time_type &);
    };

## Description

This class implements the step size control for FSAL Runge-Kutta steppers with error estimation.

### Template Parameters

1.     typename ErrorStepper

   The stepper type with error estimation, has to fulfill the ErrorStepper concept.

2.     typename ErrorChecker

   The error checker

3.     typename StepAdjuster

4.     typename Resizer

   The resizer policy type.

### `controlled_runge_kutta` public member functions

1.     controlled_runge_kutta(const error_checker_type & error_checker = error_checker_type(),
                              const step_adjuster_type & step_adjuster = step_adjuster_type(),
                              const stepper_type & stepper = stepper_type());

   Constructs the controlled Runge-Kutta stepper.

   Parameters:

   `error_checker` | An instance of the error checker.
   `stepper` | An instance of the underlying stepper.

2.     template<typename System, typename StateInOut>
         controlled_step_result
         try_step(System system, StateInOut & x, time_type & t, time_type & dt);

   Tries to perform one step.

   This method tries to do one step with step size dt. If the error estimate is to large, the step is rejected and the method returns fail and the step size dt is reduced. If the error estimate is acceptably small, the step is performed, success is returned and dt might be increased to make the steps as large as possible. This method also updates t if a step is performed.

   Parameters:

   `system` | The system function to solve, hence the r.h.s. of the ODE. It must fulfill the Simple System concept.
   `x` | The state of the ODE which should be solved. Overwritten if the step is successful.
   `t` | The value of the time. Updated if the step is successful.
   `dt` | The step size. Updated.

   Returns: | success if the step was accepted, fail otherwise.

3.     template<typename System, typename StateInOut>
         controlled_step_result
         try_step(System system, const StateInOut & x, time_type & t, time_type & dt);

   Tries to perform one step. Solves the forwarding problem and allows for using boost range as state_type.

   This method tries to do one step with step size dt. If the error estimate is to large, the step is rejected and the method returns fail and the step size dt is reduced. If the error estimate is acceptably small, the step is performed, success is returned and dt might be increased to make the steps as large as possible. This method also updates t if a step is performed.

   Parameters:

   `system` | The system function to solve, hence the r.h.s. of the ODE. It must fulfill the Simple System concept.
   `x` | The state of the ODE which should be solved. Overwritten if the step is successful. Can be a boost range.
   `t` | The value of the time. Updated if the step is successful.
   `dt` | The step size. Updated.

   Returns: | success if the step was accepted, fail otherwise.

4.     template<typename System, typename StateIn, typename StateOut>
         boost::disable_if< boost::is_same< StateIn, time_type >, controlled_step_result >::type
         try_step(System system, const StateIn & in, time_type & t, StateOut & out,
                  time_type & dt);

   Tries to perform one step.

   | Note
   This method is disabled if state_type=time_type to avoid ambiguity.

   This method tries to do one step with step size dt. If the error estimate is to large, the step is rejected and the method returns fail and the step size dt is reduced. If the error estimate is acceptably small, the step is performed, success is returned and dt might be increased to make the steps as large as possible. This method also updates t if a step is performed.

   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.
   `t` | The value of the time. Updated if the step is successful.
   `out` | Used to store the result of the step.
   `dt` | The step size. Updated.

   Returns: | success if the step was accepted, fail otherwise.

5.     template<typename System, typename StateInOut, typename DerivInOut>
         controlled_step_result
         try_step(System system, StateInOut & x, DerivInOut & dxdt, time_type & t,
                  time_type & dt);

   Tries to perform one step.

   This method tries to do one step with step size dt. If the error estimate is to large, the step is rejected and the method returns fail and the step size dt is reduced. If the error estimate is acceptably small, the step is performed, success is returned and dt might be increased to make the steps as large as possible. This method also updates t if a step is performed.

   Parameters:

   `system` | The system function to solve, hence the r.h.s. of the ODE. It must fulfill the Simple System concept.
   `x` | The state of the ODE which should be solved. Overwritten if the step is successful.
   `dxdt` | The derivative of state.
   `t` | The value of the time. Updated if the step is successful.
   `dt` | The step size. Updated.

   Returns: | success if the step was accepted, fail otherwise.

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

   Tries to perform one step.

   This method tries to do one step with step size dt. If the error estimate is to large, the step is rejected and the method returns fail and the step size dt is reduced. If the error estimate is acceptably small, the step is performed, success is returned and dt might be increased to make the steps as large as possible. This method also updates t if a step is performed.

   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.
   `t` | The value of the time. Updated if the step is successful.
   `out` | Used to store the result of the step.
   `dt` | The step size. Updated.

   Returns: | success if the step was accepted, fail otherwise.

7.     void reset(void);

   Resets the internal state of the underlying FSAL stepper.

8.     template<typename DerivIn> void initialize(const DerivIn & deriv);

   Initializes the internal state storing an internal copy of the derivative.

   Parameters:

   `deriv` | The initial derivative of the ODE.

9.     template<typename System, typename StateIn>
         void initialize(System system, const StateIn & x, time_type t);

   Initializes the internal state storing an internal copy of the derivative.

   Parameters:

   `system` | The system function to solve, hence the r.h.s. of the ODE. It must fulfill the Simple System concept.
   `x` | The initial state of the ODE which should be solved.
   `t` | The initial time.

10.     bool is_initialized(void) const;

    Returns true if the stepper has been initialized, false otherwise.

    Returns: | true, if the stepper has been initialized, false otherwise.

11.     template<typename StateType> void adjust_size(const StateType & 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.

12.     stepper_type & stepper(void);

    Returns the instance of the underlying stepper.

    Returns: | The instance of the underlying stepper.

13.     const stepper_type & stepper(void) const;

    Returns the instance of the underlying stepper.

    Returns: | The instance of the underlying stepper.

### `controlled_runge_kutta` private member functions

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

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

3.     template<typename StateIn> bool resize_m_dxdt_new_impl(const StateIn & x);

4.     template<typename StateIn> bool resize_m_xnew_impl(const StateIn & x);

5.     template<typename System, typename StateInOut>
         controlled_step_result
         try_step_v1(System system, StateInOut & x, time_type & t, time_type & dt);