AbstractCardiacCell.cpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2009
00004 
00005 University of Oxford means the Chancellor, Masters and Scholars of the
00006 University of Oxford, having an administrative office at Wellington
00007 Square, Oxford OX1 2JD, UK.
00008 
00009 This file is part of Chaste.
00010 
00011 Chaste is free software: you can redistribute it and/or modify it
00012 under the terms of the GNU Lesser General Public License as published
00013 by the Free Software Foundation, either version 2.1 of the License, or
00014 (at your option) any later version.
00015 
00016 Chaste is distributed in the hope that it will be useful, but WITHOUT
00017 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00018 FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public
00019 License for more details. The offer of Chaste under the terms of the
00020 License is subject to the License being interpreted in accordance with
00021 English Law and subject to any action against the University of Oxford
00022 being under the jurisdiction of the English Courts.
00023 
00024 You should have received a copy of the GNU Lesser General Public License
00025 along with Chaste. If not, see <http://www.gnu.org/licenses/>.
00026 
00027 */
00028 #include "AbstractCardiacCell.hpp"
00029 
00030 #include <cassert>
00031 #include <iostream>
00032 
00033 AbstractCardiacCell::AbstractCardiacCell(AbstractIvpOdeSolver *pOdeSolver,
00034                                          unsigned numberOfStateVariables,
00035                                          unsigned voltageIndex, 
00036                                          AbstractStimulusFunction* intracellularStimulus)
00037     : AbstractOdeSystem(numberOfStateVariables),
00038       mVoltageIndex(voltageIndex)
00039 {
00040     mpOdeSolver = pOdeSolver;
00041 
00042     // The second clause is to allow for FakeBathCell.
00043     assert(voltageIndex < mNumberOfStateVariables || mNumberOfStateVariables == 0);
00044     mDt = HeartConfig::Instance()->GetOdeTimeStep();
00045 
00046     mpIntracellularStimulus = intracellularStimulus;
00047 
00048     mSetVoltageDerivativeToZero = false;
00049 }
00050 
00051 AbstractCardiacCell::~AbstractCardiacCell()
00052 {}
00053 
00059 void AbstractCardiacCell::Init()
00060 {
00061     SetStateVariables(GetInitialConditions());
00062 }
00063 
00064 
00069 OdeSolution AbstractCardiacCell::Compute(double tStart, double tEnd)
00070 {
00071     return mpOdeSolver->Solve(this, rGetStateVariables(), tStart, tEnd, mDt, mDt);
00072 }
00073 
00074 
00079 void AbstractCardiacCell::ComputeExceptVoltage(double tStart, double tEnd)
00080 {
00081     double saved_voltage = GetVoltage();
00082 
00083     mSetVoltageDerivativeToZero = true;
00084     mpOdeSolver->SolveAndUpdateStateVariable(this, tStart, tEnd, mDt);
00085     mSetVoltageDerivativeToZero = false;
00086 
00087     SetVoltage(saved_voltage);
00088 
00089     VerifyStateVariables();
00090 }
00091 
00092 void AbstractCardiacCell::SetVoltage(double voltage)
00093 {
00094     rGetStateVariables()[mVoltageIndex] = voltage;
00095 }
00096 
00097 double AbstractCardiacCell::GetVoltage()
00098 {
00099     return rGetStateVariables()[mVoltageIndex];
00100 }
00101 
00102 unsigned AbstractCardiacCell::GetVoltageIndex()
00103 {
00104     return mVoltageIndex;
00105 }
00106 
00107 void AbstractCardiacCell::SetStimulusFunction(AbstractStimulusFunction *stimulus)
00108 {
00109     SetIntracellularStimulusFunction(stimulus);
00110 }
00111 
00112 double AbstractCardiacCell::GetStimulus(double time)
00113 {
00114     return GetIntracellularStimulus(time);
00115 }
00116 
00117 void AbstractCardiacCell::SetIntracellularStimulusFunction(AbstractStimulusFunction *stimulus)
00118 {
00119     mpIntracellularStimulus = stimulus;
00120 }
00121 
00122 double AbstractCardiacCell::GetIntracellularStimulus(double time)
00123 {
00124     return mpIntracellularStimulus->GetStimulus(time);
00125 }
00126 
00127 
00128 double AbstractCardiacCell::GetIntracellularCalciumConcentration()
00129 {
00130     EXCEPTION("AbstractCardiacCell::GetIntracellularCalciumConcentration() called. Either model has no [Ca_i] or method has not been implemented yet");
00131 }
00132 
00133 
00134 /*
00135  *  METHODS NEEDED BY FAST CARDIAC CELLS
00136  */    
00137 void AbstractCardiacCell::SetState(CellModelState state)
00138 {
00139     EXCEPTION("Non fast-slow cell model being used in a fast-slow problem.");
00140 }
00141     
00142 void AbstractCardiacCell::SetSlowValues(const std::vector<double> &rSlowValues)
00143 {
00144     EXCEPTION("Non fast-slow cell model being used in a fast-slow problem.");
00145 }
00146 
00147 void AbstractCardiacCell::GetSlowValues(std::vector<double>& rSlowValues)
00148 {
00149     EXCEPTION("Non fast-slow cell model being used in a fast-slow problem.");
00150 }
00151 
00152 bool AbstractCardiacCell::IsFastOnly()
00153 {
00154     EXCEPTION("Non fast-slow cell model being used in a fast-slow problem.");
00155 }
00156 
00157 unsigned AbstractCardiacCell::GetNumSlowValues()
00158 {
00159     EXCEPTION("Non fast-slow cell model being used in a fast-slow problem.");
00160 }
00161 
00162 void AbstractCardiacCell::AdjustOutOfRangeSlowValues(std::vector<double>& rSlowValues)
00163 {
00164     EXCEPTION("Non fast-slow cell model being used in a fast-slow problem.");
00165 }
00166 

Generated on Wed Mar 18 12:51:51 2009 for Chaste by  doxygen 1.5.5