Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   Related Pages  

rdIntegRKF Class Reference

A class for integrating the equations of motion of a dynamic system. More...

#include <rdIntegRKF.h>

Inheritance diagram for rdIntegRKF:

rdRKF List of all members.

Public Member Functions

 rdIntegRKF (rdModel *aModel=NULL, double aTol=1.0e-4, double aTolFine=-1.0)
 Constructs an rdIntegRKF based on the specified model and integration tolerance.

virtual ~rdIntegRKF ()
 Destructor.

void setMinDT (double aMin)
 Set the minimum integration step size.

double getMinDT ()
 Get the maximum number of integration steps.

void setMaxDT (double aMax)
 Set the maximum integration step size.

double getMaxDT ()
 Get the maximum number of integration steps.

void setMaximumNumberOfSteps (int aMaxSteps)
 Set the maximum number of integration steps.

int getMaximumNumberOfSteps ()
 Get the maximum number of integration steps.

int getStatus ()
 Get the status of the integrator.

void setUseSpecifiedDT (bool aTrueFalse)
 Set whether or not to take a specified sequence of deltas during an integration.

bool getUseSpecifiedDT () const
 Get whether or not to take a specified sequence of deltas during an integration.

void setUseConstantDT (bool aTrueFalse)
 Set whether or not to take a constant integration time step.

bool getUseConstantDT () const
 Get whether or not to use a constant integration time step.

void setDT (double aDT)
 Set the fixed time step to be taken when the integrator is set to take a constant time step and when appropriate time steps are not available in the time vector.

double getDT () const
 Get the fixed time step to be taken when the integrator is set to take a fixed time step and when appropriate time steps are not available in the time vector.

const rdArray< double > & getDTArray ()
 Get the time deltas used in the last integration.

void setDTArray (int aN, const double aDT[], double aTI=0.0)
 Set the deltas held in the dt array.

double getDTArrayDT (int aStep)
 Get the delta used for a specified integration step.

void printDTArray (const char *aFileName=NULL)
 Print the dt array.

const rdArray< double > & getTimeArray ()
 Get the sequence of time steps taken in the last integration.

double getTimeArrayTime (int aStep)
 Get the time of a specified integration step.

int getTimeArrayStep (double aTime)
 Get the integration step (index) that occured prior to or at a specified time.

void printTimeArray (const char *aFileName=NULL)
 Print the time array.

void resetTimeAndDTArrays (double aTime)
 Reset the time and dt arrays so that all times after the specified time and the corresponding deltas are erased.

void setControlStorage (rdStorage *aStorage)
 Set the storage buffer for the integration controls.

rdStoragegetControlStorage ()
 Get the storage buffer for the integration controls.

void setStateStorage (rdStorage *aStorage)
 Set the storage buffer for the integration states.

rdStoragegetStateStorage ()
 Get the storage buffer for the integration states.

void setPseudoStateStorage (rdStorage *aStorage)
 Set the storage for the pseudostates.

rdStoragegetPseudoStateStorage ()
 Get the storage for the pseudostates.

void setController (rdController *aController)
 Set a controller for this integration.

rdControllergetController ()
 Get the dynamic filter.

bool integrate (double ti, double tf, rdControlSet &x, double *y, double dtFirst=1.0e-3)
 Integrate the equations of motion from an initial time to a final time.

void halt ()
 Halt an integration.

void clearHalt ()
 Clear the halt flag.

bool checkHalt ()
 Check for a halt request.


Private Member Functions

void setNull ()
 Constructs an rdIntegRKF based on the specified model and integration tolerance.


Private Attributes

rdController_controller
 Controller for the simulation.

int _status
 Status of the integration.

int _steps
 Number of integration steps successfully taken.

int _trys
 Number of integration step trys.

int _maxSteps
 Maximum number of steps in an integration.

bool _halt
 Flag for signaling a desired halt.

double _dtMin
 Minimum step size.

double _dtMax
 Maximum step size.

double * _x
 Array of control values at the current time.

double * _xPrev
 Array of control values at the previous integration time step.

double * _yPrev
 Array of state values at the previous integration time step.

double * _yp
 Array of pseudo states.

bool _specifiedDT
 Flag to indicate whether or not specified integration time steps should be used.

bool _constantDT
 Flag to indicate whether or not constant (fixed) integration time steps should be used.

double _dt
 Constant integration time step.

rdArray< double > _tArray
 Vector of integration time steps.

rdArray< double > _dtArray
 Vector of integration time step deltas.

rdStorage_controlStorage
 Storage for the controls.

rdStorage_stateStorage
 Storage for the states.

rdStorage_pseudoStorage
 Storage for the pseudostates.


Detailed Description

A class for integrating the equations of motion of a dynamic system.

This class performs the relatively high-level tasks during an integration and implements the logic for when to reduce the integration step size or increase it. This class sits on top of class rdRKF which implements the low-level numerics for computing the derivatives and taking the states one step forward in time. RKF means Runge-Kutta-Feldberg. See rdRKF for details.

The user must supply a valid pointer to an rdModel on construction.


Member Function Documentation

bool rdIntegRKF::checkHalt  ) 
 

Check for a halt request.

The value of the halt flag is simply returned.

void rdIntegRKF::clearHalt  ) 
 

Clear the halt flag.

The value of the interrupt flag is set to false.

rdController * rdIntegRKF::getController  ) 
 

Get the dynamic filter.

Returns:
Controller set for this model. If no controller is set NULL is returned.

double rdIntegRKF::getDT  )  const
 

Get the fixed time step to be taken when the integrator is set to take a fixed time step and when appropriate time steps are not available in the time vector.

Returns:
Fixed time step.
See also:
setFixed()

