AbstractCardiacCell.hpp

00001 /*
00002 
00003 Copyright (C) University of Oxford, 2005-2010
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 
00029 #ifndef ABSTRACTCARDIACCELL_HPP_
00030 #define ABSTRACTCARDIACCELL_HPP_
00031 
00032 #include "ChasteSerialization.hpp"
00033 #include "ClassIsAbstract.hpp"
00034 #include <boost/serialization/base_object.hpp>
00035 #include <boost/shared_ptr.hpp>
00036 #include <boost/serialization/shared_ptr.hpp>
00037 
00038 #include "AbstractOdeSystem.hpp"
00039 #include "AbstractIvpOdeSolver.hpp"
00040 #include "AbstractStimulusFunction.hpp"
00041 #include "HeartConfig.hpp"
00042 
00043 #include <vector>
00044 
00045 typedef enum _CellModelState
00046 {
00047     STATE_UNSET = 0,
00048     FAST_VARS_ONLY,
00049     ALL_VARS
00050 } CellModelState;
00051 
00062 class AbstractCardiacCell : public AbstractOdeSystem
00063 {
00064 private:
00066     friend class boost::serialization::access;
00073     template<class Archive>
00074     void serialize(Archive & archive, const unsigned int version)
00075     {
00076         // This calls serialize on the base class.
00077         archive & boost::serialization::base_object<AbstractOdeSystem>(*this);
00078         archive & mDt;
00079         archive & mSetVoltageDerivativeToZero;
00080         // archive & mVoltageIndex; - always set by constructor - called by concrete class
00081         // archive & mpOdeSolver; - always set by constructor - called by concrete class
00082         // archive & mpIntracellularStimulus; - always set by constructor - called by concrete class
00083     }
00084 
00085 protected:
00087     unsigned mVoltageIndex;
00089     boost::shared_ptr<AbstractIvpOdeSolver> mpOdeSolver;
00091     double mDt;
00093     boost::shared_ptr<AbstractStimulusFunction> mpIntracellularStimulus;
00094 
00100     bool mSetVoltageDerivativeToZero;
00101 
00102 public:
00110     AbstractCardiacCell(boost::shared_ptr<AbstractIvpOdeSolver> pOdeSolver,
00111                         unsigned numberOfStateVariables,
00112                         unsigned voltageIndex,
00113                         boost::shared_ptr<AbstractStimulusFunction> pIntracellularStimulus);
00114 
00116     virtual ~AbstractCardiacCell();
00117 
00123     void Init();
00124 
00132     virtual OdeSolution Compute(double tStart, double tEnd);
00133 
00141     virtual void ComputeExceptVoltage(double tStart, double tEnd);
00142 
00147     virtual double GetIIonic() = 0;
00148 
00152     void SetVoltage(double voltage);
00153 
00158     double GetVoltage();
00159 
00161     unsigned GetVoltageIndex();
00162 
00168     void SetStimulusFunction(boost::shared_ptr<AbstractStimulusFunction> pStimulus);
00169 
00175     double GetStimulus(double time);
00176 
00180     void SetIntracellularStimulusFunction(boost::shared_ptr<AbstractStimulusFunction> pStimulus);
00181 
00186     double GetIntracellularStimulus(double time);
00187 
00195     virtual double GetIntracellularCalciumConcentration();
00196 
00203     virtual void VerifyStateVariables()
00204     {
00211 //        for(std::set<unsigned>::iterator iter = mGatingVariableIndices.begin();
00212 //            iter != mGatingVariableIndices.end();
00213 //            ++iter)
00214 //        {
00215 //            double value = mStateVariables[*iter];
00216 //            if(value<0.0)
00217 //            {
00218 //                std::stringstream error;
00219 //                error << "State variable " << *iter << ", a gating variable, has gone negative";
00220 //                EXCEPTION(DumpState(error.str()));
00221 //            }
00222 //            if(value>1.0)
00223 //            {
00224 //                std::stringstream error;
00225 //                error << "State variable " << *iter << ", a gating variable, has become greater than one";
00226 //                EXCEPTION(DumpState(error.str()));
00227 //            }
00228 //        }
00229 //
00230 //        for(std::set<unsigned>::iterator iter = mConcentrationIndices.begin();
00231 //            iter != mConcentrationIndices.end();
00232 //            ++iter)
00233 //        {
00234 //            if(mStateVariables[*iter] < 0.0)
00235 //            {
00236 //                std::stringstream error;
00237 //                error << "State variable " << *iter << ", a concentration, has gone negative";
00238 //                EXCEPTION(DumpState(error.str()));
00239 //            }
00240 //        }
00241     }
00242 
00243 
00244 
00246     //  METHODS NEEDED BY FAST CARDIAC CELLS
00248 
00260     virtual void SetState(CellModelState state);
00261 
00269     virtual void SetSlowValues(const std::vector<double> &rSlowValues);
00270 
00278     virtual void GetSlowValues(std::vector<double>& rSlowValues);
00279 
00284     virtual bool IsFastOnly();
00285 
00298     virtual void AdjustOutOfRangeSlowValues(std::vector<double>& rSlowValues);
00299 
00306     virtual unsigned GetNumSlowValues();
00307 
00314     const boost::shared_ptr<AbstractStimulusFunction> GetStimulusFunction() const;
00315 
00322     const boost::shared_ptr<AbstractIvpOdeSolver> GetSolver() const;
00323 
00324 };
00325 
00326 CLASS_IS_ABSTRACT(AbstractCardiacCell)
00327 
00328 #endif /*ABSTRACTCARDIACCELL_HPP_*/

Generated by  doxygen 1.6.2