Public Types | Public Member Functions | Public Attributes | Protected Attributes | List of all members
o2scl::ode_control_gsl< vec_y_t, vec_dydx_t, vec_yerr_t > Class Template Reference

Control structure for astep_gsl. More...

#include <astep_gsl.h>

Public Types

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

Public Member Functions

template<class svec_t >
int set_scale (size_t nscal, const svec_t &scale)
 Set the scaling for each differential equation.
virtual int hadjust (size_t dim, unsigned int ord, const vec_y_t &y, vec_yerr_t &yerr, vec_dydx_t &yp, double &h)

Public Attributes

double eps_abs
 Absolute precision (default $ 10^{-6} $)
double eps_rel
 Relative precision (default 0)
double a_y
 Function scaling factor (default 1)
double a_dydt
 Derivative scaling factor (default 0)
bool standard
 Use standard or scaled algorithm (default true)

Static Public Attributes

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.

Protected Attributes

ubvector scale_abs

Detailed Description

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 o2scl::ode_control_gsl< vec_y_t, vec_dydx_t, vec_yerr_t >

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.

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

Definition at line 130 of file astep_gsl.h.

The documentation for this class was generated from the following file:

Documentation generated with Doxygen. Provided under the GNU Free Documentation License (see License Information).