smtk::rk4< X, T, TS > Class Template Reference

First order ODE solver
Reference Tutorial Example Code
smtk::rk4 4th order Runge-Kutta ODE solver
sine_rk4.cpp
damped_SHO.cpp
damped_pendulum.cpp
lotka_volterra.cpp
multi_plot.cpp
. More...

Inheritance diagram for smtk::rk4< X, T, TS >:

Inheritance graph
[legend]
List of all members.

Public Member Functions

TS get_current_t (void) const
int get_num_diff_eq (void) const
TS get_t_step (void) const
go (X *x, T t_to)
 Advance to a given time.
go (X *x, T t_to, T t_from)
 Advance to a given time.
go (X *x)
 Advance one time step.
void go (X *x, T *t)
 Advance one time step.
bool is_invalid (void) const
 see if the object is invalid
bool is_valid (void) const
 see if the object is valid
 rk4 (void(*difeq)(X *xdot, const X *x, T t), int num_diffeq, TS tstep, T t_0=(T) 0.0)
void set_current_t (T t)
 Set the current time.
TS set_t_step (TS tstep_in)
 Set the time step.
virtual ~rk4 (void)

Protected Member Functions

template<class T>
invalidate (T t)
 invalidate the object
void invalidate (void)
 invalidate the object
template<class T>
validate (T t)
 validate the object
void validate (void)
 validate the object

Detailed Description

template<class X, class T, class TS>
class smtk::rk4< X, T, TS >

First order ODE solver
Reference Tutorial Example Code
smtk::rk4 4th order Runge-Kutta ODE solver
sine_rk4.cpp
damped_SHO.cpp
damped_pendulum.cpp
lotka_volterra.cpp
multi_plot.cpp
.

A 4th order Runge-Kutta ordinary differential equation (ODE) solver. The solver step size is fixed, but you may request the solution at any time and it will do the looping for you and evolve the solution up to your requested time.

X is the data type of the dependent state variables.

T is the data type of the independent variable, here-in refered to as time.

TS is the data type of the independent vailable step size, here-in refered to as time step. You may in some cases want T to be a higher precession (like long double) than TS (double) in order to be able keep round off small when the independent variable (time) becomes large.

The class smtk::validation is inherited and will be set invalid only if memory allocation fails, which could happen if you have a large number of ODEs to solve, and this can only happen in the constructor of smtk::rk4.


Constructor & Destructor Documentation

template<class X, class T, class TS>
smtk::rk4< X, T, TS >::rk4 ( void(*)(X *xdot, const X *x, T t)  difeq,
int  num_diffeq,
TS  tstep,
t_0 = (T) 0.0 
) [inline]

Parameters:
difeq is a pointer to the function that computes the derivatives with respect to the independent variable. xdot is the array of derivatives that difeq will compute when called and t is the time that will be passed to the function difeq when it is called. difeq will be called many times when rk4::go() is called.
num_diffeq is the number of first order ODEs that are in difeq.
tstep is the step size used by the 4th order Runge-Kutta solver for each interation. Of course, smaller step size will be used if the requested independent variable value is less than the current independent variable value minus the step size.
t_0 is the initial value of the independent variable.

template<class X, class T, class TS>
smtk::rk4< X, T, TS >::~rk4 ( void   )  [inline, virtual]

Frees memory that was explictly allocated.


Member Function Documentation

template<class X, class T, class TS>
TS smtk::rk4< X, T, TS >::get_current_t ( void   )  const [inline]

Returns:
the current time.

template<class X, class T, class TS>
int smtk::rk4< X, T, TS >::get_num_diff_eq ( void   )  const [inline]

Returns:
the number of first order ODEs.

template<class X, class T, class TS>
TS smtk::rk4< X, T, TS >::get_t_step ( void   )  const [inline]

Returns:
the current single interation time step.

template<class X, class T, class TS>
T smtk::rk4< X, T, TS >::go ( X *  x,
t_to 
) [inline]

Advance to a given time.

Advance the state pointed to by x to a state with time t_to. The current time will be that which was the last time the system had evolved to.

Parameters:
x a pointer to an array with the current state. The values in this array will be changed to the new state.
t_to time to advance to.
Returns:
the new time, which is also the value of t_to.

template<class X, class T, class TS>
T smtk::rk4< X, T, TS >::go ( X *  x,
t_to,
t_from 
) [inline]

Advance to a given time.

Advance the state pointed to by x to a state with time t_to given the the current time is t_from.

Parameters:
x a pointer to an array with the current state. The values in this array will be changed to the new state.
t_to time to advance to.
t_from time to advance from.
Returns:
the new time, which is also the value of t_to.

template<class X, class T, class TS>
T smtk::rk4< X, T, TS >::go ( X *  x  )  [inline]

Advance one time step.

Advance the state pointed to by x and t to a state with time *t plus the current single interation time step.

Parameters:
x a pointer to an array with the current state. The values in this array will be changed to the new state.
Returns:
current time.

template<class X, class T, class TS>
void smtk::rk4< X, T, TS >::go ( X *  x,
T *  t 
) [inline]

Advance one time step.

Advance the state pointed to by x and t to a state with time *t plus the current single interation time step.

Parameters:
x a pointer to an array with the current state. The values in this array will be changed to the new state.
t a pointer to the current time. The value pointer to will be changed to the new time.

template<class T>
T smtk::validation::invalidate ( t  )  [inline, protected, inherited]

invalidate the object

Make the object invalid.

Returns:
t the argument the user passed.

void smtk::validation::invalidate ( void   )  [inline, protected, inherited]

invalidate the object

Make the object invalid.

bool smtk::validation::is_invalid ( void   )  const [inline, inherited]

see if the object is invalid

Returns:
true if the object is invalid, and false if not.

bool smtk::validation::is_valid ( void   )  const [inline, inherited]

see if the object is valid

Returns:
true if the object is valid, and false if not.

template<class X, class T, class TS>
void smtk::rk4< X, T, TS >::set_current_t ( t  )  [inline]

Set the current time.

Parameters:
t the time to set the current time to.

template<class X, class T, class TS>
TS smtk::rk4< X, T, TS >::set_t_step ( TS  tstep_in  )  [inline]

Set the time step.

Set the time step for a single interation of the 4th order Runge-Kutta solver.

Parameters:
tstep_in time step value.
Returns:
the value of tstep_in which is the current time step.

template<class T>
T smtk::validation::validate ( t  )  [inline, protected, inherited]

validate the object

Make the object valid.

Returns:
t the argument the user passed.

void smtk::validation::validate ( void   )  [inline, protected, inherited]

validate the object

Make the object valid.


The documentation for this class was generated from the following file:
Generated on Sat Aug 11 22:25:57 2007 for Simulation Toolkit (SmTk) by  doxygen 1.5.2