dummy_odes.hpp 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /*
  2. [auto_generated]
  3. libs/numeric/odeint/test/dummy_odes.hpp
  4. [begin_description]
  5. tba.
  6. [end_description]
  7. Copyright 2012-2013 Karsten Ahnert
  8. Copyright 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 LIBS_NUMERIC_ODEINT_TEST_DUMMY_ODES_HPP_DEFINED
  14. #define LIBS_NUMERIC_ODEINT_TEST_DUMMY_ODES_HPP_DEFINED
  15. #include <boost/fusion/include/at_c.hpp>
  16. /*
  17. * rhs functors/functions for different state types
  18. */
  19. struct constant_system_functor_standard
  20. {
  21. template< class State , class Deriv , class Time >
  22. void operator()( const State &x , Deriv &dxdt , const Time t ) const
  23. {
  24. dxdt[0] = 1.0;
  25. }
  26. };
  27. struct constant_system_functor_vector_space
  28. {
  29. template< class State , class Deriv , class Time >
  30. void operator()( const State &x , Deriv &dxdt , const Time t ) const
  31. {
  32. dxdt = 1.0;
  33. }
  34. };
  35. struct constant_system_functor_fusion
  36. {
  37. template< class State , class Deriv , class Time >
  38. void operator()( const State &x , Deriv &dxdt , const Time t ) const
  39. {
  40. boost::fusion::at_c< 0 >( dxdt ) = boost::fusion::at_c< 0 >( x ) / Time( 1.0 );
  41. }
  42. };
  43. struct lorenz
  44. {
  45. template< typename State , typename Deriv , typename Time >
  46. void operator()( const State& x , Deriv& dxdt , const Time& t ) const
  47. {
  48. const Time sigma = 10.0;
  49. const Time R = 28.0;
  50. const Time b = 8.0 / 3.0;
  51. dxdt[0] = sigma * ( x[1] - x[0] );
  52. dxdt[1] = R * x[0] - x[1] - x[0] * x[2];
  53. dxdt[2] = -b * x[2] + x[0] * x[1];
  54. }
  55. };
  56. template< class State , class Deriv , class Time >
  57. void constant_system_standard( const State &x , Deriv &dxdt , const Time t )
  58. {
  59. dxdt[0] = 1.0;
  60. }
  61. template< class State , class Deriv , class Time >
  62. void constant_system_vector_space( const State &x , Deriv &dxdt , const Time t )
  63. {
  64. dxdt = 1.0;
  65. }
  66. template< class State , class Deriv , class Time >
  67. void constant_system_fusion( const State &x , Deriv &dxdt , const Time t )
  68. {
  69. boost::fusion::at_c< 0 >( dxdt ) = boost::fusion::at_c< 0 >( x ) / Time( 1.0 );
  70. }
  71. /*
  72. * rhs functors for symplectic steppers
  73. */
  74. struct constant_mom_func
  75. {
  76. template< class StateIn , class StateOut >
  77. void operator()( const StateIn &q , StateOut &dp ) const
  78. {
  79. dp[0] = 1.0;
  80. }
  81. };
  82. struct default_coor_func
  83. {
  84. template< class StateIn , class StateOut >
  85. void operator()( const StateIn &p , StateOut &dq ) const
  86. {
  87. dq[0] = p[0];
  88. }
  89. };
  90. struct constant_mom_func_vector_space_1d
  91. {
  92. template< class T >
  93. void operator()( const T &q , T &dp ) const
  94. {
  95. dp = 1.0;
  96. }
  97. };
  98. struct default_coor_func_vector_space_1d
  99. {
  100. template< class T >
  101. void operator()( const T &p , T &dq ) const
  102. {
  103. dq = p;
  104. }
  105. };
  106. struct empty_system
  107. {
  108. template <class State >
  109. void operator()( const State &x , State &dxdt , double t ) const
  110. {
  111. }
  112. };
  113. #endif // LIBS_NUMERIC_ODEINT_TEST_DUMMY_ODES_HPP_DEFINED