#include <AbstractOdeSystem.hpp>
Public Member Functions | |
AbstractOdeSystem (unsigned numberOfStateVariables=0) | |
virtual | ~AbstractOdeSystem () |
virtual void | EvaluateYDerivatives (double time, const std::vector< double > &rY, std::vector< double > &rDY)=0 |
unsigned | GetNumberOfStateVariables () const |
unsigned | GetNumberOfParameters () const |
double | GetParameter (unsigned index) const |
void | SetParameter (unsigned index, double value) |
const std::vector< std::string > & | rGetParameterNames () const |
const std::vector< std::string > & | rGetParameterUnits () const |
void | SetInitialConditions (const std::vector< double > &rInitialConditions) |
void | SetInitialConditionsComponent (unsigned index, double initialCondition) |
std::vector< double > | GetInitialConditions () const |
void | SetStateVariables (const std::vector< double > &rStateVariables) |
void | SetStateVariable (unsigned stateVariable, double newValue) |
std::vector< double > & | rGetStateVariables () |
const std::vector< std::string > & | rGetVariableNames () const |
const std::vector< std::string > & | rGetVariableUnits () const |
virtual bool | CalculateStoppingEvent (double time, const std::vector< double > &rY) |
virtual double | CalculateRootFunction (double time, const std::vector< double > &rY) |
bool | GetUseAnalyticJacobian () |
unsigned | GetStateVariableNumberByName (const std::string name) |
double | GetStateVariableValueByNumber (unsigned varNumber) const |
std::string | GetStateVariableUnitsByNumber (unsigned varNumber) const |
boost::shared_ptr< const AbstractOdeSystemInformation > | GetSystemInformation () const |
Protected Member Functions | |
std::string | DumpState (const std::string &rMessage, std::vector< double > Y=std::vector< double >()) |
Protected Attributes | |
unsigned | mNumberOfStateVariables |
std::vector< double > | mStateVariables |
std::vector< double > | mParameters |
boost::shared_ptr < AbstractOdeSystemInformation > | mpSystemInfo |
bool | mUseAnalyticJacobian |
Private Member Functions | |
template<class Archive> | |
void | serialize (Archive &archive, const unsigned int version) |
Friends | |
class | TestAbstractOdeSystem |
class | boost::serialization::access |
Sets up variables and functions for a general ODE system.
ODE systems are specified primarily by the EvaluateYDerivatives method, which calculates the right-hand side of the system.
Instances can store their state internally in the mStateVariables vector (see GetNumberOfStateVariables, SetStateVariables and rGetStateVariables), although this is not essential - the vector may be empty, although in this case AbstractIvpOdeSolver::SolveAndUpdateStateVariable may not be used to solve the system.
ODE systems may also have a vector of parameters, which can be accessed through the GetParameter and SetParameter methods.
Information about what the parameters and state variables represent is provided by a subclass of AbstractOdeSystemInformation. Various wrapper methods (e.g. rGetVariableNames) are provided in this class to access this information.
There are two more advanced facilities available for subclass authors. An analytic form for the Jacobian matrix of the system may be provided, in which case you must subclass AbstractOdeSystemWithAnalyticJacobian. The GetUseAnalyticJacobian method will test whether this is the case.
Also, subclasses may define a condition at which ODE solvers should stop prematurely. For the Chaste solvers this is done by overriding CalculateStoppingEvent; if the more advanced CVODE solvers are being used then implement CalculateRootFunction instead to detect the stopping time more accurately.
Definition at line 77 of file AbstractOdeSystem.hpp.
AbstractOdeSystem::AbstractOdeSystem | ( | unsigned | numberOfStateVariables = 0 |
) |
Constructor.
numberOfStateVariables | the number of state variables in the ODE system (defaults to 0) |
Definition at line 33 of file AbstractOdeSystem.cpp.
AbstractOdeSystem::~AbstractOdeSystem | ( | ) | [virtual] |
Virtual destructor since we have virtual methods.
Definition at line 39 of file AbstractOdeSystem.cpp.
void AbstractOdeSystem::serialize | ( | Archive & | archive, | |
const unsigned int | version | |||
) | [inline, private] |
Archive the member variables.
archive | the archive | |
version | the current version of this class |
Reimplemented in AbstractBackwardEulerCardiacCell< SIZE >, AbstractCardiacCell, BackwardEulerFoxModel2002Modified, BackwardEulerLuoRudyIModel1991, LuoRudyIModel1991OdeSystem, AbstractBackwardEulerCardiacCell< 12 >, AbstractBackwardEulerCardiacCell< 1 >, and AbstractBackwardEulerCardiacCell< 3 >.
Definition at line 91 of file AbstractOdeSystem.hpp.
References mNumberOfStateVariables, mParameters, mStateVariables, and mUseAnalyticJacobian.
virtual void AbstractOdeSystem::EvaluateYDerivatives | ( | double | time, | |
const std::vector< double > & | rY, | |||
std::vector< double > & | rDY | |||
) | [pure virtual] |
Method to evaluate the derivatives of the system.
time | the current time | |
rY | the current values of the state variables | |
rDY | storage for the derivatives of the system; will be filled in on return |
Implemented in AbstractBackwardEulerCardiacCell< SIZE >, DiFrancescoNoble1985OdeSystem, FakeBathCell, FitzHughNagumo1961OdeSystem, FoxModel2002Modified, HodgkinHuxleySquidAxon1952OriginalOdeSystem, LuoRudyIModel1991OdeSystem, Mahajan2008OdeSystem, NhsCellularMechanicsOdeSystem, TenTusscher2006OdeSystem, CombinedOdeSystem, IngeWntSwatCellCycleOdeSystem, TysonNovak2001OdeSystem, WntCellCycleOdeSystem, AbstractBackwardEulerCardiacCell< 12 >, AbstractBackwardEulerCardiacCell< 1 >, and AbstractBackwardEulerCardiacCell< 3 >.
Referenced by RungeKuttaFehlbergIvpOdeSolver::CalculateNextYValue(), RungeKutta4IvpOdeSolver::CalculateNextYValue(), RungeKutta2IvpOdeSolver::CalculateNextYValue(), EulerIvpOdeSolver::CalculateNextYValue(), and BackwardEulerIvpOdeSolver::ComputeResidual().
unsigned AbstractOdeSystem::GetNumberOfStateVariables | ( | ) | const |
Get the number of state variables in the ODE system.
Definition at line 65 of file AbstractOdeSystem.cpp.
References mNumberOfStateVariables.
Referenced by RungeKuttaFehlbergIvpOdeSolver::CalculateNextYValue(), RungeKutta4IvpOdeSolver::CalculateNextYValue(), RungeKutta2IvpOdeSolver::CalculateNextYValue(), EulerIvpOdeSolver::CalculateNextYValue(), BackwardEulerIvpOdeSolver::CalculateNextYValue(), RungeKuttaFehlbergIvpOdeSolver::InternalSolve(), NhsSystemWithImplicitSolver::NhsSystemWithImplicitSolver(), RungeKuttaFehlbergIvpOdeSolver::Solve(), AbstractOneStepIvpOdeSolver::Solve(), AbstractIvpOdeSolver::SolveAndUpdateStateVariable(), and AbstractOdeBasedCellCycleModel::UpdateCellCyclePhase().
unsigned AbstractOdeSystem::GetNumberOfParameters | ( | ) | const |
Get the number of parameters.
Definition at line 71 of file AbstractOdeSystem.cpp.
References mParameters.
double AbstractOdeSystem::GetParameter | ( | unsigned | index | ) | const |
Get the value of a given parameter.
index | the index of the parameter |
Definition at line 76 of file AbstractOdeSystem.cpp.
References mParameters.
void AbstractOdeSystem::SetParameter | ( | unsigned | index, | |
double | value | |||
) |
Set the value of a given parameter.
index | the index of the parameter | |
value | the value |
Definition at line 81 of file AbstractOdeSystem.cpp.
References mParameters.
const std::vector< std::string > & AbstractOdeSystem::rGetParameterNames | ( | ) | const |
Get the names of the parameters in the ODE system.
Definition at line 86 of file AbstractOdeSystem.cpp.
References mpSystemInfo.
const std::vector< std::string > & AbstractOdeSystem::rGetParameterUnits | ( | ) | const |
Get the units of the parameters in the ODE system.
Definition at line 92 of file AbstractOdeSystem.cpp.
References mpSystemInfo.
void AbstractOdeSystem::SetInitialConditions | ( | const std::vector< double > & | rInitialConditions | ) |
Set the initial conditions for the ODE system.
rInitialConditions | vector containing initial values for the state variables |
Definition at line 99 of file AbstractOdeSystem.cpp.
References mNumberOfStateVariables, and mpSystemInfo.
void AbstractOdeSystem::SetInitialConditionsComponent | ( | unsigned | index, | |
double | initialCondition | |||
) |
Set the initial condition one state variable.
index | the index of the state variable in the system | |
initialCondition | the initial value for the state variable |
Definition at line 109 of file AbstractOdeSystem.cpp.
References mNumberOfStateVariables, and mpSystemInfo.
Referenced by IngeWntSwatCellCycleOdeSystem::IngeWntSwatCellCycleOdeSystem(), and WntCellCycleOdeSystem::WntCellCycleOdeSystem().
std::vector< double > AbstractOdeSystem::GetInitialConditions | ( | ) | const |
Get the initial conditions for the ODE system.
Definition at line 119 of file AbstractOdeSystem.cpp.
References mpSystemInfo.
Referenced by CombinedOdeSystem::CombinedOdeSystem(), AbstractCardiacCell::Init(), WntCellCycleModel::Initialise(), IngeWntSwatCellCycleModel::Initialise(), NhsCellularMechanicsOdeSystem::NhsCellularMechanicsOdeSystem(), TysonNovakCellCycleModel::ResetForDivision(), AbstractWntOdeBasedCellCycleModel::ResetForDivision(), and TysonNovakCellCycleModel::TysonNovakCellCycleModel().
void AbstractOdeSystem::SetStateVariables | ( | const std::vector< double > & | rStateVariables | ) |
Set the values of the state variables in the ODE system.
rStateVariables | vector containing values for the state variables |
Definition at line 125 of file AbstractOdeSystem.cpp.
References mNumberOfStateVariables, and mStateVariables.
Referenced by CombinedOdeSystem::CombinedOdeSystem(), AbstractCardiacCell::Init(), WntCellCycleModel::Initialise(), IngeWntSwatCellCycleModel::Initialise(), NhsCellularMechanicsOdeSystem::NhsCellularMechanicsOdeSystem(), TysonNovakCellCycleModel::ResetForDivision(), AbstractOdeBasedCellCycleModel::SetProteinConcentrationsForTestsOnly(), and TysonNovakCellCycleModel::TysonNovakCellCycleModel().
void AbstractOdeSystem::SetStateVariable | ( | unsigned | stateVariable, | |
double | newValue | |||
) |
Set the value of a single state variable in the ODE system.
stateVariable | index of the state variable to be set | |
newValue | new value of the state variable |
Definition at line 134 of file AbstractOdeSystem.cpp.
References mNumberOfStateVariables, and mStateVariables.
std::vector< double > & AbstractOdeSystem::rGetStateVariables | ( | ) |
Get the values of the state variables in the ODE system.
Definition at line 144 of file AbstractOdeSystem.cpp.
References mStateVariables.
Referenced by WntCellCycleModel::ChangeCellTypeDueToCurrentBetaCateninLevel(), IngeWntSwatCellCycleModel::ChangeCellTypeDueToCurrentBetaCateninLevel(), AbstractCardiacCell::Compute(), AbstractBackwardEulerCardiacCell< SIZE >::Compute(), BackwardEulerLuoRudyIModel1991::ComputeJacobian(), BackwardEulerLuoRudyIModel1991::ComputeOneStepExceptVoltage(), BackwardEulerFoxModel2002Modified::ComputeOneStepExceptVoltage(), BackwardEulerLuoRudyIModel1991::ComputeResidual(), DumpState(), FakeBathCell::FakeBathCell(), IngeWntSwatCellCycleModel::GetCytoplasmicBetaCateninLevel(), Mahajan2008OdeSystem::GetIIonic(), FoxModel2002Modified::GetIIonic(), BackwardEulerFoxModel2002Modified::GetIIonic(), IngeWntSwatCellCycleModel::GetMembraneBoundBetaCateninLevel(), IngeWntSwatCellCycleModel::GetNuclearBetaCateninLevel(), AbstractOdeBasedCellCycleModel::GetProteinConcentrations(), AbstractCardiacCell::GetVoltage(), IngeWntSwatCellCycleModel::IngeWntSwatCellCycleModel(), TysonNovakCellCycleModel::ResetForDivision(), AbstractWntOdeBasedCellCycleModel::ResetForDivision(), AbstractOdeBasedCellCycleModel::serialize(), AbstractOdeBasedCellCycleModel::SetProteinConcentrationsForTestsOnly(), AbstractCardiacCell::SetVoltage(), AbstractIvpOdeSolver::SolveAndUpdateStateVariable(), WntCellCycleModel::SolveOdeToTime(), IngeWntSwatCellCycleModel::SolveOdeToTime(), AbstractOdeBasedCellCycleModel::UpdateCellCyclePhase(), BackwardEulerLuoRudyIModel1991::UpdateTransmembranePotential(), BackwardEulerFoxModel2002Modified::UpdateTransmembranePotential(), TenTusscher2006OdeSystem::VerifyStateVariables(), LuoRudyIModel1991OdeSystem::VerifyStateVariables(), DiFrancescoNoble1985OdeSystem::VerifyStateVariables(), BackwardEulerLuoRudyIModel1991::VerifyStateVariables(), WntCellCycleModel::WntCellCycleModel(), and CardiacElectroMechanicsProblem< DIM >::WriteWatchedLocationData().
const std::vector< std::string > & AbstractOdeSystem::rGetVariableNames | ( | ) | const |
Get the names of the state variables in the ODE system.
Definition at line 149 of file AbstractOdeSystem.cpp.
References mpSystemInfo.
Referenced by DumpState(), FoxModel2002Modified::EvaluateYDerivatives(), and OdeSolution::WriteToFile().
const std::vector< std::string > & AbstractOdeSystem::rGetVariableUnits | ( | ) | const |
Get the units of the state variables in the ODE system.
Definition at line 155 of file AbstractOdeSystem.cpp.
References mpSystemInfo.
Referenced by OdeSolution::WriteToFile().
bool AbstractOdeSystem::CalculateStoppingEvent | ( | double | time, | |
const std::vector< double > & | rY | |||
) | [virtual] |
CalculateStoppingEvent() - can be overloaded if the ODE is to be solved only until a particular event (for example, only until the y value becomes negative.
After each timestep the solver will call this method on the ODE to see if it should stop there. By default, false is returned here.
time | the current time | |
rY | the current values of the state variables |
Reimplemented in IngeWntSwatCellCycleOdeSystem, TysonNovak2001OdeSystem, and WntCellCycleOdeSystem.
Definition at line 42 of file AbstractOdeSystem.cpp.
Referenced by CalculateRootFunction(), RungeKuttaFehlbergIvpOdeSolver::InternalSolve(), AbstractOneStepIvpOdeSolver::InternalSolve(), RungeKuttaFehlbergIvpOdeSolver::Solve(), and AbstractOneStepIvpOdeSolver::Solve().
double AbstractOdeSystem::CalculateRootFunction | ( | double | time, | |
const std::vector< double > & | rY | |||
) | [virtual] |
An alternative approach to stopping events; currently only useful with CVODE. CVODE can search for roots (zeros) of this function while solving the ODE system, and home in on them to find sign transitions to high precision.
The default implementation here fakes a root function using CalculateStoppingEvent.
time | the current time | |
rY | the current values of the state variables |
Reimplemented in IngeWntSwatCellCycleOdeSystem, TysonNovak2001OdeSystem, and WntCellCycleOdeSystem.
Definition at line 167 of file AbstractOdeSystem.cpp.
References CalculateStoppingEvent().
bool AbstractOdeSystem::GetUseAnalyticJacobian | ( | ) |
Get whether an analytic Jacobian is used.
Definition at line 173 of file AbstractOdeSystem.cpp.
References mUseAnalyticJacobian.
Referenced by BackwardEulerIvpOdeSolver::ComputeJacobian().
unsigned AbstractOdeSystem::GetStateVariableNumberByName | ( | const std::string | name | ) |
This method is used to establish a state variable's position within the vector of state variables of an ODE system. This number can then be used with the methods GetStateVariableValueByNumber and GetStateVariableUnitsByNumber.
name | the name of a state variable. |
Definition at line 178 of file AbstractOdeSystem.cpp.
References mpSystemInfo.
double AbstractOdeSystem::GetStateVariableValueByNumber | ( | unsigned | varNumber | ) | const |
Get the value of a state variable given its index in the ODE system.
varNumber | a state variable's position within the vector of state variables associated with the ODE system. |
Definition at line 184 of file AbstractOdeSystem.cpp.
References mNumberOfStateVariables, and mStateVariables.
std::string AbstractOdeSystem::GetStateVariableUnitsByNumber | ( | unsigned | varNumber | ) | const |
Get the units of a state variable given its index in the ODE system.
varNumber | a state variable's position within the vector of state variables associated with the ODE system. |
Definition at line 190 of file AbstractOdeSystem.cpp.
References mNumberOfStateVariables, and mpSystemInfo.
boost::shared_ptr< const AbstractOdeSystemInformation > AbstractOdeSystem::GetSystemInformation | ( | ) | const |
Get the object which provides information about this ODE system.
Definition at line 161 of file AbstractOdeSystem.cpp.
References mpSystemInfo.
std::string AbstractOdeSystem::DumpState | ( | const std::string & | rMessage, | |
std::vector< double > | Y = std::vector<double>() | |||
) | [protected] |
Used to include extra debugging information in exception messages. For example, EXCEPTION(DumpState("Gating variable out of range"));
rMessage | the exception message | |
Y | the values of the state variables (optional input argument) |
Definition at line 47 of file AbstractOdeSystem.cpp.
References rGetStateVariables(), and rGetVariableNames().
Referenced by FoxModel2002Modified::EvaluateYDerivatives(), TenTusscher2006OdeSystem::VerifyStateVariables(), LuoRudyIModel1991OdeSystem::VerifyStateVariables(), and DiFrancescoNoble1985OdeSystem::VerifyStateVariables().
friend class boost::serialization::access [friend] |
Needed for serialization.
Reimplemented in AbstractBackwardEulerCardiacCell< SIZE >, AbstractCardiacCell, BackwardEulerFoxModel2002Modified, BackwardEulerLuoRudyIModel1991, LuoRudyIModel1991OdeSystem, AbstractBackwardEulerCardiacCell< 12 >, AbstractBackwardEulerCardiacCell< 1 >, and AbstractBackwardEulerCardiacCell< 3 >.
Definition at line 82 of file AbstractOdeSystem.hpp.
unsigned AbstractOdeSystem::mNumberOfStateVariables [protected] |
The number of state variables in the ODE system.
Definition at line 105 of file AbstractOdeSystem.hpp.
Referenced by AbstractCardiacCell::AbstractCardiacCell(), CombinedOdeSystem::CombinedOdeSystem(), GetNumberOfStateVariables(), GetStateVariableUnitsByNumber(), GetStateVariableValueByNumber(), serialize(), SetInitialConditions(), SetInitialConditionsComponent(), SetStateVariable(), and SetStateVariables().
std::vector<double> AbstractOdeSystem::mStateVariables [protected] |
Vector containing the current values of the state variables.
Definition at line 108 of file AbstractOdeSystem.hpp.
Referenced by NhsCellularMechanicsOdeSystem::GetActiveTension(), NhsCellularMechanicsOdeSystem::GetCalciumTroponinValue(), TenTusscher2006OdeSystem::GetIIonic(), LuoRudyIModel1991OdeSystem::GetIIonic(), HodgkinHuxleySquidAxon1952OriginalOdeSystem::GetIIonic(), FitzHughNagumo1961OdeSystem::GetIIonic(), DiFrancescoNoble1985OdeSystem::GetIIonic(), BackwardEulerLuoRudyIModel1991::GetIIonic(), LuoRudyIModel1991OdeSystem::GetIntracellularCalciumConcentration(), BackwardEulerLuoRudyIModel1991::GetIntracellularCalciumConcentration(), GetStateVariableValueByNumber(), rGetStateVariables(), serialize(), SetStateVariable(), SetStateVariables(), NhsSystemWithImplicitSolver::SolveDoNotUpdate(), and NhsSystemWithImplicitSolver::UpdateStateVariables().
std::vector<double> AbstractOdeSystem::mParameters [protected] |
Vector containing parameters.
Definition at line 111 of file AbstractOdeSystem.hpp.
Referenced by GetNumberOfParameters(), GetParameter(), serialize(), and SetParameter().
boost::shared_ptr<AbstractOdeSystemInformation> AbstractOdeSystem::mpSystemInfo [protected] |
Information about the concrete ODE system class.
Subclasses need to set this in their constructor to point to an instance of a suitable class. See for example the OdeSystemInformation class.
Definition at line 119 of file AbstractOdeSystem.hpp.
Referenced by BackwardEulerFoxModel2002Modified::BackwardEulerFoxModel2002Modified(), CombinedOdeSystem::CombinedOdeSystem(), DiFrancescoNoble1985OdeSystem::DiFrancescoNoble1985OdeSystem(), FakeBathCell::FakeBathCell(), FitzHughNagumo1961OdeSystem::FitzHughNagumo1961OdeSystem(), GetInitialConditions(), GetStateVariableNumberByName(), GetStateVariableUnitsByNumber(), GetSystemInformation(), HodgkinHuxleySquidAxon1952OriginalOdeSystem::HodgkinHuxleySquidAxon1952OriginalOdeSystem(), IngeWntSwatCellCycleOdeSystem::IngeWntSwatCellCycleOdeSystem(), BackwardEulerLuoRudyIModel1991::Init(), LuoRudyIModel1991OdeSystem::LuoRudyIModel1991OdeSystem(), Mahajan2008OdeSystem::Mahajan2008OdeSystem(), NhsCellularMechanicsOdeSystem::NhsCellularMechanicsOdeSystem(), rGetParameterNames(), rGetParameterUnits(), rGetVariableNames(), rGetVariableUnits(), SetInitialConditions(), SetInitialConditionsComponent(), TenTusscher2006OdeSystem::TenTusscher2006OdeSystem(), TysonNovak2001OdeSystem::TysonNovak2001OdeSystem(), and WntCellCycleOdeSystem::WntCellCycleOdeSystem().
bool AbstractOdeSystem::mUseAnalyticJacobian [protected] |
Whether to use an analytic Jacobian.
Definition at line 122 of file AbstractOdeSystem.hpp.
Referenced by AbstractOdeSystemWithAnalyticJacobian::AbstractOdeSystemWithAnalyticJacobian(), GetUseAnalyticJacobian(), and serialize().