Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r57042 - in sandbox/odeint: boost/numeric libs libs/numeric libs/numeric/odeint libs/numeric/odeint/doc libs/numeric/odeint/examples
From: karsten.ahnert_at_[hidden]
Date: 2009-10-21 10:18:00


Author: karsten
Date: 2009-10-21 10:18:00 EDT (Wed, 21 Oct 2009)
New Revision: 57042
URL: http://svn.boost.org/trac/boost/changeset/57042

Log:
first version of euler stepper
Added:
   sandbox/odeint/libs/
   sandbox/odeint/libs/numeric/
   sandbox/odeint/libs/numeric/odeint/
   sandbox/odeint/libs/numeric/odeint/doc/
   sandbox/odeint/libs/numeric/odeint/examples/
   sandbox/odeint/libs/numeric/odeint/examples/lorenz.cpp (contents, props changed)
Text files modified:
   sandbox/odeint/boost/numeric/odeint.hpp | 20 ++++++++++++++++++++
   1 files changed, 20 insertions(+), 0 deletions(-)

Modified: sandbox/odeint/boost/numeric/odeint.hpp
==============================================================================
--- sandbox/odeint/boost/numeric/odeint.hpp (original)
+++ sandbox/odeint/boost/numeric/odeint.hpp 2009-10-21 10:18:00 EDT (Wed, 21 Oct 2009)
@@ -0,0 +1,20 @@
+/* Boost odeint.hpp header file
+
+ Copyright 2009 Karsten Ahnert
+ Copyright 2009 Mario Mulansky
+ Copyright 2009 Andre Bergner
+
+ This file includes *all* headers needed for integration of ordinary differential equations.
+
+
+ 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)
+*/
+
+#ifndef BOOST_NUMERIC_ODEINT_HPP
+#define BOOST_NUMERIC_ODEINT_HPP
+
+#include <boost/numeric/odeint/euler.hpp>
+
+#endif // BOOST_NUMERIC_ODEINT_HPP

Added: sandbox/odeint/libs/numeric/odeint/examples/lorenz.cpp
==============================================================================
--- (empty file)
+++ sandbox/odeint/libs/numeric/odeint/examples/lorenz.cpp 2009-10-21 10:18:00 EDT (Wed, 21 Oct 2009)
@@ -0,0 +1,77 @@
+/* Boost numeric/odeint/examples/lorenz.cpp
+
+ Copyright 2009 Karsten Ahnert
+
+ Shows, the usage of odeint, and integrates the Lorenz equations,
+ a deterministic chaotic system
+
+ dx/dt = sigma * ( x - y)
+ dy/dt = R*x - y - x*z
+ dz/dt = x*y - b*z
+
+ mit sigma = 10, r=28, b = 8/3
+
+ 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 <iostream>
+#include <vector>
+#include <list>
+#include <tr1/array>
+
+#include <boost/numeric/odeint.hpp>
+
+#define tab "\t"
+
+using namespace std;
+using namespace std::tr1;
+using namespace boost::numeric::odeint;
+
+
+
+
+const double sigma = 10.0;
+const double R = 28.0;
+const double b = 8.0 / 3.0;
+
+const double dt = 0.01;
+const size_t olen = 10000;
+
+typedef vector<double> state_type;
+//typedef list<double> state_type;
+
+void lorenz( state_type::iterator x , state_type::iterator dxdt , double t )
+{
+ dxdt[0] = sigma * ( x[1] - x[0] );
+ dxdt[1] = R * x[0] - x[1] - x[0] * x[2];
+ dxdt[2] = x[0]*x[1] - b * x[2];
+}
+
+int main( int argc , char **argv )
+{
+
+ state_type x(3);
+ x[0] = 1.0;
+ x[1] = 0.0;
+ x[2] = 0.0;
+
+ ode_step_euler< state_type > euler;
+
+ double t = 0.0;
+ for( size_t oi=0 ; oi<olen ; ++oi,t+=dt )
+ {
+ cout << t << tab << x[0] << tab << x[1] << tab << x[2] << endl;
+ euler.next_step( lorenz , x , t , dt );
+ }
+
+ return 0;
+}
+
+
+
+/*
+ Compile with
+ g++ -Wall -I$BOOST_ROOT -I../../../../ lorenz.cpp
+*/


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