#include <AbstractOdeSystem.hpp>
Public Member Functions | |
AbstractOdeSystem (unsigned numberOfStateVariables) | |
virtual | ~AbstractOdeSystem () |
virtual void | EvaluateYDerivatives (double time, const std::vector< double > &rY, std::vector< double > &rDY)=0 |
void | SetDefaultInitialConditions (const std::vector< double > &rInitialConditions) |
void | SetDefaultInitialCondition (unsigned index, double initialCondition) |
std::vector< double > | GetInitialConditions () const |
void | SetStateVariables (const std::vector< double > &rStateVariables) |
virtual bool | CalculateStoppingEvent (double time, const std::vector< double > &rY) |
virtual double | CalculateRootFunction (double time, const std::vector< double > &rY) |
bool | GetUseAnalyticJacobian () |
const std::vector< double > & | rGetConstStateVariables () const |
Protected Member Functions | |
std::string | DumpState (const std::string &rMessage, std::vector< double > Y=std::vector< double >()) |
Protected Attributes | |
bool | mUseAnalyticJacobian |
Private Member Functions | |
template<class Archive> | |
void | save (Archive &archive, const unsigned int version) const |
template<class Archive> | |
void | load (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 in our base class AbstractParameterisedSystem (see also GetNumberOfStateVariables(), SetStateVariables() and rGetStateVariables()), although this is not essential - the vector may be empty, in which 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 of our base class.
Information about what the parameters and state variables represent is provided by a subclass of AbstractOdeSystemInformation. Various wrapper methods (e.g. rGetStateVariableNames()) are provided in our base 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 79 of file AbstractOdeSystem.hpp.
AbstractOdeSystem::AbstractOdeSystem | ( | unsigned | numberOfStateVariables | ) |
Constructor.
numberOfStateVariables | the number of state variables in the ODE system |
Definition at line 35 of file AbstractOdeSystem.cpp.
AbstractOdeSystem::~AbstractOdeSystem | ( | ) | [virtual] |
Virtual destructor since we have virtual methods.
Definition at line 41 of file AbstractOdeSystem.cpp.
void AbstractOdeSystem::save | ( | Archive & | archive, | |
const unsigned int | version | |||
) | const [inline, private] |
Archive the member variables.
archive | the archive | |
version | the current version of this class |
Definition at line 94 of file AbstractOdeSystem.hpp.
References AbstractParameterisedSystem< std::vector< double > >::mNumberOfStateVariables, AbstractParameterisedSystem< std::vector< double > >::mParameters, AbstractParameterisedSystem< std::vector< double > >::mStateVariables, mUseAnalyticJacobian, and AbstractParameterisedSystem< std::vector< double > >::rGetParameterNames().
void AbstractOdeSystem::load | ( | Archive & | archive, | |
const unsigned int | version | |||
) | [inline, private] |
Archive the member variables.
archive | the archive | |
version | the current version of this class |
Definition at line 121 of file AbstractOdeSystem.hpp.
References EXCEPTION, AbstractParameterisedSystem< std::vector< double > >::mNumberOfStateVariables, AbstractParameterisedSystem< std::vector< double > >::mParameters, AbstractParameterisedSystem< std::vector< double > >::mStateVariables, mUseAnalyticJacobian, and AbstractParameterisedSystem< std::vector< double > >::rGetParameterNames().
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 50 of file AbstractOdeSystem.cpp.
References AbstractParameterisedSystem< std::vector< double > >::rGetStateVariableNames(), and AbstractParameterisedSystem< std::vector< double > >::rGetStateVariables().
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 >, Kerchoffs2003ContractionModel, Nash2004ContractionModel, NhsContractionModel, FakeBathCell, FitzHughNagumo1961OdeSystem, CML_noble_varghese_kohl_noble_1998_basic_with_sac, CombinedOdeSystem, Alarcon2004OxygenBasedCellCycleOdeSystem, TysonNovak2001OdeSystem, Mirams2010WntOdeSystem, VanLeeuwen2009WntSwatCellCycleOdeSystem, and WntCellCycleOdeSystem.
Referenced by RungeKuttaFehlbergIvpOdeSolver::CalculateNextYValue(), RungeKutta4IvpOdeSolver::CalculateNextYValue(), RungeKutta2IvpOdeSolver::CalculateNextYValue(), HeunIvpOdeSolver::CalculateNextYValue(), EulerIvpOdeSolver::CalculateNextYValue(), and BackwardEulerIvpOdeSolver::ComputeResidual().
void AbstractOdeSystem::SetDefaultInitialConditions | ( | const std::vector< double > & | rInitialConditions | ) |
Set the default initial conditions for the ODE system. This method DOES NOT change the state variables of the ODE object on which it is called.
rInitialConditions | vector containing initial values for the state variables |
Definition at line 68 of file AbstractOdeSystem.cpp.
References EXCEPTION, AbstractParameterisedSystem< std::vector< double > >::mNumberOfStateVariables, and AbstractParameterisedSystem< std::vector< double > >::mpSystemInfo.
void AbstractOdeSystem::SetDefaultInitialCondition | ( | unsigned | index, | |
double | initialCondition | |||
) |
Set a single component of the default initial conditions for the ODE system. This method DOES NOT change the state variables of the ODE object on which it is called.
index | the index of the state variable in the system | |
initialCondition | the initial value for the state variable |
Definition at line 78 of file AbstractOdeSystem.cpp.
References EXCEPTION, AbstractParameterisedSystem< std::vector< double > >::mNumberOfStateVariables, and AbstractParameterisedSystem< std::vector< double > >::mpSystemInfo.
Referenced by Alarcon2004OxygenBasedCellCycleOdeSystem::Alarcon2004OxygenBasedCellCycleOdeSystem(), Mirams2010WntOdeSystem::Mirams2010WntOdeSystem(), VanLeeuwen2009WntSwatCellCycleOdeSystem::VanLeeuwen2009WntSwatCellCycleOdeSystem(), and WntCellCycleOdeSystem::WntCellCycleOdeSystem().
std::vector< double > AbstractOdeSystem::GetInitialConditions | ( | ) | const |
Get the initial conditions for the ODE system.
Definition at line 88 of file AbstractOdeSystem.cpp.
References AbstractParameterisedSystem< std::vector< double > >::mpSystemInfo.
Referenced by CombinedOdeSystem::CombinedOdeSystem(), AbstractCardiacCell::Init(), WntCellCycleModel::Initialise(), SingleOdeWntCellCycleModel::Initialise(), AbstractVanLeeuwen2009WntSwatCellCycleModel::Initialise(), TysonNovakCellCycleModel::Initialise(), Alarcon2004OxygenBasedCellCycleModel::Initialise(), NhsContractionModel::NhsContractionModel(), AbstractWntOdeBasedCellCycleModel::ResetForDivision(), TysonNovakCellCycleModel::ResetForDivision(), Alarcon2004OxygenBasedCellCycleModel::ResetForDivision(), and AbstractCardiacCell::ResetToInitialConditions().
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 94 of file AbstractOdeSystem.cpp.
References EXCEPTION, AbstractParameterisedSystem< std::vector< double > >::mNumberOfStateVariables, and AbstractParameterisedSystem< std::vector< double > >::mStateVariables.
Referenced by Alarcon2004OxygenBasedCellCycleOdeSystem::Alarcon2004OxygenBasedCellCycleOdeSystem(), CombinedOdeSystem::CombinedOdeSystem(), AbstractCardiacCell::Init(), WntCellCycleModel::Initialise(), SingleOdeWntCellCycleModel::Initialise(), AbstractVanLeeuwen2009WntSwatCellCycleModel::Initialise(), TysonNovakCellCycleModel::Initialise(), Alarcon2004OxygenBasedCellCycleModel::Initialise(), Mirams2010WntOdeSystem::Mirams2010WntOdeSystem(), NhsContractionModel::NhsContractionModel(), TysonNovakCellCycleModel::ResetForDivision(), AbstractCardiacCell::ResetToInitialConditions(), AbstractOdeBasedCellCycleModel::SetProteinConcentrationsForTestsOnly(), CellCycleModelOdeHandler::SetStateVariables(), AbstractCardiacTissue< ELEMENT_DIM, SPACE_DIM >::SolveCellSystems(), TysonNovak2001OdeSystem::TysonNovak2001OdeSystem(), VanLeeuwen2009WntSwatCellCycleOdeSystem::VanLeeuwen2009WntSwatCellCycleOdeSystem(), and WntCellCycleOdeSystem::WntCellCycleOdeSystem().
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 Alarcon2004OxygenBasedCellCycleOdeSystem, TysonNovak2001OdeSystem, VanLeeuwen2009WntSwatCellCycleOdeSystem, and WntCellCycleOdeSystem.
Definition at line 45 of file AbstractOdeSystem.cpp.
Referenced by CalculateRootFunction(), RungeKuttaFehlbergIvpOdeSolver::InternalSolve(), AbstractOneStepIvpOdeSolver::InternalSolve(), RungeKuttaFehlbergIvpOdeSolver::Solve(), CvodeAdaptor::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 TysonNovak2001OdeSystem, VanLeeuwen2009WntSwatCellCycleOdeSystem, and WntCellCycleOdeSystem.
Definition at line 103 of file AbstractOdeSystem.cpp.
References CalculateStoppingEvent().
bool AbstractOdeSystem::GetUseAnalyticJacobian | ( | ) |
Get whether an analytic Jacobian is used.
Definition at line 109 of file AbstractOdeSystem.cpp.
References mUseAnalyticJacobian.
Referenced by BackwardEulerIvpOdeSolver::ComputeJacobian().
const std::vector< double > & AbstractOdeSystem::rGetConstStateVariables | ( | ) | const |
Definition at line 114 of file AbstractOdeSystem.cpp.
References AbstractParameterisedSystem< std::vector< double > >::mStateVariables.
bool AbstractOdeSystem::mUseAnalyticJacobian [protected] |
Whether to use an analytic Jacobian.
Definition at line 153 of file AbstractOdeSystem.hpp.
Referenced by AbstractOdeSystemWithAnalyticJacobian::AbstractOdeSystemWithAnalyticJacobian(), GetUseAnalyticJacobian(), load(), and save().