#include <RungeKuttaFehlbergIvpOdeSolver.hpp>
Public Member Functions | |
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 > ¤tYValues, std::vector< double > &nextYValues) |
void | AdjustStepSize (double &rCurrentStepSize, const double &rError, const double &rTolerance, const double &rMaxTimeStep, const double &rMinTimeStep) |
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< double > | mError |
std::vector< double > | mk1 |
std::vector< double > | mk2 |
std::vector< double > | mk3 |
std::vector< double > | mk4 |
std::vector< double > | mk5 |
std::vector< double > | mk6 |
std::vector< double > | myk2 |
std::vector< double > | myk3 |
std::vector< double > | myk4 |
std::vector< double > | myk5 |
std::vector< double > | myk6 |
Friends | |
class | TestRungeKuttaFehlbergIvpOdeSolver |
Good for problems where you need to be able to guarantee the accuracy of the answer as it is specified via the tolerance parameter.
Should be reasonably fast too as it increases the timestep when the solutions are changing slowly, whilst maintaining accuracy.
Definition at line 53 of file RungeKuttaFehlbergIvpOdeSolver.hpp.
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.
rSolution | an ode solution to input data into if requited | |
pAbstractOdeSystem | the 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 | |
timeStep | dt | |
outputSolution | whether to output into rSolution (or save time by not doing) |
Definition at line 49 of file RungeKuttaFehlbergIvpOdeSolver.cpp.
References AdjustStepSize(), CalculateNextYValue(), AbstractOdeSystem::CalculateStoppingEvent(), AbstractOdeSystem::GetNumberOfStateVariables(), AbstractIvpOdeSolver::mStoppingEventOccurred, AbstractIvpOdeSolver::mStoppingTime, OdeSolution::rGetSolutions(), OdeSolution::rGetTimes(), and OdeSolution::SetNumberOfTimeSteps().
Referenced by Solve().
void RungeKuttaFehlbergIvpOdeSolver::CalculateNextYValue | ( | AbstractOdeSystem * | pAbstractOdeSystem, | |
double | timeStep, | |||
double | time, | |||
std::vector< double > & | currentYValues, | |||
std::vector< double > & | nextYValues | |||
) | [protected] |
Calculate the next time step, using rkf45 numerical routine
Updates the mError vector with current error.
pAbstractOdeSystem | the ode system to be solved | |
timeStep | the current timestep | |
time | the current time | |
currentYValues | Y Values at the current time | |
nextYValues | the 4th order approximation for the Y values at the end of the timestep. |
Definition at line 163 of file RungeKuttaFehlbergIvpOdeSolver.cpp.
References AbstractOdeSystem::EvaluateYDerivatives(), and AbstractOdeSystem::GetNumberOfStateVariables().
Referenced by InternalSolve().
void RungeKuttaFehlbergIvpOdeSolver::AdjustStepSize | ( | double & | rCurrentStepSize, | |
const double & | rError, | |||
const double & | rTolerance, | |||
const double & | rMaxTimeStep, | |||
const double & | rMinTimeStep | |||
) | [protected] |
Uses the error approximation of the last CalculateNextYValue() call to change the time step appropriately.
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 224 of file RungeKuttaFehlbergIvpOdeSolver.cpp.
Referenced by InternalSolve().
OdeSolution RungeKuttaFehlbergIvpOdeSolver::Solve | ( | AbstractOdeSystem * | pAbstractOdeSystem, | |
std::vector< double > & | rYValues, | |||
double | startTime, | |||
double | endTime, | |||
double | timeStep, | |||
double | timeSampling | |||
) | [virtual] |
Solves a system of ODEs using a specified one-step ODE solver
pAbstractOdeSystem | points to the concrete ODE system to be solved | |
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 | |
initialConditions | a standard vector specifying the intial condition of each solution variable in the system. |
Implements AbstractIvpOdeSolver.
Definition at line 267 of file RungeKuttaFehlbergIvpOdeSolver.cpp.
References AbstractOdeSystem::CalculateStoppingEvent(), AbstractOdeSystem::GetNumberOfStateVariables(), InternalSolve(), and AbstractIvpOdeSolver::mStoppingEventOccurred.