Next: , Previous: Defining the ODE System, Up: Ordinary Differential Equations


26.2 Stepping Functions

The lowest level components are the stepping functions which advance a solution from time t to t+h for a fixed step-size h and estimate the resulting local error.

— Function: gsl_odeiv2_step * gsl_odeiv2_step_alloc (const gsl_odeiv2_step_type * T, size_t dim)

This function returns a pointer to a newly allocated instance of a stepping function of type T for a system of dim dimensions. Please note that if you use a stepper method that requires access to a driver object, it is advisable to use a driver allocation method, which automatically allocates a stepper, too.

— Function: int gsl_odeiv2_step_reset (gsl_odeiv2_step * s)

This function resets the stepping function s. It should be used whenever the next use of s will not be a continuation of a previous step.

— Function: void gsl_odeiv2_step_free (gsl_odeiv2_step * s)

This function frees all the memory associated with the stepping function s.

— Function: const char * gsl_odeiv2_step_name (const gsl_odeiv2_step * s)

This function returns a pointer to the name of the stepping function. For example,

          printf ("step method is '%s'\n",
                   gsl_odeiv2_step_name (s));

would print something like step method is 'rkf45'.

— Function: unsigned int gsl_odeiv2_step_order (const gsl_odeiv2_step * s)

This function returns the order of the stepping function on the previous step. The order can vary if the stepping function itself is adaptive.

— Function: int gsl_odeiv2_step_set_driver (gsl_odeiv2_step * s, const gsl_odeiv2_driver * d)

This function sets a pointer of the driver object d for stepper s, to allow the stepper to access control (and evolve) object through the driver object. This is a requirement for some steppers, to get the desired error level for internal iteration of stepper. Allocation of a driver object calls this function automatically.

— Function: int gsl_odeiv2_step_apply (gsl_odeiv2_step * s, double t, double h, double y[], double yerr[], const double dydt_in[], double dydt_out[], const gsl_odeiv2_system * sys)

This function applies the stepping function s to the system of equations defined by sys, using the step-size h to advance the system from time t and state y to time t+h. The new state of the system is stored in y on output, with an estimate of the absolute error in each component stored in yerr. If the argument dydt_in is not null it should point an array containing the derivatives for the system at time t on input. This is optional as the derivatives will be computed internally if they are not provided, but allows the reuse of existing derivative information. On output the new derivatives of the system at time t+h will be stored in dydt_out if it is not null.

The stepping function returns GSL_FAILURE if it is unable to compute the requested step. Also, if the user-supplied functions defined in the system sys return a status other than GSL_SUCCESS the step will be aborted. In that case, the elements of y will be restored to their pre-step values and the error code from the user-supplied function will be returned. Failure may be due to a singularity in the system or too large step-size h. In that case the step should be attempted again with a smaller step-size, e.g. h/2.

If the driver object is not appropriately set via gsl_odeiv2_step_set_driver for those steppers that need it, the stepping function returns GSL_EFAULT. If the user-supplied functions defined in the system sys returns GSL_EBADFUNC, the function returns immediately with the same return code. In this case the user must call gsl_odeiv2_step_reset before calling this function again.

The following algorithms are available,

— Step Type: gsl_odeiv2_step_rk2

Explicit embedded Runge-Kutta (2, 3) method.

— Step Type: gsl_odeiv2_step_rk4

Explicit 4th order (classical) Runge-Kutta. Error estimation is carried out by the step doubling method. For more efficient estimate of the error, use the embedded methods described below.

— Step Type: gsl_odeiv2_step_rkf45

Explicit embedded Runge-Kutta-Fehlberg (4, 5) method. This method is a good general-purpose integrator.

— Step Type: gsl_odeiv2_step_rkck

Explicit embedded Runge-Kutta Cash-Karp (4, 5) method.

— Step Type: gsl_odeiv2_step_rk8pd

Explicit embedded Runge-Kutta Prince-Dormand (8, 9) method.

— Step Type: gsl_odeiv2_step_rk1imp

Implicit Gaussian first order Runge-Kutta. Also known as implicit Euler or backward Euler method. Error estimation is carried out by the step doubling method. This algorithm requires the Jacobian and access to the driver object via gsl_odeiv2_step_set_driver.

— Step Type: gsl_odeiv2_step_rk2imp

Implicit Gaussian second order Runge-Kutta. Also known as implicit mid-point rule. Error estimation is carried out by the step doubling method. This stepper requires the Jacobian and access to the driver object via gsl_odeiv2_step_set_driver.

— Step Type: gsl_odeiv2_step_rk4imp

Implicit Gaussian 4th order Runge-Kutta. Error estimation is carried out by the step doubling method. This algorithm requires the Jacobian and access to the driver object via gsl_odeiv2_step_set_driver.

— Step Type: gsl_odeiv2_step_bsimp

Implicit Bulirsch-Stoer method of Bader and Deuflhard. The method is generally suitable for stiff problems. This stepper requires the Jacobian.

— Step Type: gsl_odeiv2_step_msadams

A variable-coefficient linear multistep Adams method in Nordsieck form. This stepper uses explicit Adams-Bashforth (predictor) and implicit Adams-Moulton (corrector) methods in P(EC)^m functional iteration mode. Method order varies dynamically between 1 and 12. This stepper requires the access to the driver object via gsl_odeiv2_step_set_driver.

— Step Type: gsl_odeiv2_step_msbdf

A variable-coefficient linear multistep backward differentiation formula (BDF) method in Nordsieck form. This stepper uses the explicit BDF formula as predictor and implicit BDF formula as corrector. A modified Newton iteration method is used to solve the system of non-linear equations. Method order varies dynamically between 1 and 5. The method is generally suitable for stiff problems. This stepper requires the Jacobian and the access to the driver object via gsl_odeiv2_step_set_driver.