/* Boost libs/numeric/odeint/examples/solar_system.cpp Copyright 2010-2012 Karsten Ahnert Copyright 2011 Mario Mulansky Solar system example for Hamiltonian stepper Distributed under the Boost Software License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) */ #include #include #include #include "point_type.hpp" //[ container_type_definition // we simulate 5 planets and the sun const size_t n = 6; typedef point< double , 3 > point_type; typedef boost::array< point_type , n > container_type; typedef boost::array< double , n > mass_type; //] //[ coordinate_function const double gravitational_constant = 2.95912208286e-4; struct solar_system_coor { const mass_type &m_masses; solar_system_coor( const mass_type &masses ) : m_masses( masses ) { } void operator()( const container_type &p , container_type &dqdt ) const { for( size_t i=0 ; i void operator()( const State &x , double t ) const { container_type &q = x.first; m_out << t; for( size_t i=0 ; i stepper_type; const double dt = 100.0; integrate_const( stepper_type() , make_pair( solar_system_coor( masses ) , solar_system_momentum( masses ) ) , make_pair( boost::ref( q ) , boost::ref( p ) ) , 0.0 , 200000.0 , dt , streaming_observer( cout ) ); //] return 0; } /* Plot with gnuplot: p "solar_system.dat" u 2:4 w l,"solar_system.dat" u 5:7 w l,"solar_system.dat" u 8:10 w l,"solar_system.dat" u 11:13 w l,"solar_system.dat" u 14:16 w l,"solar_system.dat" u 17:19 w l */