Integration of ordinary differential equations

Header file odeint.h

The classes and methods defined here allow the integration of a set of simultaneous ordinary differential equations (ODEs) of a real variable.

Classes to define and integrate functions

ODE integrator class, ODEvector

Expects subclasses to define a vector function of a real number and a real vector, which is the set of simultaneous ODEs. To integrate the set of functions, the class is used as follows:
  1. Define a subclass which inherits from this class for the particular ODE to be solved.
  2. Define a method in the class to evaluate the gradients given the ordinate and a vector of parameters:
       Vector dfdx(const double x, const Vector& f) const
       
    (This is the most simple form. Some of the integration methods can use more information, as described below.)
  3. Set control parameters for the integration. The control parameters (constituents of the ODEvector class) are:
    int verbose; // 1 or higher for diagnostic output
    double acc; // accuracy, e.g. 1.0e-8
    int nsugsteps; // suggested integration steps, e.g. 10
    int maxsteps; // max integration steps; 0 => no limit
    double eps; // bandwidth, e.g. 1.0e-10
    double sfac; // step change safety factor, e.g. 0.9
       

    There is a call to set defaults, the unimaginatively-named

       set_defaults();
       
    The defaults are:
       verbose = 0;
       acc = 1.0e-8;
       nsugsteps = 10;
       maxsteps = 0;
       eps = 1.0e-10;
       sfac = 0.9;
       
    and methods Read_parameters(istream &) and Write_parameters(ostream &) to read and write the parameters (in the same order) to/from an ASCII stream.

    The control parameters are publicly-aceessible, and can also be set individually.

  4. Call the appropriate integration method: