RungeKuttaFehlbergIvpOdeSolver Class Reference

#include <RungeKuttaFehlbergIvpOdeSolver.hpp>

Inherits AbstractIvpOdeSolver.

Collaboration diagram for RungeKuttaFehlbergIvpOdeSolver:
Collaboration graph
[legend]

List of all members.

Public Member Functions

 RungeKuttaFehlbergIvpOdeSolver ()
OdeSolution Solve (AbstractOdeSystem *pAbstractOdeSystem, std::vector< double > &rYValues, double startTime, double endTime, double timeStep, double ignoredSamplingTime)
void Solve (AbstractOdeSystem *pAbstractOdeSystem, std::vector< double > &rYValues, double startTime, double endTime, double timeStep)

Protected Member Functions

void InternalSolve (OdeSolution &rSolution, AbstractOdeSystem *pAbstractOdeSystem, std::vector< double > &rCurrentYValues, std::vector< double > &rWorkingMemory, double startTime, double endTime, double maxTimeStep, double minTimeStep, double tolerance, bool outputSolution)
void CalculateNextYValue (AbstractOdeSystem *pAbstractOdeSystem, double timeStep, double time, std::vector< double > &rCurrentYValues, std::vector< double > &rNextYValues)
void AdjustStepSize (double &rCurrentStepSize, const double &rError, const double &rTolerance, const double &rMaxTimeStep, const double &rMinTimeStep)

Private Member Functions

template<class Archive >
void serialize (Archive &archive, const unsigned int version)

Private Attributes

double m1932o2197
double m7200o2197
double m7296o2197
double m12o13
double m439o216
double m3680o513
double m845o4104
double m8o27
double m3544o2565
double m1859o4104
double m1o360
double m128o4275
double m2197o75240
double m2o55
double m25o216
double m1408o2565
double m2197o4104
std::vector< doublemError
std::vector< doublemk1
std::vector< doublemk2
std::vector< doublemk3
std::vector< doublemk4
std::vector< doublemk5
std::vector< doublemk6
std::vector< doublemyk2
std::vector< doublemyk3
std::vector< doublemyk4
std::vector< doublemyk5
std::vector< doublemyk6

Friends

class TestRungeKuttaFehlbergIvpOdeSolver
class boost::serialization::access

Detailed Description

A concrete one step ODE solver class that employs the Runge Kutta Fehlberg adaptive solver (RKF45).

This solver is good for problems where you need to be able to guarantee the accuracy of the answer as it is specified via the tolerance parameter.

The solver should also be reasonably fast as it increases the timestep when the solutions are changing slowly, whilst maintaining accuracy.

Definition at line 49 of file RungeKuttaFehlbergIvpOdeSolver.hpp.


Constructor & Destructor Documentation

RungeKuttaFehlbergIvpOdeSolver::RungeKuttaFehlbergIvpOdeSolver (  ) 

Constructor.

Definition at line 257 of file RungeKuttaFehlbergIvpOdeSolver.cpp.


Member Function Documentation

void RungeKuttaFehlbergIvpOdeSolver::AdjustStepSize ( double rCurrentStepSize,
const double rError,
const double rTolerance,
const double rMaxTimeStep,
const double rMinTimeStep 
) [protected]

Use the error approximation of the last call to the CalculateNextYValue() method to change the time step appropriately.

Parameters:
rCurrentStepSize the current step size being used (returns answer via this reference)
rError the error in the approximation at this time step
rTolerance the tolerance required
rMaxTimeStep the maximum timestep to be used
rMinTimeStep the minimum timestep to be used (to prevent huge loops)

Definition at line 214 of file RungeKuttaFehlbergIvpOdeSolver.cpp.

Referenced by InternalSolve().

void RungeKuttaFehlbergIvpOdeSolver::CalculateNextYValue ( AbstractOdeSystem pAbstractOdeSystem,
double  timeStep,
double  time,
std::vector< double > &  rCurrentYValues,
std::vector< double > &  rNextYValues 
) [protected]

Calculate the solution to the ODE system at the next timestep. Updates the mError vector with current error.

