AdaptiveRungeKutta Class Reference

Inheritance diagram for AdaptiveRungeKutta:

Inheritance graph
[legend]

List of all members.


Detailed Description

Adaptive Runge-Kutta method for solving a system of ordinary differential equations.

Author:
Lawrence Murray <lawrence@indii.org>
Version:
Rev
Date:
Date
This class numerically solves DifferentialModel models defining a system of ordinary differential equations using an adaptive time step 4th/5th order Runge--Kutta--Fehlberg method as implemented in the GSL.

The general usage idiom is as follows. First begin by writing your own class deriving from DifferentialModel to describe your model, and instantiating an object of this class:

 MyDifferentialModel model;

Construct the initial state of the system:

 indii::ml::aux::vector y0(4);
 y0(0) = 1.0;
 y0(1) = 0.0;
 y0(2) = 0.0;
 y0(3) = 2.0;

Create an AdaptiveRungeKutta object, passing in the model to solve and the initial state:

 AdaptiveRungeKutta solver(&model, y0);

At this stage setErrorBounds() and setStepSize() may be used to manipulate the Runge-Kutta to be appropriate for the model, balancing speed versus accuracy. The defaults are often sufficient, however.

Now use step() to step through the system. The time step will vary to maintain error bounds, so it is necessary to keep track of the time after each step.

 double end = 60.0;
 double t = 0.0;
 while (t < end) {
   t = solver.step(end);
   std::cout << solver.getState() << std::endl;
 }

t is guaranteed to reach end at some point, although the number of steps that this will take depends on the model, initial state and error bounds.

If you are only interested in the state of the system at a given time, or wish to use fixed time steps, use stepTo() to jump straight to the required time. Internally, stepTo() essentially just performs the above loop for you, but its use can be more convenient.

For known discontinuities, it is usual to estimate the function piecewise, stepping from start to finish through a continuous piece, then calling setDiscontinuity() before proceeding onto the next.

References

The GNU Scientific Library (GSL). http://www.gnu.org/software/gsl/.

Definition at line 90 of file AdaptiveRungeKutta.hpp.


Public Member Functions

 AdaptiveRungeKutta (DifferentialModel *model)
 Constructor.
 AdaptiveRungeKutta (DifferentialModel *model, const indii::ml::aux::vector &y0)
 Constructor.
virtual ~AdaptiveRungeKutta ()
 Destructor.
virtual int calculateDerivativesForward (double t, const double y[], double dydt[])
 Calculate derivatives for forwards step.
virtual int calculateDerivativesBackward (double t, const double y[], double dydt[])
 Calculate derivatives for backwards step.

Constructor & Destructor Documentation

AdaptiveRungeKutta ( DifferentialModel model  ) 

Constructor.

Parameters:
model Model to estimate.
The time is initialised to zero, but the state is uninitialised and should be set with setVariable() or setState().

Definition at line 20 of file AdaptiveRungeKutta.cpp.

AdaptiveRungeKutta ( DifferentialModel model,
const indii::ml::aux::vector y0 
)

Constructor.

Parameters:
model Model to estimate.
y0 Initial state.
The time is initialised to zero and the state to that given.

Definition at line 25 of file AdaptiveRungeKutta.cpp.

~AdaptiveRungeKutta (  )  [virtual]

Destructor.

Definition at line 33 of file AdaptiveRungeKutta.cpp.


Member Function Documentation

int calculateDerivativesForward ( double  t,
const double  y[],
double  dydt[] 
) [virtual]

Calculate derivatives for forwards step.

Implements NumericalSolver.

Definition at line 37 of file AdaptiveRungeKutta.cpp.

int calculateDerivativesBackward ( double  t,
const double  y[],
double  dydt[] 
) [virtual]

Calculate derivatives for backwards step.

Implements NumericalSolver.

Definition at line 44 of file AdaptiveRungeKutta.cpp.


Generated on Wed Dec 17 15:11:58 2008 for dysii Dynamical Systems Library by  doxygen 1.5.3