Class ode_control_gsl (o2scl)

O2scl : Class List

template<class vec_y_t = boost::numeric::ublas::vector<double>, class vec_dydx_t = vec_y_t, class vec_yerr_t = vec_y_t, class fp_t = double>
class ode_control_gsl

Control structure for astep_gsl.

This class implements both the “standard” and “scaled” step control methods from GSL. The standard control method is the default. To use the scaled control, set standard to false and set the scale for each component using set_scale().

The control object is a four parameter heuristic based on absolute and relative errors eps_abs and eps_rel, and scaling factors a_y and a_dydt for the system state \( y(t) \) and derivatives \( y^{\prime}(t) \) respectively.

The step-size adjustment procedure for this method begins by computing the desired error level \( D_i \) for each component. In the unscaled version,

\[ D_i = \mathrm{eps\_abs}+\mathrm{eps\_rel} \times \left( \mathrm{a\_y} | y_i| + \mathrm{a\_dydt}~h | y_i^{\prime}| \right) \]
while in the scaled version the user specifies the scale for each component, \( s_i \),
\[ D_i = \mathrm{eps\_abs}~s_i+\mathrm{eps\_rel} \times \left( \mathrm{a\_y} | y_i| + \mathrm{a\_dydt}~h | y_i^{\prime}| \right) \]

The desired error level \( D_i \) is compared to then observed error \( E_i = |\mathrm{yerr}_i| \). If the observed error \( E \) exceeds the desired error level \( D \) by more than 10 percent for any component then the method reduces the step-size by an appropriate factor,

\[ h_{\mathrm{new}} = S~h_{\mathrm{old}} \left(\frac{E}{D}\right)^{-1/q} \]
where \( q \) is the consistency order of the method (e.g. \( q=4 \) for 4(5) embedded RK), and \( S \) is a safety factor of 0.9. The ratio \( E/D \) is taken to be the maximum of the ratios \( E_i/D_i \).

If the observed error E is less than 50 percent of the desired error level \( D \) for the maximum ratio \( E_i/D_i \) then the algorithm takes the opportunity to increase the step-size to bring the error in line with the desired level,

\[ h_{\mathrm{new}} = S~h_{\mathrm{old}} \left(\frac{E}{D}\right)^{-1/(q+1)} \]
This encompasses all the standard error scaling methods. To avoid uncontrolled changes in the stepsize, the overall scaling factor is limited to the range 1/5 to 5.

If the user specified fewer scaling parameters than the number of ODEs, then the scaling parameters are reused as follows. If there are \( N \) ODEs and \( M \) scaling parameters, then for \( i>M \), the ith scaling parameter \( s_i \) is set to be \( s_{i\%M} \) . If the user selects the scaled control by setting standard to false and no scale parameters are specified, this class reverts to the standard control.

Todo:

Double check that the improvements in the ode-initval2 routines are available here

Adjustment specification

static const size_t hadj_nil = 0

No adjustment required.

static const size_t hadj_dec = 1

Recommend step decrease.

static const size_t hadj_inc = 2

Recommend step increase.

fp_t eps_abs

Absolute precision (default \( 10^{-6} \))

fp_t eps_rel

Relative precision (default 0)

fp_t a_y

Function scaling factor (default 1)

fp_t a_dydt

Derivative scaling factor (default 0)

bool standard

Use standard or scaled algorithm (default true)

inline ode_control_gsl()
inline virtual ~ode_control_gsl()
template<class svec_t>
inline int set_scale(size_t nscal, const svec_t &scale)

Set the scaling for each differential equation.

inline virtual int hadjust(size_t dim, unsigned int ord, const vec_y_t &y, vec_yerr_t &yerr, vec_dydx_t &yp, fp_t &h)

Public Types

typedef boost::numeric::ublas::vector<fp_t> ubvector

Protected Attributes

ubvector scale_abs

Scalings.