...one of the most highly
regarded and expertly designed C++ library projects in the
world.
— Herb Sutter and Andrei
Alexandrescu, C++
Coding Standards
Home | Libraries | People | FAQ | More |
boost::numeric::odeint::symplectic_nystroem_stepper_base — Base class for all symplectic steppers of Nystroem type.
// In header: <boost/numeric/odeint/stepper/base/symplectic_rkn_stepper_base.hpp> template<size_t NumOfStages, unsigned short Order, typename Coor, typename Momentum, typename Value, typename CoorDeriv, typename MomentumDeriv, typename Time, typename Algebra, typename Operations, typename Resizer> class symplectic_nystroem_stepper_base : public boost::numeric::odeint::algebra_stepper_base< Algebra, Operations > { public: // types typedef algebra_stepper_base< Algebra, Operations > algebra_stepper_base_type; typedef algebra_stepper_base_type::algebra_type algebra_type; typedef algebra_stepper_base_type::operations_type operations_type; typedef Coor coor_type; typedef Momentum momentum_type; typedef std::pair< coor_type, momentum_type > state_type; typedef CoorDeriv coor_deriv_type; typedef state_wrapper< coor_deriv_type > wrapped_coor_deriv_type; typedef MomentumDeriv momentum_deriv_type; typedef state_wrapper< momentum_deriv_type > wrapped_momentum_deriv_type; typedef std::pair< coor_deriv_type, momentum_deriv_type > deriv_type; typedef Value value_type; typedef Time time_type; typedef Resizer resizer_type; typedef stepper_tag stepper_category; typedef unsigned short order_type; typedef boost::array< value_type, num_of_stages > coef_type; // construct/copy/destruct symplectic_nystroem_stepper_base(const coef_type &, const coef_type &, const algebra_type & = algebra_type()); // public member functions order_type order(void) const; template<typename System, typename StateInOut> void do_step(System, const StateInOut &, time_type, time_type); template<typename System, typename StateInOut> void do_step(System, StateInOut &, time_type, time_type); template<typename System, typename CoorInOut, typename MomentumInOut> void do_step(System, CoorInOut &, MomentumInOut &, time_type, time_type); template<typename System, typename CoorInOut, typename MomentumInOut> void do_step(System, const CoorInOut &, const MomentumInOut &, time_type, time_type); template<typename System, typename StateIn, typename StateOut> void do_step(System, const StateIn &, time_type, StateOut &, time_type); template<typename StateType> void adjust_size(const StateType &); const coef_type & coef_a(void) const; const coef_type & coef_b(void) const; algebra_type & algebra(); const algebra_type & algebra() const; // private member functions template<typename System, typename StateIn, typename StateOut> void do_step_impl(System, const StateIn &, time_type, StateOut &, time_type, boost::mpl::true_); template<typename System, typename StateIn, typename StateOut> void do_step_impl(System, const StateIn &, time_type, StateOut &, time_type, boost::mpl::false_); template<typename StateIn> bool resize_dqdt(const StateIn &); template<typename StateIn> bool resize_dpdt(const StateIn &); // public data members static const size_t num_of_stages; static const order_type order_value; };
This class is the base class for the symplectic Runge-Kutta-Nystroem steppers. Symplectic steppers are usually used to solve Hamiltonian systems and they conserve the phase space volume, see en.wikipedia.org/wiki/Symplectic_integrator. Furthermore, the energy is conserved in average. In detail this class of steppers can be used to solve separable Hamiltonian systems which can be written in the form H(q,p) = H1(p) + H2(q). q is usually called the coordinate, while p is the momentum. The equations of motion are dq/dt = dH1/dp, dp/dt = -dH2/dq.
ToDo : add formula for solver and explanation of the coefficients
symplectic_nystroem_stepper_base uses odeints algebra and operation system. Step size and error estimation are not provided for this class of solvers. It derives from algebra_stepper_base. Several `do_step` variants are provided:
`do_step( sys , x , t , dt )` - The classical `do_step` method. The sys can be either a pair of function objects for the coordinate or the momentum part or one function object for the momentum part. `x` is a pair of coordinate and momentum. The state is updated in-place.
`do_step( sys , q , p , t , dt )` - This method is similar to the method above with the difference that the coordinate and the momentum are passed explicitly and not packed into a pair.
`do_step( sys , x_in , t , x_out , dt )` - This method transforms the state out-of-place. `x_in` and `x_out` are here pairs of coordinate and momentum.
size_t NumOfStages
Number of stages.
unsigned short Order
The order of the stepper.
typename Coor
The type representing the coordinates q.
typename Momentum
The type representing the coordinates p.
typename Value
The basic value type. Should be something like float, double or a high-precision type.
typename CoorDeriv
The type representing the time derivative of the coordinate dq/dt.
typename MomentumDeriv
typename Time
The type representing the time t.
typename Algebra
The algebra.
typename Operations
The operations.
typename Resizer
The resizer policy.
symplectic_nystroem_stepper_base
public
construct/copy/destructsymplectic_nystroem_stepper_base(const coef_type & coef_a, const coef_type & coef_b, const algebra_type & algebra = algebra_type());Constructs a
symplectic_nystroem_stepper_base
class. The parameters of the specific Nystroem method and the algebra have to be passed.
Parameters: |
|
symplectic_nystroem_stepper_base
public member functionsorder_type order(void) const;
Returns: |
Returns the order of the stepper. |
template<typename System, typename StateInOut> void do_step(System system, const StateInOut & state, time_type t, time_type dt);This method performs one step. The system can be either a pair of two function object describing the momentum part and the coordinate part or one function object describing only the momentum part. In this case the coordinate is assumed to be trivial dq/dt = p. The state is updated in-place.
Note | |
---|---|
boost::ref or std::ref can be used for the system as well as for the state. So, it is correct to write `stepper.do_step( make_pair( std::ref( fq ) , std::ref( fp ) ) , make_pair( std::ref( q ) , std::ref( p ) ) , t , dt )`. This method solves the forwarding problem. |
Parameters: |
|
template<typename System, typename StateInOut> void do_step(System system, StateInOut & state, time_type t, time_type dt);Same function as above. It differs only in a different const specifier in order to solve the forwarding problem, can be used with Boost.Range.
template<typename System, typename CoorInOut, typename MomentumInOut> void do_step(System system, CoorInOut & q, MomentumInOut & p, time_type t, time_type dt);This method performs one step. The system can be either a pair of two function object describing the momentum part and the coordinate part or one function object describing only the momentum part. In this case the coordinate is assumed to be trivial dq/dt = p. The state is updated in-place.
Note | |
---|---|
boost::ref or std::ref can be used for the system. So, it is correct to write `stepper.do_step( make_pair( std::ref( fq ) , std::ref( fp ) ) , q , p , t , dt )`. This method solves the forwarding problem. |
Parameters: |
|
template<typename System, typename CoorInOut, typename MomentumInOut> void do_step(System system, const CoorInOut & q, const MomentumInOut & p, time_type t, time_type dt);Same function as do_step( system , q , p , t , dt ). It differs only in a different const specifier in order to solve the forwarding problem, can be called with Boost.Range.
template<typename System, typename StateIn, typename StateOut> void do_step(System system, const StateIn & in, time_type t, StateOut & out, time_type dt);This method performs one step. The system can be either a pair of two function object describing the momentum part and the coordinate part or one function object describing only the momentum part. In this case the coordinate is assumed to be trivial dq/dt = p. The state is updated out-of-place.
Note | |
---|---|
boost::ref or std::ref can be used for the system. So, it is correct to write `stepper.do_step( make_pair( std::ref( fq ) , std::ref( fp ) ) , x_in , t , x_out , dt )`. This method NOT solve the forwarding problem. |
Parameters: |
|
template<typename StateType> void adjust_size(const StateType & x);Adjust the size of all temporaries in the stepper manually.
Parameters: |
|
const coef_type & coef_a(void) const;Returns the coefficients a.
const coef_type & coef_b(void) const;Returns the coefficients b.
algebra_type & algebra();
Returns: |
A reference to the algebra which is held by this class. |
const algebra_type & algebra() const;
Returns: |
A const reference to the algebra which is held by this class. |
symplectic_nystroem_stepper_base
private member functionstemplate<typename System, typename StateIn, typename StateOut> void do_step_impl(System system, const StateIn & in, time_type t, StateOut & out, time_type dt, boost::mpl::true_);
template<typename System, typename StateIn, typename StateOut> void do_step_impl(System system, const StateIn & in, time_type, StateOut & out, time_type dt, boost::mpl::false_);
template<typename StateIn> bool resize_dqdt(const StateIn & x);
template<typename StateIn> bool resize_dpdt(const StateIn & x);