Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r62910 - in sandbox/odeint: boost/numeric/odeint libs/numeric/odeint/examples
From: karsten.ahnert_at_[hidden]
Date: 2010-06-13 11:19:56


Author: karsten
Date: 2010-06-13 11:19:54 EDT (Sun, 13 Jun 2010)
New Revision: 62910
URL: http://svn.boost.org/trac/boost/changeset/62910

Log:
removed the center of mass velocity from the solar system example
Added:
   sandbox/odeint/boost/numeric/odeint/hamiltonian_stepper_euler_qfunc.hpp
      - copied unchanged from r62909, /sandbox/odeint/boost/numeric/odeint/hamiltonian_stepper_qfunc.hpp
Text files modified:
   sandbox/odeint/boost/numeric/odeint/hamiltonian_stepper_euler.hpp | 24 ------------------------
   sandbox/odeint/boost/numeric/odeint/hamiltonian_stepper_rk.hpp | 6 +++---
   sandbox/odeint/libs/numeric/odeint/examples/solar_system.cpp | 9 ++++-----
   3 files changed, 7 insertions(+), 32 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-13 11:19:54 EDT (Sun, 13 Jun 2010)
@@ -76,32 +76,8 @@
                                            traits_type::end(p) ,
                                            traits_type::begin(dpdt) ,
                                            dt );
-
         }
 
- template< class CoordinateFunction , class MomentumFunction >
- void do_step( CoordinateFunction dqdt_func ,
- MomentumFunction dpdt_func ,
- container_type &q ,
- container_type &p ,
- time_type dt )
- {
- if( !traits_type::same_size( q , p ) )
- {
- std::string msg( "hamiltonian_stepper_euler::do_step(): " );
- msg += "q and p have different sizes";
- throw std::invalid_argument( msg );
- }
-
- traits_type::adjust_size( p , m_dqdt );
- traits_type::adjust_size( p , m_dpdt );
-
- dqdt_func( p , m_dqdt );
- detail::it_algebra::increment( traits_type::begin(q) ,
- traits_type::end(q) ,
- traits_type::begin(m_dqdt) ,
- dt );
- }
     };
 
 

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-13 11:19:54 EDT (Sun, 13 Jun 2010)
@@ -67,7 +67,7 @@
         template< class CoordinateFunction >
         void do_step( CoordinateFunction qfunc ,
                       state_type &x ,
- time_type t ,
+ time_type t ,
                       time_type dt )
         {
             const size_t order = 6;
@@ -89,8 +89,8 @@
                     static_cast<time_type>( 0.0 )
                 };
 
- container_type &q = x.first;
- container_type &p = x.second;
+ container_type &q = x.first;
+ container_type &p = x.second;
 
             if( !traits_type::same_size( q , p ) )
             {

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-13 11:19:54 EDT (Sun, 13 Jun 2010)
@@ -152,12 +152,11 @@
             point_type( 0.00288930 , 0.00114527 , 0.00039677 ) , // neptune
             point_type( 0.00276725 , -0.00170702 , -0.00136504 ) // pluto
         }};
- for( size_t i=0 ; i<n ; ++i ) p[i] *= masses[i];
-
 
-/*
- * ToDo : remove center of mass velocity
-*/
+ // remove center of mass velocity
+ point_type com = center_of_mass( p , masses );
+ for( size_t i=0 ; i<n ; ++i ) p[i] -= com;
+ for( size_t i=0 ; i<n ; ++i ) p[i] *= masses[i];
 
     stepper_type stepper;
     const double dt = 1.0;


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