integrate.hpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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 2009-2011 Karsten Ahnert
  8. Copyright 2009-2011 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/iterator/integrate/null_observer.hpp>
  19. #include <boost/numeric/odeint/iterator/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. /*
  39. * the two overloads are needed in order to solve the forwarding problem
  40. */
  41. template< class System , class State , class Time >
  42. size_t integrate( System system , State &start_state , Time start_time , Time end_time , Time dt )
  43. {
  44. return integrate( system , start_state , start_time , end_time , dt , null_observer() );
  45. }
  46. /**
  47. * \fn integrate( System system , State &start_state , Time start_time , Time end_time , Time dt , Observer observer )
  48. * \brief Integrates the ODE.
  49. *
  50. * Integrates the ODE given by system from start_time to end_time starting
  51. * with start_state as initial condition and dt as initial time step.
  52. * This function uses a dense output dopri5 stepper and performs an adaptive
  53. * integration with step size control, thus dt changes during the integration.
  54. * This method uses standard error bounds of 1E-6.
  55. * After each step, the observer is called.
  56. *
  57. * \param system The system function to solve, hence the r.h.s. of the
  58. * ordinary differential equation.
  59. * \param start_state The initial state.
  60. * \param start_time Start time of the integration.
  61. * \param end_time End time of the integration.
  62. * \param dt Initial step size, will be adjusted during the integration.
  63. * \param observer Observer that will be called after each time step.
  64. * \return The number of steps performed.
  65. */
  66. /**
  67. * \fn integrate( System system , State &start_state , Time start_time , Time end_time , Time dt )
  68. * \brief Integrates the ODE without observer calls.
  69. *
  70. * Integrates the ODE given by system from start_time to end_time starting
  71. * with start_state as initial condition and dt as initial time step.
  72. * This function uses a dense output dopri5 stepper and performs an adaptive
  73. * integration with step size control, thus dt changes during the integration.
  74. * This method uses standard error bounds of 1E-6.
  75. * No observer is called.
  76. *
  77. * \param system The system function to solve, hence the r.h.s. of the
  78. * ordinary differential equation.
  79. * \param start_state The initial state.
  80. * \param start_time Start time of the integration.
  81. * \param end_time End time of the integration.
  82. * \param dt Initial step size, will be adjusted during the integration.
  83. * \return The number of steps performed.
  84. */
  85. } // namespace odeint
  86. } // namespace numeric
  87. } // namespace boost
  88. #endif // BOOST_NUMERIC_ODEINT_INTEGRATE_INTEGRATE_HPP_INCLUDED