symplectic_rkn_sb3a_m4_mclachlan.hpp 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160
  1. /*
  2. [auto_generated]
  3. boost/numeric/odeint/stepper/symplectic_rkn_sb3a_m4_mclachlan.hpp
  4. [begin_description]
  5. tba.
  6. [end_description]
  7. Copyright 2012-2013 Karsten Ahnert
  8. Copyright 2012-2013 Mario Mulansky
  9. Distributed under the Boost Software License, Version 1.0.
  10. (See accompanying file LICENSE_1_0.txt or
  11. copy at http://www.boost.org/LICENSE_1_0.txt)
  12. */
  13. #ifndef BOOST_NUMERIC_ODEINT_STEPPER_SYMPLECTIC_RKN_SB3A_M4_MCLACHLAN_HPP_DEFINED
  14. #define BOOST_NUMERIC_ODEINT_STEPPER_SYMPLECTIC_RKN_SB3A_M4_MCLACHLAN_HPP_DEFINED
  15. #include <boost/numeric/odeint/algebra/default_operations.hpp>
  16. #include <boost/numeric/odeint/algebra/algebra_dispatcher.hpp>
  17. #include <boost/numeric/odeint/algebra/operations_dispatcher.hpp>
  18. #include <boost/numeric/odeint/util/resizer.hpp>
  19. namespace boost {
  20. namespace numeric {
  21. namespace odeint {
  22. #ifndef DOXYGEN_SKIP
  23. namespace detail {
  24. namespace symplectic_rkn_sb3a_m4_mclachlan {
  25. /*
  26. exp( a1 t A ) exp( b1 t B )
  27. exp( a2 t A ) exp( b2 t B )
  28. exp( a3 t A )
  29. exp( b2 t B ) exp( a2 t A )
  30. exp( b1 t B ) exp( a1 t A )
  31. */
  32. template< class Value >
  33. struct coef_a_type : public boost::array< Value , 5 >
  34. {
  35. coef_a_type( void )
  36. {
  37. using std::sqrt;
  38. Value z = sqrt( static_cast< Value >( 7 ) / static_cast< Value >( 8 ) ) / static_cast< Value >( 3 );
  39. (*this)[0] = static_cast< Value >( 1 ) / static_cast< Value >( 2 ) - z ;
  40. (*this)[1] = static_cast< Value >( -1 ) / static_cast< Value >( 3 ) + z ;
  41. (*this)[2] = static_cast< Value >( 2 ) / static_cast< Value >( 3 );
  42. (*this)[3] = (*this)[1];
  43. (*this)[4] = (*this)[0];
  44. }
  45. };
  46. template< class Value >
  47. struct coef_b_type : public boost::array< Value , 5 >
  48. {
  49. coef_b_type( void )
  50. {
  51. (*this)[0] = static_cast< Value >( 1 );
  52. (*this)[1] = static_cast< Value >( -1 ) / static_cast< Value >( 2 );
  53. (*this)[2] = (*this)[1];
  54. (*this)[3] = (*this)[0];
  55. (*this)[4] = static_cast< Value >( 0 );
  56. }
  57. };
  58. } // namespace symplectic_rkn_sb3a_m4_mclachlan
  59. } // namespace detail
  60. #endif // DOXYGEN_SKIP
  61. template<
  62. class Coor ,
  63. class Momentum = Coor ,
  64. class Value = double ,
  65. class CoorDeriv = Coor ,
  66. class MomentumDeriv = Coor ,
  67. class Time = Value ,
  68. class Algebra = typename algebra_dispatcher< Coor >::algebra_type ,
  69. class Operations = typename operations_dispatcher< Coor >::operations_type ,
  70. class Resizer = initially_resizer
  71. >
  72. #ifndef DOXYGEN_SKIP
  73. class symplectic_rkn_sb3a_m4_mclachlan :
  74. public symplectic_nystroem_stepper_base
  75. <
  76. 5 , 4 ,
  77. Coor , Momentum , Value , CoorDeriv , MomentumDeriv , Time , Algebra , Operations , Resizer
  78. >
  79. #else
  80. class symplectic_rkn_sb3a_m4_mclachlan : public symplectic_nystroem_stepper_base
  81. #endif
  82. {
  83. public:
  84. #ifndef DOXYGEN_SKIP
  85. typedef symplectic_nystroem_stepper_base
  86. <
  87. 5 , 4 ,
  88. Coor , Momentum , Value , CoorDeriv , MomentumDeriv , Time , Algebra , Operations , Resizer
  89. > stepper_base_type;
  90. #endif
  91. typedef typename stepper_base_type::algebra_type algebra_type;
  92. typedef typename stepper_base_type::value_type value_type;
  93. symplectic_rkn_sb3a_m4_mclachlan( const algebra_type &algebra = algebra_type() )
  94. : stepper_base_type(
  95. detail::symplectic_rkn_sb3a_m4_mclachlan::coef_a_type< value_type >() ,
  96. detail::symplectic_rkn_sb3a_m4_mclachlan::coef_b_type< value_type >() ,
  97. algebra )
  98. { }
  99. };
  100. /***************** DOXYGEN ***************/
  101. /**
  102. * \class symplectic_rkn_sb3a_m4_mclachlan
  103. * \brief Implementation of the symmetric B3A Runge-Kutta Nystroem method of fifth order.
  104. *
  105. * The method is of fourth order and has five stages. It is described HERE. This method can be used
  106. * with multiprecision types since the coefficients are defined analytically.
  107. *
  108. * ToDo: add reference to paper.
  109. *
  110. * \tparam Order The order of the stepper.
  111. * \tparam Coor The type representing the coordinates q.
  112. * \tparam Momentum The type representing the coordinates p.
  113. * \tparam Value The basic value type. Should be something like float, double or a high-precision type.
  114. * \tparam CoorDeriv The type representing the time derivative of the coordinate dq/dt.
  115. * \tparam MomemtnumDeriv The type representing the time derivative of the momentum dp/dt.
  116. * \tparam Time The type representing the time t.
  117. * \tparam Algebra The algebra.
  118. * \tparam Operations The operations.
  119. * \tparam Resizer The resizer policy.
  120. */
  121. /**
  122. * \fn symplectic_rkn_sb3a_m4_mclachlan::symplectic_rkn_sb3a_m4_mclachlan( const algebra_type &algebra )
  123. * \brief Constructs the symplectic_rkn_sb3a_m4_mclachlan. This constructor can be used as a default
  124. * constructor if the algebra has a default constructor.
  125. * \param algebra A copy of algebra is made and stored inside explicit_stepper_base.
  126. */
  127. } // namespace odeint
  128. } // namespace numeric
  129. } // namespace boost
  130. #endif // BOOST_NUMERIC_ODEINT_STEPPER_SYMPLECTIC_RKN_SB3A_M4_MCLACHLAN_HPP_DEFINED