Chaste Commit::1fd4e48e3990e67db148bc1bc4cf6991a0049d0c
RungeKuttaFehlbergIvpOdeSolver Class Reference

#include <RungeKuttaFehlbergIvpOdeSolver.hpp>

+ Inheritance diagram for RungeKuttaFehlbergIvpOdeSolver:
+ Collaboration diagram for RungeKuttaFehlbergIvpOdeSolver:

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)
 
- Public Member Functions inherited from AbstractIvpOdeSolver
virtual void SolveAndUpdateStateVariable (AbstractOdeSystem *pAbstractOdeSystem, double startTime, double endTime, double timeStep)
 
bool StoppingEventOccurred ()
 
double GetStoppingTime ()
 
 AbstractIvpOdeSolver ()
 
virtual ~AbstractIvpOdeSolver ()
 
- Public Member Functions inherited from Identifiable
virtual ~Identifiable ()
 
std::string GetIdentifier () const
 

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
 

Additional Inherited Members

- Protected Attributes inherited from AbstractIvpOdeSolver
bool mStoppingEventOccurred
 
double mStoppingTime
 

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 56 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Constructor & Destructor Documentation

◆ RungeKuttaFehlbergIvpOdeSolver()

RungeKuttaFehlbergIvpOdeSolver::RungeKuttaFehlbergIvpOdeSolver ( )

Constructor.

Definition at line 263 of file RungeKuttaFehlbergIvpOdeSolver.cpp.

Member Function Documentation

◆ AdjustStepSize()

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
rCurrentStepSizethe current step size being used (returns answer via this reference)
rErrorthe error in the approximation at this time step
rTolerancethe tolerance required
rMaxTimeStepthe maximum timestep to be used
rMinTimeStepthe minimum timestep to be used (to prevent huge loops)

Definition at line 220 of file RungeKuttaFehlbergIvpOdeSolver.cpp.

References EXCEPTION.

Referenced by InternalSolve().

◆ CalculateNextYValue()

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
pAbstractOdeSystemthe ODE system to solve
timeStepdt
timethe current time
rCurrentYValuesthe current (initial) state
rNextYValuesthe state at the next timestep

Definition at line 159 of file RungeKuttaFehlbergIvpOdeSolver.cpp.

References AbstractOdeSystem::EvaluateYDerivatives(), AbstractUntemplatedParameterisedSystem::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().

◆ 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
rSolutionan ODE solution to input data into if requited
pAbstractOdeSystemthe ODE system to solve
rCurrentYValuesthe current (initial) state; results will also be returned in here
rWorkingMemoryworking memory; same size as rCurrentYValues
startTimeinitial time
endTimetime to solve to
maxTimeStepthe maximum size of timestep allowable
minTimeStepthe maximum size of timestep allowable (to prevent huge loops)
tolerancehow accurate the numerical solution must be
outputSolutionwhether to output into rSolution (or save time by not doing)

Definition at line 46 of file RungeKuttaFehlbergIvpOdeSolver.cpp.

References AdjustStepSize(), CalculateNextYValue(), AbstractOdeSystem::CalculateStoppingEvent(), AbstractUntemplatedParameterisedSystem::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(), and Solve().

◆ serialize()

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

Archive, never used directly - boost uses this.

Parameters
archivethe archive
versionthe current version of this class

Definition at line 70 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

◆ Solve() [1/2]

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
pAbstractOdeSystempointer to the concrete ODE system to be solved
rYValuesa 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)
startTimethe time at which the initial conditions are specified
endTimethe time to which the system should be solved and the solution returned
timeStepthe time interval to be used by the solver

Implements AbstractIvpOdeSolver.

Definition at line 310 of file RungeKuttaFehlbergIvpOdeSolver.cpp.

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

◆ Solve() [2/2]

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
pAbstractOdeSystempointer to the concrete ODE system to be solved
rYValuesa 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)
startTimethe time at which the initial conditions are specified
endTimethe time to which the system should be solved and the solution returned
timeStepthe time interval to be used by the solver
ignoredSamplingTimethe 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 284 of file RungeKuttaFehlbergIvpOdeSolver.cpp.

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

Friends And Related Symbol Documentation

◆ boost::serialization::access

friend class boost::serialization::access
friend

Needed for serialization.

Definition at line 62 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

◆ TestRungeKuttaFehlbergIvpOdeSolver

friend class TestRungeKuttaFehlbergIvpOdeSolver
friend

Definition at line 58 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Member Data Documentation

◆ m128o4275

double RungeKuttaFehlbergIvpOdeSolver::m128o4275
private

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

Definition at line 92 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue().

◆ m12o13

double RungeKuttaFehlbergIvpOdeSolver::m12o13
private

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

