formatting

This commit is contained in:
Valentin Hartmann 2017-07-06 20:07:56 +02:00
parent fa6621e43c
commit c673986a13
5 changed files with 89 additions and 73 deletions

View File

@ -105,7 +105,9 @@ public:
m_coeff.confirm();
if(m_coeff.m_eo < order_value)
{
m_coeff.m_eo ++;
}
};
template< class ExplicitStepper, class System >
@ -123,7 +125,9 @@ public:
m_coeff.confirm();
if(m_coeff.m_eo < order_value)
m_coeff.m_eo ++;
{
++m_coeff.m_eo;
}
}
};

View File

@ -75,7 +75,6 @@ public:
};
private:
algebra_type m_algebra;
};
template<
@ -146,7 +145,9 @@ public:
controlled_step_result res = try_step(system, inOut, t, m_xnew.m_v, dt);
if(res == success)
{
boost::numeric::odeint::copy( m_xnew.m_v , inOut);
}
return res;
};

View File

@ -52,8 +52,8 @@ public:
typedef adaptive_adams_coefficients< Steps , Deriv , Value , Time , Algebra , Operations , Resizer > aac_type;
adaptive_adams_coefficients( const algebra_type &algebra = algebra_type())
:m_eo( 1 ), m_steps_init( 1 ), beta(), phi(), m_ns( 0 ), m_time_storage(),
m_algebra( algebra ),
:m_eo(1), m_steps_init(1), beta(), phi(), m_ns(0), m_time_storage(),
m_algebra(algebra),
m_phi_resizer()
{
for (size_t i=0; i<order_value+2; ++i)
@ -81,8 +81,10 @@ public:
for(size_t i=1+m_ns; i<m_eo+1; ++i)
{
if(i<m_steps_init)
{
beta[0][i] = beta[0][i-1]*(m_time_storage[0] + dt -
m_time_storage[i-1])/(m_time_storage[0] - m_time_storage[i]);
}
}
for(size_t i=1+m_ns; i<m_eo+2; ++i)
@ -90,7 +92,9 @@ public:
for(size_t j=0; j<m_eo+1; ++j)
{
if(i<m_steps_init+1)
{
c[i][j] = c[i-1][j] - c[i-1][j+1]*dt/(m_time_storage[0] + dt - m_time_storage[i-1]);
}
}
g[i] = c[i][0];
@ -106,8 +110,10 @@ public:
for(size_t i=1; i<m_eo + 2; ++i)
{
if(i<m_steps_init+1)
{
this->m_algebra.for_each3(phi[o][i].m_v, phi[o][i-1].m_v, phi[o+1][i-1].m_v,
typename Operations::template scale_sum2<double, double>(1.0, -beta[o][i-1]));
}
}
};
@ -118,7 +124,9 @@ public:
m_time_storage.rotate();
if(m_steps_init < order_value+1)
{
++m_steps_init;
}
};
void reset() { m_eo = 1; };

View File

@ -8,10 +8,10 @@
#include <math.h>
namespace boost{
namespace numeric{
namespace odeint{
namespace detail{
namespace boost {
namespace numeric {
namespace odeint {
namespace detail {
template<
class Value = double,
@ -51,6 +51,7 @@ public:
adapted_pow(fabs(m_tol/t4), beta3/(m_steps + 1)) *
adapted_pow(fabs(dt1/dt2), -alpha1/(m_steps + 1))*
adapted_pow(fabs(dt2/dt3), -alpha2/(m_steps + 1));
t1 = 1/t1;
};
@ -58,6 +59,7 @@ public:
void operator()(T1 &t1, const T2 &t2)
{
t1 = adapted_pow(fabs(m_tol/t2), beta1/(m_steps + 1));
t1 = 1/t1;
};
@ -85,7 +87,7 @@ class State,
class Value = double,
class Time = double,
class Algebra = typename algebra_dispatcher< State >::algebra_type,
size_t Type = H211PI
size_t Type = BASIC
>
struct pid_step_adjuster
{
@ -95,6 +97,7 @@ public:
typedef State state_type;
typedef Value value_type;
typedef Time time_type;
typedef Algebra algebra_type;
typedef rotating_buffer<state_type, 3> error_storage_type;
@ -122,17 +125,17 @@ public:
pid_op<>(steps, m_tol, m_dt_storage[0], m_dt_storage[1], m_dt_storage[2], 0.7));
}
value_type ratio = 1/m_algebra.norm_inf(err);
value_type ratio = 1 / m_algebra.norm_inf(err);
value_type kappa = 1.0;
ratio = 1.0 + kappa*atan((ratio - 1)/kappa);
ratio = 1.0 + kappa*atan((ratio - 1) / kappa);
if(ratio*dt >= m_dtmax)
{
ratio = m_dtmax / dt;
}
if(ratio >= threshold() )
if(ratio >= threshold())
{
m_error_storage.rotate();
m_dt_storage.rotate();
@ -144,7 +147,7 @@ public:
m_init = 0;
}
return dt * static_cast<time_type> (ratio);
return dt * static_cast<time_type>(ratio);
};
private:
@ -160,8 +163,9 @@ private:
coeff_type m_coeff;
};
}
}
}
}
} // detail
} // odeint
} // numeric
} // boost
#endif

View File

