Ode Class Template Reference

Class template integrates ordinary differential equations. More...

#include <Ode.h>

Inherits Base.

Inheritance diagram for Ode:

Inheritance graph
[legend]
List of all members.

Public Types

 CURRENT = 0
 MAXIMUM
 VARIABLE
enum  VTYPE { CURRENT = 0, MAXIMUM, VARIABLE, VTYPE_CNT }
 VTYPE_CNT

Public Member Functions

yType * eval (yType *y, xType x1, xType x2, xType dx) throw (OdeErr)
int getCount (enum Ode< xType, yType >::VTYPE vType) const
void getDerivative (yType *dy, yType *y, xType x) const
xType getError (void) const
 Ode (const Ode &od)
 Ode (void(&pFn)(yType *, yType *, xType), xType dEps, int nVar)
bool setCount (int nMaximum)
bool setEpsilon (xType dEps)
 ~Ode (void)

Static Public Attributes

static const int DEF_LOOP_MAX = 10000
static const int STEP_CNT = 6

Detailed Description

template<typename xType, typename yType>
class calc::Ode< xType, yType >

Class template integrates ordinary differential equations.

This class template integrates user-defined ordinary differential equations (ode) using a fifth-order Cash-Karp embedded Runge-Kutta method with fourth-order evaluations to estimate error.

The declaration typename <xType> specifies the form of independent variables used in integration calculations. The declaration typename <yType> specifies the form of solution variables used in integration calculations. In general, the <yType> variables should be the equal or superset of the <xType> variables.

See the cited References to obtain more information on the mathematical theory applied here.

Author
efgeorge
Date
2006/07/18 01:45:34
Revision
1.2
Examples:

example_Ode.txt.


Member Enumeration Documentation

enum VTYPE

Enumeration indicates the variable index of the integer value.

Enumerator:
CURRENT  index of the current loop count used in the last integration evaluation step
MAXIMUM  index of the current maximum loop count used in the integration evaluation
VARIABLE  index of the number of specified integration variables used in the integration evaluation
VTYPE_CNT  variable type index count


Constructor & Destructor Documentation

Ode ( void(&)(yType *, yType *, xType)  rFn,
xType  dEps,
int  nVar 
)

Constructor initializes an ordinary differential equation integration object.

Parameters:
rFn a reference to a derivative evaluation function
dEps required error of the calculated integral (|y| units)
nVar number of integration variables
Remarks:
  • The specified integration tolerance dEps must be greater than zero.
  • The specified integration variable count nVar must be greater than zero.
  • The specified function rFn(dy,y,x) calculates nVar derivatives dy defined by the state variables x and y (see Ode::getDerivatives()).
  • Array formats maintain sequential order for the integration variables.
  • Function declaration: void fn(yType *dy, yType *y, xType x);
  • Function input array declarations: yType dy[nVar], y[nVar];

Ode ( const Ode< xType, yType > &  od  ) 

Copy constructor initializes an ordinary differential equation integration object from the specified existing integration object.

Parameters:
od a reference to an ordinary differential equation integration object

~Ode ( void   ) 

Destructor frees allocated memory.


Member Function Documentation

yType * eval ( yType *  y,
xType  x1,
xType  x2,
xType  dx 
) throw (OdeErr)

Function integrates the defined ordinary differential equation using 5th-order Cash-Karp embedded Runge-Kutta equations with 4th-order evaluation to estimate error.

Parameters:
x1 starting bound for independent variable (x units)
x2 ending bound for independent variable (x units)
dx step size initialization value (x units)
y a pointer to an initialized starting values array for the dependent variables evaluated at point x1; these values are overwritten with the calculated ending values array for dependent variable evaluated at point x2 (y units)
Returns:
the value of pointer y
Exceptions:
OdeErr type of object thrown
Remarks:
  • The function integrates between the specified independent variable bounds x1 and x2 using the suggested step size dx.
  • The array pointer y must store the number of values equal to the number of integration variable specified in the object's constructor with variable nVar (see Ode::Ode()).
  • The array y must have initialized values corresponding to x1. These values are overwritten on function return.
  • Array y declaration: yType y[nVar];

int getCount ( enum Ode< xType, yType >::VTYPE  vType  )  const

Function returns variable information or loop information pertaining to algorithm iterations.

Parameters:
vType variable index indentifying the type of data
Returns:
the loop count property of the object
Remarks:
  • Valid loop or variable values should be above 0.
  • If the object is not initialized, -1 is returned.
  • If the object does not have the variable identified by vType, -1 is returned.

void getDerivative ( yType *  dy,
yType *  y,
xType  x 
) const

Function evaluates the user specified derivative function at the specified x and y values.

Parameters:
x value at which to evaluate the differential equation (x units)
y a pointer to an array of dependent values which define the differential equation at value x (y units)
dy a pointer to the calculated derivatives of y values at value x (y units/x units)
Remarks:
  • The array pointers dy and y must be able to store the number of values equal to the number of integration variable specified in the object's constructor with variable nVar (see Ode::Ode()).
  • Array dy declaration: yType dy[nVar];
  • Array y declaration: yType y[nVar];

xType getError ( void   )  const

Function returns the current error criterion used in the integration evaluation.

Returns:
the fractional error tolerance of integration values (|y|)

bool setCount ( int  nMaximum  ) 

Function sets the current maximum loop count used in the integration evaluation.

Parameters:
nMaximum the maximum loop count value
Returns:
status flag
  • false (successful execution)
  • true (execution error, parameter not set)
Remarks:
The loop count value of nMaximum must be greater than zero.

bool setEpsilon ( xType  dEps  ) 

Function sets the current fractional error criterion used in the integration evaluation.

Parameters:
dEps fractional error tolerance of the integration values (|y| units)
Returns:
status flag
  • false (successful execution)
  • true (execution error, parameter not set)
Remarks:
The tolerance value of dEps must be greater than zero.


Member Data Documentation

const int DEF_LOOP_MAX = 10000 [static]

default maximum iteration loop count

const int STEP_CNT = 6 [static]

Runge-Kutta algorithm step count value


The documentation for this class was generated from the following files:
Generated on Wed Jul 19 09:24:19 2006 for CalcLib by  doxygen 1.4.7