Parameters:
pAbstractOdeSystem the ODE system to solve
timeStep dt
time the current time
rCurrentYValues the current (initial) state
rNextYValues the state at the next timestep

Definition at line 153 of file RungeKuttaFehlbergIvpOdeSolver.cpp.

References AbstractOdeSystem::EvaluateYDerivatives(), AbstractOdeSystem::GetNumberOfStateVariables(), m128o4275, m12o13, m1408o2565, m1859o4104, m1932o2197, m1o360, m2197o4104, m2197o75240, m25o216, m2o55, m3544o2565, m3680o513, m439o216, m7200o2197, m7296o2197, m845o4104, m8o27, mError, mk1, mk2, mk3, mk4, mk5, mk6, myk2, myk3, myk4, myk5, and myk6.

Referenced by InternalSolve().

void RungeKuttaFehlbergIvpOdeSolver::InternalSolve ( OdeSolution rSolution,
AbstractOdeSystem pAbstractOdeSystem,
std::vector< double > &  rCurrentYValues,
std::vector< double > &  rWorkingMemory,
double  startTime,
double  endTime,
double  maxTimeStep,
double  minTimeStep,
double  tolerance,
bool  outputSolution 
) [protected]

Method that actually performs the solving on behalf of the public Solve methods.

Parameters:
rSolution an ode solution to input data into if requited
pAbstractOdeSystem the ODE system to solve
rCurrentYValues the current (initial) state; results will also be returned in here
rWorkingMemory working memory; same size as rCurrentYValues
startTime initial time
endTime time to solve to
maxTimeStep the maximum size of timestep allowable
minTimeStep the maximum size of timestep allowable (to prevent huge loops)
tolerance how accurate the numerical solution must be
outputSolution whether to output into rSolution (or save time by not doing)

Definition at line 40 of file RungeKuttaFehlbergIvpOdeSolver.cpp.

References AdjustStepSize(), CalculateNextYValue(), AbstractOdeSystem::CalculateStoppingEvent(), AbstractOdeSystem::GetNumberOfStateVariables(), mError, mk1, mk2, mk3, mk4, mk5, mk6, AbstractIvpOdeSolver::mStoppingEventOccurred, AbstractIvpOdeSolver::mStoppingTime, myk2, myk3, myk4, myk5, myk6, OdeSolution::rGetSolutions(), OdeSolution::rGetTimes(), and OdeSolution::SetNumberOfTimeSteps().

Referenced by Solve().

template<class Archive >
void RungeKuttaFehlbergIvpOdeSolver::serialize ( Archive &  archive,
const unsigned int  version 
) [inline, private]

Archive, never used directly - boost uses this.

Parameters:
archive the archive
version the current version of this class

Reimplemented from AbstractIvpOdeSolver.

Definition at line 63 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

void RungeKuttaFehlbergIvpOdeSolver::Solve ( AbstractOdeSystem pAbstractOdeSystem,
std::vector< double > &  rYValues,
double  startTime,
double  endTime,
double  timeStep 
) [virtual]

Second version of Solve. Solves a system of ODEs using a specified one-step ODE solver. This method does not return the solution and therefore does not take in a sampling time. Instead, the mStateVariables component in the ODE system object is updated.

Parameters:
pAbstractOdeSystem pointer to the concrete ODE system to be solved
rYValues a standard vector specifying the intial condition of each solution variable in the system (this can be the initial conditions vector stored in the ODE system)
startTime the time at which the initial conditions are specified
endTime the time to which the system should be solved and the solution returned
timeStep the time interval to be used by the solver

Implements AbstractIvpOdeSolver.

Definition at line 304 of file RungeKuttaFehlbergIvpOdeSolver.cpp.

References AbstractOdeSystem::CalculateStoppingEvent(), AbstractOdeSystem::GetNumberOfStateVariables(), InternalSolve(), and AbstractIvpOdeSolver::mStoppingEventOccurred.

OdeSolution RungeKuttaFehlbergIvpOdeSolver::Solve ( AbstractOdeSystem pAbstractOdeSystem,
std::vector< double > &  rYValues,
double  startTime,
double  endTime,
double  timeStep,
double  ignoredSamplingTime 
) [virtual]

Solves a system of ODEs using a specified one-step ODE solver and returns the solution as an OdeSolution object.

