diff --git a/.gitignore b/.gitignore index a3437bff8690fcb279f0bc51d6923a00ebb8bac1..003c662d06543536b5af1ea33c29f9f19c979d6a 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,7 @@ /build /interface/teqpversion.hpp /pypirc -/boost_multiprecision +/boost_teqp /teqp.egg-info /MANIFEST.in /teqp diff --git a/dev/boost_bcp_docker/Dockerfile b/dev/boost_bcp_docker/Dockerfile index 93cdea261746891b419fa40f1ac1a90f4c5480ff..8ce3fdac6689ea44dcdccb9e3898fcb2531e4700 100644 --- a/dev/boost_bcp_docker/Dockerfile +++ b/dev/boost_bcp_docker/Dockerfile @@ -8,10 +8,12 @@ RUN mkdir /boost && \ wget -c https://boostorg.jfrog.io/artifactory/main/release/1.77.0/source/boost_1_77_0.tar.gz -O - | tar -xz -C /boost && \ cd /boost/boost_1_77_0/ && \ ./bootstrap.sh && \ - ./b2 tools/bcp && \ - mkdir /boost_teqp && \ - bin.v2/tools/bcp/gcc-9/release/link-static/bcp multiprecision/cpp_bin_float.hpp multiprecision/eigen.hpp functional/hash.hpp numeric/odeint.hpp /boost_teqp && \ - zip -r /boost_teqp.zip /boost_teqp && \ + ./b2 tools/bcp + +WORKDIR /boost/boost_1_77_0 +RUN mkdir /boost_teqp && \ + bin.v2/tools/bcp/gcc-9/release/link-static/bcp multiprecision/cpp_bin_float.hpp multiprecision/eigen.hpp functional/hash.hpp numeric/odeint.hpp typeof/incr_registration_group.hpp /boost_teqp && \ + zip -r /boost_teqp.zip /boost_teqp && \ tar czf /boost_teqp.tar.gz /boost_teqp CMD cp /*.tar.gz /output \ No newline at end of file diff --git a/dev/boost_bcp_docker/README.md b/dev/boost_bcp_docker/README.md index 87ef08f4ee4d7e5b511c97a9c8c05719daa62cd0..4be8cd2ee7fa29a0ca0529a7064c991b75adc47e 100644 --- a/dev/boost_bcp_docker/README.md +++ b/dev/boost_bcp_docker/README.md @@ -1,7 +1,7 @@ # INFO -Just a tiny docker container used to extract the necessary parts of boost with the use of the tool bcp +Just a tiny docker container used to extract the necessary parts of ``boost`` with the use of the tool ``bcp`` To run: ``docker-compose up --build`` -The output will be a ``.tar.gz`` file with the bits and pieces needed to include in the ``output`` folder. \ No newline at end of file +The output will be a ``.tar.gz`` file in this folder with the bits and pieces needed to include. \ No newline at end of file diff --git a/dev/boost_bcp_docker/boost_teqp.tar.gz b/dev/boost_bcp_docker/boost_teqp.tar.gz index 5faf1923c75ce6256e71b3c9badf46832c170da3..8ef3cd7608f2fc4c7523dad6f66c688eb3a8b591 100644 Binary files a/dev/boost_bcp_docker/boost_teqp.tar.gz and b/dev/boost_bcp_docker/boost_teqp.tar.gz differ diff --git a/src/test_boost_odeint.cpp b/src/test_boost_odeint.cpp new file mode 100644 index 0000000000000000000000000000000000000000..751cdd638975f1968376c3af06339338c0781f28 --- /dev/null +++ b/src/test_boost_odeint.cpp @@ -0,0 +1,44 @@ +#include <iostream> +#include <valarray> + +#include <boost/numeric/odeint/stepper/controlled_runge_kutta.hpp> +#include <boost/numeric/odeint/stepper/runge_kutta_cash_karp54.hpp> + +/* The type of container used to hold the state vector */ +typedef std::vector< double > state_type; + +void xprime( const state_type &x , state_type &dxdt , const double /* t */ ) +{ + const double gam = 0.15; + dxdt[0] = x[1]; + dxdt[1] = -x[0] - gam*x[1]; +} + +int main(int /* argc */ , char** /* argv */ ) +{ + using namespace boost::numeric::odeint; + + // Typedefs for the types + typedef runge_kutta_cash_karp54< state_type > error_stepper_type; + typedef controlled_runge_kutta< error_stepper_type > controlled_stepper_type; + + // Define the tolerances + double abs_err = 1.0e-10 , rel_err = 1.0e-6 , a_x = 1.0 , a_dxdt = 1.0; + controlled_stepper_type controlled_stepper( default_error_checker< double , range_algebra , default_operations >( abs_err , rel_err , a_x , a_dxdt ) ); + + state_type x0 = {1.0, 0.0}; // Starting point + + // First integrate, adaptively, until you get as close to the end as you can + double t = 0, dt = 0.001, tmax = 100.0; + auto write = [&]() { std::cout << t << " " << x0[0] << "," << x0[1] << std::endl; }; + for (auto i = 0; t < tmax; ++i){ + if (t + dt > tmax) { break; } + write(); + auto status = controlled_stepper.try_step(xprime, x0, t, dt); + // The state is mutable, so here is where you could modify the solution + } + write(); + double dtfinal = tmax - t; + auto status = controlled_stepper.try_step(xprime, x0, t, dtfinal); + write(); +} \ No newline at end of file