The classes and methods defined here allow the integration of a set of simultaneous ordinary differential equations (ODEs) of a real variable.
ODEvectorVector 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.)
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.
Vector rkint(const double x1, const double x2, const Vector& f1) const
Array<Vector> rkinthist(const double x1, const double x2, const Vector& f1) const
Vector rkaccint(
// Data in:
const double x1, // start of interval (initial function values known)
const double x2, // end of interval (function values to be calculated)
const Vector& f1, // initial function values
// Data out:
int& nsteps, // number of integration steps needed
int& hitmax, // true if reached max iterations
int& underflow // true if space step became too small
) const
Vector rkaccint(
const double x1, // start of interval (initial function values known)
const double x2, // end of interval (function values to be calculated)
const Vector& f1 // initial function values
) const
Vector rksaccint(
// Data in:
const double x1, // start of interval (initial function values known)
const double x2, // end of interval (function values to be calculated)
const Vector& f1, // initial function values
// Data out:
int& nsteps, // number of integration steps needed
int& hitmax, // true if reached max iterations
int& underflow, // true if space step became too small
int& earlystop, // true if stopped on `stop now' condition
double& xearly // position of early stop
) const
Uses a gradient function of the following form:
Vector dfdx(const double x, const Vector& f, int& stopnow, int& toofar) constwhere
stopnow is returned as 1 to stop the integration,
and toofar is returned as 1 if the integration has proceeded
too far.
A default gradient function of this form is defined, calling the simple gradient function described above and checking the state with a call to a function
void statechk(const double x, const Vector& f, int& stopnow, int& toofar) constA default
statechk is defined which always returns zero
for stopnow and toofar.
Array<Vector> rkaccinthist( // Data in: const double x1, // start of interval (initial function values known) const double x2, // end of interval (function values to be calculated) const Vector& f1, // initial function values // Data out: int& nsteps, // number of integration steps needed int& hitmax, // true if reached max iterations int& underflow, // true if space step became too small int& earlystop // true if stopped on `stop now' condition ) constEach element of the array of returned vectors is a vector whose first element is the ordinate
x at that point and the remaining elements
are the function values.
The flexible stop condition is as above, with the addition of a test based on the state history:
void histchk(const List<Vector>& fhist, int& stopnow, int& toofar) constwhere
fhist is the saved history so far.
A default histchk is defined which always returns zero
for stopnow and toofar.
Array<Vector> rkaccinthist(
const double x1, // start of interval (initial function values known)
const double x2, // end of interval (function values to be calculated)
const Vector& f1 // initial function values
) const