Definition at line 84 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue().

◆ m1408o2565

double RungeKuttaFehlbergIvpOdeSolver::m1408o2565
private

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

Definition at line 96 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue().

◆ m1859o4104

double RungeKuttaFehlbergIvpOdeSolver::m1859o4104
private

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

Definition at line 90 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue().

◆ m1932o2197

double RungeKuttaFehlbergIvpOdeSolver::m1932o2197
private

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

Definition at line 81 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue().

◆ m1o360

double RungeKuttaFehlbergIvpOdeSolver::m1o360
private

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

Definition at line 91 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue().

◆ m2197o4104

double RungeKuttaFehlbergIvpOdeSolver::m2197o4104
private

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

Definition at line 97 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue().

◆ m2197o75240

double RungeKuttaFehlbergIvpOdeSolver::m2197o75240
private

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

Definition at line 93 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue().

◆ m25o216

double RungeKuttaFehlbergIvpOdeSolver::m25o216
private

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

Definition at line 95 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue().

◆ m2o55

double RungeKuttaFehlbergIvpOdeSolver::m2o55
private

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

Definition at line 94 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue().

◆ m3544o2565

double RungeKuttaFehlbergIvpOdeSolver::m3544o2565
private

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

Definition at line 89 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue().

◆ m3680o513

double RungeKuttaFehlbergIvpOdeSolver::m3680o513
private

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

Definition at line 86 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue().

◆ m439o216

double RungeKuttaFehlbergIvpOdeSolver::m439o216
private

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

Definition at line 85 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue().

◆ m7200o2197

double RungeKuttaFehlbergIvpOdeSolver::m7200o2197
private

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

Definition at line 82 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue().

◆ m7296o2197

double RungeKuttaFehlbergIvpOdeSolver::m7296o2197
private

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

Definition at line 83 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue().

◆ m845o4104

double RungeKuttaFehlbergIvpOdeSolver::m845o4104
private

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

Definition at line 87 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue().

◆ m8o27

double RungeKuttaFehlbergIvpOdeSolver::m8o27
private

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

Definition at line 88 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue().

◆ mError

std::vector<double> RungeKuttaFehlbergIvpOdeSolver::mError
private

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

Definition at line 99 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue(), and InternalSolve().

◆ mk1

std::vector<double> RungeKuttaFehlbergIvpOdeSolver::mk1
private

Working memory: expression k1 in the RKF45 method.

Definition at line 101 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue(), and InternalSolve().

◆ mk2

std::vector<double> RungeKuttaFehlbergIvpOdeSolver::mk2
private

Working memory: expression k2 in the RKF45 method.

Definition at line 102 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue(), and InternalSolve().

◆ mk3

std::vector<double> RungeKuttaFehlbergIvpOdeSolver::mk3
private

Working memory: expression k3 in the RKF45 method.

Definition at line 103 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue(), and InternalSolve().

◆ mk4

std::vector<double> RungeKuttaFehlbergIvpOdeSolver::mk4
private

Working memory: expression k4 in the RKF45 method.

Definition at line 104 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue(), and InternalSolve().

◆ mk5

std::vector<double> RungeKuttaFehlbergIvpOdeSolver::mk5
private

Working memory: expression k5 in the RKF45 method.

Definition at line 105 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue(), and InternalSolve().

◆ mk6

std::vector<double> RungeKuttaFehlbergIvpOdeSolver::mk6
private

Working memory: expression k6 in the RKF45 method.

Definition at line 106 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue(), and InternalSolve().

◆ myk2

std::vector<double> RungeKuttaFehlbergIvpOdeSolver::myk2
private

Working memory: expression yk2 in the RKF45 method.

Definition at line 107 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue(), and InternalSolve().

◆ myk3

std::vector<double> RungeKuttaFehlbergIvpOdeSolver::myk3
private

Working memory: expression yk3 in the RKF45 method.

Definition at line 108 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue(), and InternalSolve().

◆ myk4

std::vector<double> RungeKuttaFehlbergIvpOdeSolver::myk4
private

Working memory: expression yk4 in the RKF45 method.

Definition at line 109 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue(), and InternalSolve().

◆ myk5

std::vector<double> RungeKuttaFehlbergIvpOdeSolver::myk5
private

Working memory: expression yk5 in the RKF45 method.

Definition at line 110 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue(), and InternalSolve().

◆ myk6

std::vector<double> RungeKuttaFehlbergIvpOdeSolver::myk6
private

Working memory: expression yk6 in the RKF45 method.

Definition at line 111 of file RungeKuttaFehlbergIvpOdeSolver.hpp.

Referenced by CalculateNextYValue(), and InternalSolve().


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