From 483eb2f56657e8e7f419ab1a4fab8dce9ade8609 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sat, 27 Apr 2024 20:24:20 +0200 Subject: Adding upstream version 14.2.21. Signed-off-by: Daniel Baumann --- .../libs/numeric/odeint/examples/solar_system.cpp | 201 +++++++++++++++++++++ 1 file changed, 201 insertions(+) create mode 100644 src/boost/libs/numeric/odeint/examples/solar_system.cpp (limited to 'src/boost/libs/numeric/odeint/examples/solar_system.cpp') diff --git a/src/boost/libs/numeric/odeint/examples/solar_system.cpp b/src/boost/libs/numeric/odeint/examples/solar_system.cpp new file mode 100644 index 00000000..3586d5b8 --- /dev/null +++ b/src/boost/libs/numeric/odeint/examples/solar_system.cpp @@ -0,0 +1,201 @@ +/* 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 + */ -- cgit v1.2.3