AbstractCardiacCell.cpp
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #include "AbstractCardiacCell.hpp"
00029
00030 #include <cassert>
00031 #include <iostream>
00032
00033 AbstractCardiacCell::AbstractCardiacCell(boost::shared_ptr<AbstractIvpOdeSolver> pOdeSolver,
00034 unsigned numberOfStateVariables,
00035 unsigned voltageIndex,
00036 boost::shared_ptr<AbstractStimulusFunction> pIntracellularStimulus)
00037 : AbstractOdeSystem(numberOfStateVariables),
00038 mVoltageIndex(voltageIndex),
00039 mpOdeSolver(pOdeSolver),
00040 mDt(HeartConfig::Instance()->GetOdeTimeStep()),
00041 mpIntracellularStimulus(pIntracellularStimulus),
00042 mSetVoltageDerivativeToZero(false)
00043 {
00044
00045 assert(voltageIndex < mNumberOfStateVariables || mNumberOfStateVariables == 0);
00046 }
00047
00048 AbstractCardiacCell::~AbstractCardiacCell()
00049 {
00050 }
00051
00052 void AbstractCardiacCell::Init()
00053 {
00054 SetStateVariables(GetInitialConditions());
00055 }
00056
00057
00058 OdeSolution AbstractCardiacCell::Compute(double tStart, double tEnd)
00059 {
00060 return mpOdeSolver->Solve(this, rGetStateVariables(), tStart, tEnd, mDt, mDt);
00061 }
00062
00063
00064 void AbstractCardiacCell::ComputeExceptVoltage(double tStart, double tEnd)
00065 {
00066 double saved_voltage = GetVoltage();
00067
00068 mSetVoltageDerivativeToZero = true;
00069 mpOdeSolver->SolveAndUpdateStateVariable(this, tStart, tEnd, mDt);
00070 mSetVoltageDerivativeToZero = false;
00071
00072 SetVoltage(saved_voltage);
00073
00074 VerifyStateVariables();
00075 }
00076
00077 void AbstractCardiacCell::SetVoltage(double voltage)
00078 {
00079 rGetStateVariables()[mVoltageIndex] = voltage;
00080 }
00081
00082 double AbstractCardiacCell::GetVoltage()
00083 {
00084 return rGetStateVariables()[mVoltageIndex];
00085 }
00086
00087 unsigned AbstractCardiacCell::GetVoltageIndex()
00088 {
00089 return mVoltageIndex;
00090 }
00091
00092 void AbstractCardiacCell::SetStimulusFunction(boost::shared_ptr<AbstractStimulusFunction> pStimulus)
00093 {
00094 SetIntracellularStimulusFunction(pStimulus);
00095 }
00096
00097 double AbstractCardiacCell::GetStimulus(double time)
00098 {
00099 return GetIntracellularStimulus(time);
00100 }
00101
00102 void AbstractCardiacCell::SetIntracellularStimulusFunction(boost::shared_ptr<AbstractStimulusFunction> pStimulus)
00103 {
00104 mpIntracellularStimulus = pStimulus;
00105 }
00106
00107 double AbstractCardiacCell::GetIntracellularStimulus(double time)
00108 {
00109 return mpIntracellularStimulus->GetStimulus(time);
00110 }
00111
00112
00113 double AbstractCardiacCell::GetIntracellularCalciumConcentration()
00114 {
00115 EXCEPTION("AbstractCardiacCell::GetIntracellularCalciumConcentration() called. Either model has no [Ca_i] or method has not been implemented yet");
00116 }
00117
00118
00119
00120
00121
00122 void AbstractCardiacCell::SetState(CellModelState state)
00123 {
00124 EXCEPTION("Non fast-slow cell model being used in a fast-slow problem.");
00125 }
00126
00127 void AbstractCardiacCell::SetSlowValues(const std::vector<double> &rSlowValues)
00128 {
00129 EXCEPTION("Non fast-slow cell model being used in a fast-slow problem.");
00130 }
00131
00132 void AbstractCardiacCell::GetSlowValues(std::vector<double>& rSlowValues)
00133 {
00134 EXCEPTION("Non fast-slow cell model being used in a fast-slow problem.");
00135 }
00136
00137 bool AbstractCardiacCell::IsFastOnly()
00138 {
00139 EXCEPTION("Non fast-slow cell model being used in a fast-slow problem.");
00140 }
00141
00142 unsigned AbstractCardiacCell::GetNumSlowValues()
00143 {
00144 EXCEPTION("Non fast-slow cell model being used in a fast-slow problem.");
00145 }
00146
00147 void AbstractCardiacCell::AdjustOutOfRangeSlowValues(std::vector<double>& rSlowValues)
00148 {
00149 EXCEPTION("Non fast-slow cell model being used in a fast-slow problem.");
00150 }
00151
00152
00153
00154 const boost::shared_ptr<AbstractStimulusFunction> AbstractCardiacCell::GetStimulusFunction() const
00155 {
00156 return mpIntracellularStimulus;
00157 }
00158
00159 const boost::shared_ptr<AbstractIvpOdeSolver> AbstractCardiacCell::GetSolver() const
00160 {
00161 return mpOdeSolver;
00162 }
00163
00164