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