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

OSCAR::RK4 Class Reference
[Math]

fixed step size Runge Kutta Integrator Used to integrate ODEs in a manner similar to ode45 in matlab More...

#include <RK4.h>

Inheritance diagram for OSCAR::RK4:

Inheritance graph
[legend]
List of all members.

Public Methods

 RK4 ()
 RK4 (const RK4 &rhs)
RK4 & operator= (const RK4 &rhs)
virtual ~RK4 ()
Matrix NumIntegrate (Vector(*function)(double t, Vector x), Vector &x0)
void SetTimes (double tbegin=0, double tend=10)
void SetStepSize (double timestep=0.1)
double GetTimeEnd ()
double GetStepSize ()
unsigned int ResultLength ()

Protected Attributes

double tbegin
double tend
double timestep

Detailed Description

Author:
Jeremy Sevier


Constructor & Destructor Documentation

OSCAR::RK4::RK4  
 

Default Contructor.

Constructs an RK4 object

OSCAR::RK4::RK4 const RK4 &    rhs
 

Copy Contructor.

Constructs a copy of an RK4 object from an existing RK4 object

virtual OSCAR::RK4::~RK4   [virtual]
 

Virtual Destructor.

This is the Destructor for an object of type RK4.


Member Function Documentation

double OSCAR::RK4::GetStepSize  
 

used to get the time step over which we integrate

Returns:
The function returns a double which has the time step of the ODE.

double OSCAR::RK4::GetTimeEnd  
 

used to get the time through which we integrate

Returns:
The function returns a double which has the final time of the ODE.

Matrix OSCAR::RK4::NumIntegrate Vector(*    function)(double t, Vector x),
Vector   x0
 

Numerical Integator which takes a function pointer as its argument. The function must be declared as shown (for example:Vector feval(double tt,Vector xx);) could be the function prototype, where xx are the states and tt is the time. Vector &x0 are the initial conditions for states.Here is a sample function:.

Vector VanDerPol(double t,Vector xx){ Vector xdot(2); xdot[0] = 5*(1-xx[1]*xx[1])*xx[0] - xx[1];//xddot xdot[1] = xx[0];//xdot return xdot;}

Which can be called as: NumIntegrate(VanDerPol,x0);

The matrix NumIntegrate returns is of size (ResultLength,ODE + 1). Use the result length function after setting the times and step size to get the number of rows for the matrix, the columns contain ODE + 1 because the matrix integrates all of the states, but also in the first column of the returned matrix will be the time vector.

Parameters:
function takes an ODE function to integrate. This function is dependent on x and t, where x is a vector of states and t is a time variable. This function returns the derivative of the states. See the Van Der Pol example above for a second order function example.
Vector &x0 is a vector of initial conditions for the ODE.
Returns:
Matrix the first column of which is the time vector, the the rest of the columns are the integrated solution to the ODE. Use ResultLength() to get the number of rows for the matrix, the the number of columns should be one greater than the size of the initial conditions.

RK4& OSCAR::RK4::operator= const RK4 &    rhs
 

= operator. Used for copying objects of type RK4

Returns:
A reference to the object on the left hand side of the = operator
Parameters:
rhs An RK4 object that goes on the right hand side of the = operator

unsigned int OSCAR::RK4::ResultLength  
 

used to get the length of the solution vector this is used to get the number of rows for the solution matrix in NumIntegrate

Returns:
The function returns a int which has the number of rows of the solution.

void OSCAR::RK4::SetStepSize double    timestep = 0.1
 

used to set time step size for integration The default is 0.1.

Parameters:
timestep is a double which takes the step time for the ODE.

void OSCAR::RK4::SetTimes double    tbegin = 0,
double    tend = 10
 

used to set times for starting and ending integration The default is to begin at time zero and end at 10, but anyting can be used.

Parameters:
tbegin is a double which takes the starting time.
tend is a double which takes the ending time.


Member Data Documentation

double OSCAR::RK4::tbegin [protected]
 

double OSCAR::RK4::tend [protected]
 

double OSCAR::RK4::timestep [protected]
 


The documentation for this class was generated from the following file:
RRG Homepage OSCAR Overview OSCAR Tutorials Simulations