@ -1,13 +1,12 @@
#ifndef PID_STEP_ADJUSTER_COEFFICIENTS_HPP_INCLUDED
#define PID_STEP_ADJUSTER_COEFFICIENTS_HPP_INCLUDED
#ifndef BOOST_NUMERIC_ODEINT_STEPPER_DETAIL_PID_STEP_ADJUSTER_COEFFICIENTS_HPP_INCLUDED
#define BOOST_NUMERIC_ODEINT_STEPPER_DETAIL_PID_STEP_ADJUSTER_COEFFICIENTS_HPP_INCLUDED
#include <boost/array.hpp>
namespace boost{
namespace numeric{
namespace odeint{
namespace detail{
namespace boost {
namespace numeric {
namespace odeint {
namespace detail {
enum adjuster_type{
BASIC,
@ -31,11 +30,11 @@ public:
pid_step_adjuster_coefficients()
: boost::array<double, 5>()
{
(*this)[0] = 1;
(*this)[1] = 0;
(*this)[2] = 0;
(*this)[3] = 0;
(*this)[4] = 0;
(*this)[0] = 1.0;
(*this)[1] = 0.0;
(*this)[2] = 0.0;
(*this)[3] = 0.0;
(*this)[4] = 0.0;
}
};
@ -46,11 +45,11 @@ public:
pid_step_adjuster_coefficients()
: boost::array<double, 5>()
{
(*this)[0] = 1.0/2.0;
(*this)[1] = 1.0/2.0;
(*this)[2] = 0;
(*this)[3] = 1.0/2.0;
(*this)[4] = 0;
(*this)[0] = 1.0 / 2.0;
(*this)[1] = 1.0 / 2.0;
(*this)[2] = 0.0;
(*this)[3] = 1.0 / 2.0;
(*this)[4] = 0.0;
}
};
@ -61,11 +60,11 @@ public:
pid_step_adjuster_coefficients()
: boost::array<double, 5>()
{
(*this)[0] = 1.0/5.0;
(*this)[1] = 2.0/5.0;
(*this)[2] = 0;
(*this)[3] = 1.0/5.0;
(*this)[4] = 0;
(*this)[0] = 1.0 / 5.0;
(*this)[1] = 2.0 / 5.0;
(*this)[2] = 0.0;
(*this)[3] = 1.0 / 5.0;
(*this)[4] = 0.0;
}
};
@ -76,11 +75,11 @@ public:
pid_step_adjuster_coefficients()
: boost::array<double, 5>()
{
(*this)[0] = 1.0/6.0;
(*this)[1] = 2.0/6.0;
(*this)[2] = 0;
(*this)[3] = 0;
(*this)[4] = 0;
(*this)[0] = 1.0 / 6.0;
(*this)[1] = 2.0 / 6.0;
(*this)[2] = 0.0;
(*this)[3] = 0.0;
(*this)[4] = 0.0;
}
};
@ -91,11 +90,11 @@ public:
pid_step_adjuster_coefficients()
: boost::array<double, 5>()
{
(*this)[0] = 1.0/4.0;
(*this)[1] = 2.0/2.0;
(*this)[2] = 1.0/4.0;
(*this)[3] = 3.0/4.0;
(*this)[4] = 1.0/4.0;
(*this)[0] = 1.0 / 4.0;
(*this)[1] = 2.0 / 2.0;
(*this)[2] = 1.0 / 4.0;
(*this)[3] = 3.0 / 4.0;
(*this)[4] = 1.0 / 4.0;
}
};
@ -106,11 +105,11 @@ public:
pid_step_adjuster_coefficients()
: boost::array<double, 5>()
{
(*this)[0] = 1.0/6.0;
(*this)[1] = 2.0/6.0;
(*this)[2] = 1.0/6.0;
(*this)[3] = 3.0/6.0;
(*this)[4] = 1.0/6.0;
(*this)[0] = 1.0 / 6.0;
(*this)[1] = 2.0 / 6.0;
(*this)[2] = 1.0 / 6.0;
(*this)[3] = 3.0 / 6.0;
(*this)[4] = 1.0 / 6.0;
}
};
@ -121,11 +120,11 @@ public:
pid_step_adjuster_coefficients()
: boost::array<double, 5>()
{
(*this)[0] = 1.0/18.0;
(*this)[1] = 2.0/9.0;
(*this)[2] = 1.0/18.0;
(*this)[3] = 0;
(*this)[4] = 0;
(*this)[0] = 1.0 / 18.0;
(*this)[1] = 2.0 / 9.0;
(*this)[2] = 1.0 / 18.0;
(*this)[3] = 0.0;
(*this)[4] = 0.0;
}
};
@ -136,11 +135,11 @@ public:
pid_step_adjuster_coefficients()
: boost::array<double, 5>()
{
(*this)[0] = 5.0/4.0;
(*this)[1] = 1.0/2.0;
(*this)[2] = -3.0/4.0;
(*this)[3] = -1.0/4.0;
(*this)[4] = -3.0/4.0;
(*this)[0] = 5.0 / 4.0;
(*this)[1] = 1.0 / 2.0;
(*this)[2] = -3.0 / 4.0;
(*this)[3] = -1.0 / 4.0;
(*this)[4] = -3.0 / 4.0;
}
};
@ -151,17 +150,17 @@ public:
pid_step_adjuster_coefficients()
: boost::array<double, 5>()
{
(*this)[0] = 1.0/3.0;
(*this)[1] = 1.0/18.0;
(*this)[2] = -5.0/18.0;
(*this)[3] = -5.0/16.0;
(*this)[4] = -1.0/6.0;
(*this)[0] = 1.0 / 3.0;
(*this)[1] = 1.0 / 18.0;
(*this)[2] = -5.0 / 18.0;
(*this)[3] = -5.0 / 16.0;
(*this)[4] = -1.0 / 6.0;
}
};
}
}
}
}
} // detail
} // odeint
} // numeric
} // boost
#endif