symplectic_rkn_sb3a_mclachlan.hpp 5.3 KB

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