getTimeVector()

const rdArray< double > & rdIntegRKF::getDTArray  ) 
 

Get the time deltas used in the last integration.

Returns:
Constant reference to the dt array.

double rdIntegRKF::getDTArrayDT int  aStep  ) 
 

Get the delta used for a specified integration step.

For step aStep, the delta returned is the delta used to go from step aStep to step aStep+1.

Parameters:
aStep Index of the desired step.
Returns:
Delta. rdMath::NAN is returned on error.

int rdIntegRKF::getTimeArrayStep double  aTime  ) 
 

Get the integration step (index) that occured prior to or at a specified time.

Parameters:
aTime Time of the integration step.
Returns:
Step that occured prior to or at aTime. 0 is returned if there is no such time stored.

double rdIntegRKF::getTimeArrayTime int  aStep  ) 
 

Get the time of a specified integration step.

Parameters:
aStep Index of the desired step.
Returns:
Time of integration step aStep. rdMath::NAN is returned on error.

bool rdIntegRKF::getUseConstantDT  )  const
 

Get whether or not to use a constant integration time step.

The constant integration time step can be set using setDT().

Returns:
If true, constant time steps are used. If false, either specified or variable time steps are used.
See also:
setDT()

getUseSpecifiedDTs();

bool rdIntegRKF::getUseSpecifiedDT  )  const
 

Get whether or not to take a specified sequence of deltas during an integration.

The time deltas are obtained from what's stored in the dt vector (

See also:
setDTVector()). In order to execute an integration in this manner, the sum of the deltas must cover any requested integration interval. If not, an exception will be thrown at the beginning of an integration.
Returns:
If true, a specified time step will be used if possible. If false, a variable-step integration will be performed or a constant time step will be taken.
See also:
getUseConstantDT()

getDT()

getTimeVector()

void rdIntegRKF::halt  ) 
 

Halt an integration.

If an integration is pending or executing, the value of the interrupt flag is set to true.

bool rdIntegRKF::integrate double  ti,
double  tf,
rdControlSet x,
double *  y,
double  dtFirst = 1.0e-3
 

Integrate the equations of motion from an initial time to a final time.

The initial values of the states must already be set for the model.

Parameters:
ti Initial time.
tf Final time.
controlSet Controls.
y States.
dtFirst Size of the first time step.
Returns:
true on successful completion of the integration, false otherwise. Use getStatus() to querry the nature of the error.

void rdIntegRKF::printTimeArray const char *  aFileName = NULL  ) 
 

Print the time array.

Parameters:
aFileName Name of the file to which to print. If the time array cannot be written to a file of the specified name, the time array is wirttent to standard out.

void rdIntegRKF::resetTimeAndDTArrays double  aTime  ) 
 

Reset the time and dt arrays so that all times after the specified time and the corresponding deltas are erased.

Parameters:
aTime Time after which to erase the entries in the time and dt vectors.

void rdIntegRKF::setController rdController aController  ) 
 

Set a controller for this integration.

If one is set, the controller will be called each integration step to determine a set of controls for controlling the current model.

Parameters:
aController Controller. To remove the controller, set the controller to NULL.

void rdIntegRKF::setDT double  aDT  ) 
 

Set the fixed time step to be taken when the integrator is set to take a constant time step and when appropriate time steps are not available in the time vector.

Parameters:
aDT Fixed time step.
See also:
setFixed()

getTimeVector()

void rdIntegRKF::setDTArray int  aN,
const double  aDT[],
double  aTI = 0.0
 

Set the deltas held in the dt array.

These deltas will be used if the integrator is set to take a specified set of deltas. In order to integrate using a specified set of deltas, the sum of deltas must cover the requested integration time interval, otherwise an exception will be thrown at the beginning of an integration.

Note that the time vector is reconstructed in order to check that the sum of the deltas covers a requested integration interval.

Parameters:
aN Number of deltas.
aDT Array of deltas.
aTI Initial time. If not specified, 0.0 is assumed.
See also:
getUseSpecifiedDT()

void rdIntegRKF::setUseConstantDT bool  aTrueFalse  ) 
 

Set whether or not to take a constant integration time step.

The size of the constant integration time step can be set using setDT().

Parameters:
aTrueFalse If true, constant time steps are used. When set to true, the flag used to indicate whether or not to take specified time steps is set to false. If set to false, a variable-step integration or a constant integration time step will be used.
See also:
setDT()

setUseSpecifiedDT()

getUseSpecifiedDT();

void rdIntegRKF::setUseSpecifiedDT bool  aTrueFalse  ) 
 

Set whether or not to take a specified sequence of deltas during an integration.

The time deltas are obtained from what's stored in the vector dt vector (

See also:
setDTVector()). In order to execute an integration in this manner, the sum of the deltas must cover any requested integration interval. If not, an exception will be thrown at the beginning of an integration.
Parameters:
aTrueFalse If true, a specified dt's will be used. If set to false, a variable-step integration or a constant step integration will be used. When set to true, the flag used to indicate whether or not a constant time step is used is set to false.
See also:
setDTVector()

getUseConstantDT()


Member Data Documentation

bool rdIntegRKF::_constantDT [private]
 

Flag to indicate whether or not constant (fixed) integration time steps should be used.

The constant integration time step is set using setDT().

bool rdIntegRKF::_specifiedDT [private]
 

Flag to indicate whether or not specified integration time steps should be used.

The specified integration time steps are held in _tVec. If _tVec does not contain time steps appropriate for the integration, an exception is thrown.


The documentation for this class was generated from the following files:
Generated on Wed Aug 20 02:17:11 2003 for Simulation Software by doxygen1.3