diff --git a/include/boost/numeric/odeint/stepper/adaptive_adams_bashforth_moulton.hpp b/include/boost/numeric/odeint/stepper/adaptive_adams_bashforth_moulton.hpp index 295cc859..9bfd6cbe 100644 --- a/include/boost/numeric/odeint/stepper/adaptive_adams_bashforth_moulton.hpp +++ b/include/boost/numeric/odeint/stepper/adaptive_adams_bashforth_moulton.hpp @@ -124,7 +124,8 @@ public: m_coeff.do_step(m_dxdt.m_v); m_coeff.confirm(); - t += dt/static_cast< Time >(order_value); + if(m_coeff.m_eo < order_value) + m_coeff.m_eo ++; } }; diff --git a/include/boost/numeric/odeint/stepper/detail/adaptive_adams_coefficients.hpp b/include/boost/numeric/odeint/stepper/detail/adaptive_adams_coefficients.hpp index 1bf76bfe..7f6d9d75 100644 --- a/include/boost/numeric/odeint/stepper/detail/adaptive_adams_coefficients.hpp +++ b/include/boost/numeric/odeint/stepper/detail/adaptive_adams_coefficients.hpp @@ -123,8 +123,8 @@ public: size_t m_eo; - rotating_buffer, 2> beta; // beta[0] = beta(n) - rotating_buffer, 3> phi; // phi[0] = phi(n+1) + rotating_buffer, 2> beta; // beta[0] = beta(n) + rotating_buffer, 3> phi; // phi[0] = phi(n+1) boost::array g; private: diff --git a/include/boost/numeric/odeint/stepper/detail/pid_step_adjuster.hpp b/include/boost/numeric/odeint/stepper/detail/pid_step_adjuster.hpp index 35af0ef0..d0c75ee2 100644 --- a/include/boost/numeric/odeint/stepper/detail/pid_step_adjuster.hpp +++ b/include/boost/numeric/odeint/stepper/detail/pid_step_adjuster.hpp @@ -30,7 +30,7 @@ public: typedef rotating_buffer time_storage_type; typedef pid_step_adjuster_coefficients coeff_type; - pid_step_adjuster(double tol = 1e-5, time_type dtmax = 1.0) + pid_step_adjuster(double tol = 1e-6, time_type dtmax = 1.0) :m_dtmax(dtmax), m_error_storage(), m_time_storage(), m_init(0), m_tol(tol) {}; diff --git a/test/adaptive_adams_coefficients.cpp b/test/adaptive_adams_coefficients.cpp index 7a7e8267..362458f0 100644 --- a/test/adaptive_adams_coefficients.cpp +++ b/test/adaptive_adams_coefficients.cpp @@ -25,58 +25,96 @@ BOOST_AUTO_TEST_SUITE( adaptive_adams_coefficients_test ) typedef boost::mpl::range_c< size_t , 2 , 10 > vector_of_steps; BOOST_AUTO_TEST_CASE_TEMPLATE( test_step, step_type, vector_of_steps ) { - // const static size_t steps = step_type::value; + const static size_t steps = step_type::value; - // typedef std::vector deriv_type; - // typedef double time_type; + typedef std::vector deriv_type; + typedef double time_type; - // typedef detail::adaptive_adams_coefficients aac_type; + typedef detail::adaptive_adams_coefficients aac_type; - // std::vector deriv; - // deriv.push_back(-1); + std::vector deriv; + deriv.push_back(-1); - // aac_type coeff; - // for(size_t i=0; i v(10); + v[0] = 1.0/1.0; + v[1] = 1.0/2.0; + v[2] = 5.0/12.0; + v[3] = 9.0/24.0; + v[4] = 251.0/720.0; + v[5] = 95.0/288.0; + v[6] = 19087.0/60480.0; + v[7] = 5257.0/17280.0; + v[8] = 5311869667636789.0/18014398509481984.0; + + for(size_t i=0; i deriv_type; - // typedef double time_type; + typedef std::vector deriv_type; + typedef double time_type; - // typedef detail::adaptive_adams_coefficients<3, deriv_type, time_type> aac_type; - // aac_type c1; + typedef detail::adaptive_adams_coefficients<3, deriv_type, time_type> aac_type; + aac_type c1; - // deriv_type deriv(1); - // deriv[0] = 1.0; + deriv_type deriv(1); + deriv[0] = 1.0; - // c1.step(deriv, 0.0); - // c1.confirm(); - // c1.step(deriv, 1.0); - // c1.confirm(); - // c1.step(deriv, 2.0); - // c1.confirm(); + time_type t = 0.0; + time_type dt = 0.01; - // aac_type c2(c1); - // BOOST_CHECK_EQUAL(c1.m_ss[0][0].m_v[0], c2.m_ss[0][0].m_v[0]); - // BOOST_CHECK(&(c1.m_ss[0][0].m_v) != &(c2.m_ss[0][0].m_v)); + for(size_t i=0; i<3; ++i) + { + c1.predict(t, dt); + c1.do_step(deriv); + c1.confirm(); - // aac_type c3; - // deriv_type *p1 = &(c3.m_ss[0][0].m_v); + t+= dt; - // c3 = c1; - // // BOOST_CHECK(p1 == (&(c3.m_ss[0][0].m_v))); - // BOOST_CHECK_EQUAL(c1.m_ss[0][0].m_v[0], c3.m_ss[0][0].m_v[0]); + if(c1.m_eo < 3) + c1.m_eo ++; + } + + aac_type c2(c1); + BOOST_CHECK_EQUAL(c1.phi[0][0].m_v[0], c2.phi[0][0].m_v[0]); + BOOST_CHECK(&(c1.phi[0][0].m_v) != &(c2.phi[0][0].m_v)); + + aac_type c3; + deriv_type *p1 = &(c3.phi[0][0].m_v); + + c3 = c1; + BOOST_CHECK(p1 == (&(c3.phi[0][0].m_v))); + BOOST_CHECK_EQUAL(c1.phi[0][0].m_v[0], c3.phi[0][0].m_v[0]); } BOOST_AUTO_TEST_SUITE_END() \ No newline at end of file diff --git a/test/integrate.cpp b/test/integrate.cpp index 8f43228f..07d4617f 100644 --- a/test/integrate.cpp +++ b/test/integrate.cpp @@ -17,6 +17,8 @@ #define BOOST_TEST_MODULE odeint_integrate_functions +#include + #include #include #include @@ -240,7 +242,12 @@ class stepper_methods : public mpl::vector< controlled_runge_kutta< runge_kutta_dopri5< state_type > > , controlled_runge_kutta< runge_kutta_fehlberg78< state_type > > , bulirsch_stoer< state_type > , - dense_output_runge_kutta< controlled_runge_kutta< runge_kutta_dopri5< state_type > > > + dense_output_runge_kutta< controlled_runge_kutta< runge_kutta_dopri5< state_type > > >, + adaptive_adams_bashforth_moulton<3, state_type>, + adaptive_adams_bashforth_moulton<5, state_type>, + adaptive_adams_bashforth_moulton<7, state_type>, + controlled_adams_bashforth_moulton >, + controlled_adams_bashforth_moulton > //bulirsch_stoer_dense_out< state_type > > { }; @@ -277,12 +284,16 @@ BOOST_AUTO_TEST_CASE_TEMPLATE( integrate_times_test_case , Stepper, stepper_meth BOOST_AUTO_TEST_CASE_TEMPLATE( integrate_n_steps_test_case , Stepper, stepper_methods ) { - perform_integrate_n_steps_test< Stepper > tester; - tester(); - tester( 200 , 0.01 ); - tester( 200 , 0.01 ); - tester( 200 , 0.01 ); - tester( 200 , -0.01 ); + if(!boost::is_same > >::value && + !boost::is_same > >::value) + { + perform_integrate_n_steps_test< Stepper > tester; + tester(); + tester( 200 , 0.01 ); + tester( 200 , 0.01 ); + tester( 200 , 0.01 ); + tester( 200 , -0.01 ); + } } BOOST_AUTO_TEST_SUITE_END()