|
Boost-Commit : |
Subject: [Boost-commit] svn:boost r62801 - in sandbox/odeint: boost/numeric/odeint libs/numeric/odeint/examples
From: mario.mulansky_at_[hidden]
Date: 2010-06-11 10:22:54
Author: mariomulansky
Date: 2010-06-11 10:22:53 EDT (Fri, 11 Jun 2010)
New Revision: 62801
URL: http://svn.boost.org/trac/boost/changeset/62801
Log:
added pair to hamiltonian steppers
Text files modified:
sandbox/odeint/boost/numeric/odeint/hamiltonian_stepper_euler.hpp | 10 +++++++-
sandbox/odeint/boost/numeric/odeint/hamiltonian_stepper_rk.hpp | 9 +++++--
sandbox/odeint/boost/numeric/odeint/stepper_euler.hpp | 6 ++--
sandbox/odeint/libs/numeric/odeint/examples/solar_system.cpp | 42 +++++++++++++++++++++------------------
4 files changed, 40 insertions(+), 27 deletions(-)
Modified: sandbox/odeint/boost/numeric/odeint/hamiltonian_stepper_euler.hpp
==============================================================================
--- sandbox/odeint/boost/numeric/odeint/hamiltonian_stepper_euler.hpp (original)
+++ sandbox/odeint/boost/numeric/odeint/hamiltonian_stepper_euler.hpp 2010-06-11 10:22:53 EDT (Fri, 11 Jun 2010)
@@ -14,6 +14,7 @@
#define BOOST_NUMERIC_ODEINT_HAMILTONIAN_STEPPER_EULER_HPP_INCLUDED
#include <stdexcept>
+#include <utility>
#include <boost/numeric/odeint/detail/iterator_algebra.hpp>
#include <boost/numeric/odeint/container_traits.hpp>
@@ -36,6 +37,7 @@
typedef Time time_type;
typedef Traits traits_type;
typedef typename traits_type::container_type container_type;
+ typedef std::pair< container_type , container_type > state_type;
typedef typename traits_type::value_type value_type;
typedef typename traits_type::iterator iterator;
typedef typename traits_type::const_iterator const_iterator;
@@ -50,10 +52,14 @@
template< class CoordinateFunction >
void do_step( CoordinateFunction qfunc ,
- container_type &q ,
- container_type &p ,
+ state_type &x ,
+ time_type t ,
time_type dt )
{
+
+ container_type &q = x.first;
+ container_type &p = x.second;
+
if( !traits_type::same_size( q , p ) )
{
std::string msg( "hamiltonian_stepper_euler::do_step(): " );
Modified: sandbox/odeint/boost/numeric/odeint/hamiltonian_stepper_rk.hpp
==============================================================================
--- sandbox/odeint/boost/numeric/odeint/hamiltonian_stepper_rk.hpp (original)
+++ sandbox/odeint/boost/numeric/odeint/hamiltonian_stepper_rk.hpp 2010-06-11 10:22:53 EDT (Fri, 11 Jun 2010)
@@ -14,6 +14,7 @@
#define BOOST_NUMERIC_ODEINT_HAMILTONIAN_STEPPER_RK_HPP_INCLUDED
#include <stdexcept>
+#include <utility>
#include <boost/numeric/odeint/detail/iterator_algebra.hpp>
#include <boost/numeric/odeint/container_traits.hpp>
@@ -36,6 +37,7 @@
typedef Time time_type;
typedef Traits traits_type;
typedef typename traits_type::container_type container_type;
+ typedef std::pair< container_type , container_type > state_type;
typedef typename traits_type::value_type value_type;
typedef typename traits_type::iterator iterator;
typedef typename traits_type::const_iterator const_iterator;
@@ -64,8 +66,8 @@
template< class CoordinateFunction >
void do_step( CoordinateFunction qfunc ,
- container_type &q ,
- container_type &p ,
+ state_type &x ,
+ time_type t ,
time_type dt )
{
const size_t order = 6;
@@ -87,7 +89,8 @@
static_cast<time_type>( 0.0 )
};
-
+ container_type &q = x.first;
+ container_type &p = x.second;
if( !traits_type::same_size( q , p ) )
{
Modified: sandbox/odeint/boost/numeric/odeint/stepper_euler.hpp
==============================================================================
--- sandbox/odeint/boost/numeric/odeint/stepper_euler.hpp (original)
+++ sandbox/odeint/boost/numeric/odeint/stepper_euler.hpp 2010-06-11 10:22:53 EDT (Fri, 11 Jun 2010)
@@ -106,9 +106,9 @@
// performs one step
template< class DynamicalSystem >
void do_step( DynamicalSystem &system ,
- state_type &x ,
- time_type t ,
- time_type dt )
+ state_type &x ,
+ time_type t ,
+ time_type dt )
{
system( x , m_dxdt , t );
do_step( system , x , m_dxdt , t , dt );
Modified: sandbox/odeint/libs/numeric/odeint/examples/solar_system.cpp
==============================================================================
--- sandbox/odeint/libs/numeric/odeint/examples/solar_system.cpp (original)
+++ sandbox/odeint/libs/numeric/odeint/examples/solar_system.cpp 2010-06-11 10:22:53 EDT (Fri, 11 Jun 2010)
@@ -18,6 +18,7 @@
#include <boost/ref.hpp>
#include <boost/numeric/odeint.hpp>
#include <boost/numeric/odeint/container_traits_tr1_array.hpp>
+#include <utility>
#include "point_type.hpp"
@@ -31,6 +32,9 @@
typedef point< double , 3 > point_type;
typedef std::tr1::array< point_type , n > state_type;
+
+typedef std::pair< state_type , state_type > state_pair;
+
typedef std::tr1::array< double , n > mass_type;
typedef hamiltonian_stepper_euler< state_type > stepper_type;
@@ -114,24 +118,24 @@
1.0 / ( 1.3e8 ) // pluto
}};
- state_type q = {{
- point_type( 0.0 , 0.0 , 0.0 ) , // sun
- point_type( -3.5023653 , -3.8169847 , -1.5507963 ) , // jupiter
- point_type( 9.0755314 , -3.0458353 , -1.6483708 ) , // saturn
- point_type( 8.3101420 , -16.2901086 , -7.2521278 ) , // uranus
- point_type( 11.4707666 , -25.7294829 , -10.8169456 ) , // neptune
- point_type( -15.5387357 , -25.2225594 , -3.1902382 ) // pluto
- }};
-
- state_type p = {{
- point_type( 0.0 , 0.0 , 0.0 ) , // sun
- point_type( 0.00565429 , -0.00412490 , -0.00190589 ) , // jupiter
- point_type( 0.00168318 , 0.00483525 , 0.00192462 ) , // saturn
- point_type( 0.00354178 , 0.00137102 , 0.00055029 ) , // uranus
- point_type( 0.00288930 , 0.00114527 , 0.00039677 ) , // neptune
- point_type( 0.00276725 , -0.00170702 , -0.00136504 ) // pluto
- }};
-
+ state_pair state;
+ state_type &q = state.first;
+ state_type &p = state.second;
+
+ q[0] = point_type( 0.0 , 0.0 , 0.0 ); // sun
+ q[1] = point_type( -3.5023653 , -3.8169847 , -1.5507963 ); // jupiter
+ q[2] = point_type( 9.0755314 , -3.0458353 , -1.6483708 ); // saturn
+ q[3] = point_type( 8.3101420 , -16.2901086 , -7.2521278 ); // uranus
+ q[4] = point_type( 11.4707666 , -25.7294829 , -10.8169456 ); // neptune
+ q[5] = point_type( -15.5387357 , -25.2225594 , -3.1902382 ); // pluto
+
+
+ p[0] = point_type( 0.0 , 0.0 , 0.0 ); // sun
+ p[1] = point_type( 0.00565429 , -0.00412490 , -0.00190589 ); // jupiter
+ p[2] = point_type( 0.00168318 , 0.00483525 , 0.00192462 ); // saturn
+ p[3] = point_type( 0.00354178 , 0.00137102 , 0.00055029 ); // uranus
+ p[4] = point_type( 0.00288930 , 0.00114527 , 0.00039677 ); // neptune
+ p[5] = point_type( 0.00276725 , -0.00170702 , -0.00136504 ); // pluto
point_type qmean = center_of_mass( q , masses );
point_type pmean = center_of_mass( p , masses );
@@ -153,7 +157,7 @@
cout << endl;
for( size_t i=0 ; i<1 ; ++i,t+=dt )
- stepper.do_step( sol , q , p , dt );
+ stepper.do_step( sol , state , t , dt );
t += dt;
}
Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk