integrate.hpp 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  1. /*
  2. [auto_generated]
  3. boost/numeric/odeint/integrate/integrate.hpp
  4. [begin_description]
  5. Convenience methods which choose the stepper for the current ODE.
  6. [end_description]
  7. Copyright 2011-2013 Karsten Ahnert
  8. Copyright 2011-2012 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_INTEGRATE_INTEGRATE_HPP_INCLUDED
  14. #define BOOST_NUMERIC_ODEINT_INTEGRATE_INTEGRATE_HPP_INCLUDED
  15. #include <boost/utility/enable_if.hpp>
  16. #include <boost/numeric/odeint/stepper/runge_kutta_dopri5.hpp>
  17. #include <boost/numeric/odeint/stepper/controlled_runge_kutta.hpp>
  18. #include <boost/numeric/odeint/integrate/null_observer.hpp>
  19. #include <boost/numeric/odeint/integrate/integrate_adaptive.hpp>
  20. // for has_value_type trait
  21. #include <boost/numeric/odeint/algebra/detail/extract_value_type.hpp>
  22. namespace boost {
  23. namespace numeric {
  24. namespace odeint {
  25. /*
  26. * ToDo :
  27. *
  28. * determine type of dxdt for units
  29. *
  30. */
  31. template< class System , class State , class Time , class Observer >
  32. typename boost::enable_if< typename has_value_type<State>::type , size_t >::type
  33. integrate( System system , State &start_state , Time start_time , Time end_time , Time dt , Observer observer )
  34. {
  35. typedef controlled_runge_kutta< runge_kutta_dopri5< State , typename State::value_type , State , Time > > stepper_type;
  36. return integrate_adaptive( stepper_type() , system , start_state , start_time , end_time , dt , observer );
  37. }
  38. template< class Value , class System , class State , class Time , class Observer >
  39. size_t
  40. integrate( System system , State &start_state , Time start_time , Time end_time , Time dt , Observer observer )
  41. {
  42. typedef controlled_runge_kutta< runge_kutta_dopri5< State , Value , State , Time > > stepper_type;
  43. return integrate_adaptive( stepper_type() , system , start_state , start_time , end_time , dt , observer );
  44. }
  45. /*
  46. * the two overloads are needed in order to solve the forwarding problem
  47. */
  48. template< class System , class State , class Time >
  49. size_t integrate( System system , State &start_state , Time start_time , Time end_time , Time dt )
  50. {
  51. return integrate( system , start_state , start_time , end_time , dt , null_observer() );
  52. }
  53. template< class Value , class System , class State , class Time >
  54. size_t integrate( System system , State &start_state , Time start_time , Time end_time , Time dt )
  55. {
  56. return integrate< Value >( system , start_state , start_time , end_time , dt , null_observer() );
  57. }
  58. /**
  59. * \fn integrate( System system , State &start_state , Time start_time , Time end_time , Time dt , Observer observer )
  60. * \brief Integrates the ODE.
  61. *
  62. * Integrates the ODE given by system from start_time to end_time starting
  63. * with start_state as initial condition and dt as initial time step.
  64. * This function uses a dense output dopri5 stepper and performs an adaptive
  65. * integration with step size control, thus dt changes during the integration.
  66. * This method uses standard error bounds of 1E-6.
  67. * After each step, the observer is called.
  68. *
  69. * \attention A second version of this function template exists which explicitly
  70. * expects the value type as template parameter, i.e. integrate< double >( sys , x , t0 , t1 , dt , obs );
  71. *
  72. * \param system The system function to solve, hence the r.h.s. of the
  73. * ordinary differential equation.
  74. * \param start_state The initial state.
  75. * \param start_time Start time of the integration.
  76. * \param end_time End time of the integration.
  77. * \param dt Initial step size, will be adjusted during the integration.
  78. * \param observer Observer that will be called after each time step.
  79. * \return The number of steps performed.
  80. */
  81. /**
  82. * \fn integrate( System system , State &start_state , Time start_time , Time end_time , Time dt )
  83. * \brief Integrates the ODE without observer calls.
  84. *
  85. * Integrates the ODE given by system from start_time to end_time starting
  86. * with start_state as initial condition and dt as initial time step.
  87. * This function uses a dense output dopri5 stepper and performs an adaptive
  88. * integration with step size control, thus dt changes during the integration.
  89. * This method uses standard error bounds of 1E-6.
  90. * No observer is called.
  91. *
  92. * \attention A second version of this function template exists which explicitly
  93. * expects the value type as template parameter, i.e. integrate< double >( sys , x , t0 , t1 , dt );
  94. *
  95. * \param system The system function to solve, hence the r.h.s. of the
  96. * ordinary differential equation.
  97. * \param start_state The initial state.
  98. * \param start_time Start time of the integration.
  99. * \param end_time End time of the integration.
  100. * \param dt Initial step size, will be adjusted during the integration.
  101. * \return The number of steps performed.
  102. */
  103. } // namespace odeint
  104. } // namespace numeric
  105. } // namespace boost
  106. #endif // BOOST_NUMERIC_ODEINT_INTEGRATE_INTEGRATE_HPP_INCLUDED