Parameters:
pAbstractOdeSystem pointer to the concrete ODE system to be solved
rYValues a standard vector specifying the intial condition of each solution variable in the system (this can be the initial conditions vector stored in the ODE system)
startTime the time at which the initial conditions are specified
endTime the time to which the system should be solved and the solution returned
timeStep the time interval to be used by the solver
ignoredSamplingTime the interval at which to sample the solution to the ODE system (ignored in this class as the timestep is variable)
Returns:
OdeSolution is an object containing an integer of the number of equations, a stdAbstractOdeSystem::vector of times and a std::vector of std::vectors where each of those vectors contains the solution for one variable of the ODE system at those times.

Implements AbstractIvpOdeSolver.

Definition at line 278 of file RungeKuttaFehlbergIvpOdeSolver.cpp.

References AbstractOdeSystem::CalculateStoppingEvent(), AbstractOdeSystem::GetNumberOfStateVariables(), InternalSolve(), and AbstractIvpOdeSolver::mStoppingEventOccurred.


Friends And Related Function Documentation

friend class boost::serialization::access [friend]

Needed for serialization.

Reimplemented from AbstractIvpOdeSolver.

Definition at line 55 of file RungeKuttaFehlbergIvpOdeSolver.hpp.


Member Data Documentation

Working memory: numerical value for the fraction 128/4275.

Definition at line 85 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue().

Working memory: numerical value for the fraction 12/13.

Definition at line 77 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue().

Working memory: numerical value for the fraction 1408/2565.

Definition at line 89 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue().

Working memory: numerical value for the fraction 1859/4104.

Definition at line 83 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue().

Working memory: numerical value for the fraction 1932/2197.

Definition at line 74 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue().

Working memory: numerical value for the fraction 1/360.

Definition at line 84 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue().

Working memory: numerical value for the fraction 2197/4104.

Definition at line 90 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue().

Working memory: numerical value for the fraction 2197/75240.

Definition at line 86 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue().

Working memory: numerical value for the fraction 25/216.

Definition at line 88 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue().

Working memory: numerical value for the fraction 2/55.

Definition at line 87 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue().

Working memory: numerical value for the fraction 3544/2565.

Definition at line 82 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue().

Working memory: numerical value for the fraction 3680/513.

Definition at line 79 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue().

Working memory: numerical value for the fraction 439/216.

Definition at line 78 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue().

Working memory: numerical value for the fraction 7200/2197.

Definition at line 75 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue().

Working memory: numerical value for the fraction 7296/2197.

Definition at line 76 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue().

Working memory: numerical value for the fraction 845/4104.

Definition at line 80 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue().

Working memory: numerical value for the fraction 8/27.

Definition at line 81 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue().

Error expression, used to adjust the timestep in the RKF45 method.

Definition at line 92 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue(), and InternalSolve().

Working memory: expression k1 in the RKF45 method.

Definition at line 94 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue(), and InternalSolve().

Working memory: expression k2 in the RKF45 method.

Definition at line 95 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue(), and InternalSolve().

Working memory: expression k3 in the RKF45 method.

Definition at line 96 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue(), and InternalSolve().

Working memory: expression k4 in the RKF45 method.

Definition at line 97 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue(), and InternalSolve().

Working memory: expression k5 in the RKF45 method.

Definition at line 98 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue(), and InternalSolve().

Working memory: expression k6 in the RKF45 method.

Definition at line 99 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue(), and InternalSolve().

Working memory: expression yk2 in the RKF45 method.

Definition at line 100 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue(), and InternalSolve().

Working memory: expression yk3 in the RKF45 method.

Definition at line 101 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue(), and InternalSolve().

Working memory: expression yk4 in the RKF45 method.

Definition at line 102 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue(), and InternalSolve().

Working memory: expression yk5 in the RKF45 method.

Definition at line 103 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue(), and InternalSolve().

Working memory: expression yk6 in the RKF45 method.

Definition at line 104 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue(), and InternalSolve().


The documentation for this class was generated from the following files:

Generated by  doxygen 1.6.2