Chaste Release::3.1
AbstractCardiacCellInterface.hpp
00001 /*
00002 
00003 Copyright (c) 2005-2012, University of Oxford.
00004 All rights reserved.
00005 
00006 University of Oxford means the Chancellor, Masters and Scholars of the
00007 University of Oxford, having an administrative office at Wellington
00008 Square, Oxford OX1 2JD, UK.
00009 
00010 This file is part of Chaste.
00011 
00012 Redistribution and use in source and binary forms, with or without
00013 modification, are permitted provided that the following conditions are met:
00014  * Redistributions of source code must retain the above copyright notice,
00015    this list of conditions and the following disclaimer.
00016  * Redistributions in binary form must reproduce the above copyright notice,
00017    this list of conditions and the following disclaimer in the documentation
00018    and/or other materials provided with the distribution.
00019  * Neither the name of the University of Oxford nor the names of its
00020    contributors may be used to endorse or promote products derived from this
00021    software without specific prior written permission.
00022 
00023 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
00024 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
00025 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
00026 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
00027 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
00028 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
00029 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
00030 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
00031 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
00032 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
00033 
00034 */
00035 
00036 #ifndef ABSTRACTCARDIACCELLINTERFACE_HPP_
00037 #define ABSTRACTCARDIACCELLINTERFACE_HPP_
00038 
00039 #include <boost/shared_ptr.hpp>
00040 
00041 #include "ChasteSerialization.hpp"
00042 #include "ChasteSerializationVersion.hpp"
00043 #include "ClassIsAbstract.hpp"
00044 
00045 #include "AbstractIvpOdeSolver.hpp"
00046 #include "AbstractStimulusFunction.hpp"
00047 #include "OdeSolution.hpp"
00048 #include "AbstractLookupTableCollection.hpp"
00049 
00062 class AbstractCardiacCellInterface
00063 {
00064 public:
00077     AbstractCardiacCellInterface(boost::shared_ptr<AbstractIvpOdeSolver> pOdeSolver,
00078                                  unsigned voltageIndex,
00079                                  boost::shared_ptr<AbstractStimulusFunction> pIntracellularStimulus);
00080 
00082     virtual ~AbstractCardiacCellInterface();
00083 
00089     virtual void SetTimestep(double dt)=0;
00090 
00098     virtual unsigned GetNumberOfStateVariables() const=0;
00099 
00105     virtual unsigned GetNumberOfParameters() const=0;
00106 
00116     virtual std::vector<double> GetStdVecStateVariables()=0;
00117 
00125     virtual const std::vector<std::string>& rGetStateVariableNames() const=0;
00126 
00127 
00135     virtual void SetStateVariables(const std::vector<double>& rVariables)=0;
00136 
00145     virtual void SetStateVariable(unsigned index, double newValue)=0;
00146 
00156     virtual void SetStateVariable(const std::string& rName, double newValue)=0;
00157 
00167     virtual double GetAnyVariable(const std::string& rName, double time)=0;
00168 
00177     virtual double GetParameter(const std::string& rParameterName)=0;
00178 
00187     virtual double GetParameter(unsigned parameterIndex)=0;
00188 
00197     virtual void SetParameter(const std::string& rParameterName, double value)=0;
00198 
00207     virtual void SetParameter(unsigned parameterIdx, double value)=0;
00208 
00209 
00218     virtual void SolveAndUpdateState(double tStart, double tEnd)=0;
00219 
00229     virtual OdeSolution Compute(double tStart, double tEnd, double tSamp=0.0)=0;
00230 
00239     virtual void ComputeExceptVoltage(double tStart, double tEnd)=0;
00240 
00270     virtual double GetIIonic(const std::vector<double>* pStateVariables=NULL)=0;
00271 
00276     virtual void SetVoltage(double voltage)=0;
00277 
00281     virtual double GetVoltage()=0;
00282 
00289     unsigned GetVoltageIndex();
00290 
00296     void SetStimulusFunction(boost::shared_ptr<AbstractStimulusFunction> pStimulus);
00297 
00303     double GetStimulus(double time);
00304 
00311     void SetIntracellularStimulusFunction(boost::shared_ptr<AbstractStimulusFunction> pStimulus);
00312 
00320     double GetIntracellularStimulus(double time);
00321 
00328     double GetIntracellularAreaStimulus(double time);
00329 
00338     void SetUsedInTissueSimulation(bool tissue=true);
00339 
00346     virtual void UseCellMLDefaultStimulus();
00347 
00351     bool HasCellMLDefaultStimulus();
00352 
00359     virtual AbstractLookupTableCollection* GetLookupTableCollection()
00360     {
00361         return NULL;
00362     }
00363 
00367     boost::shared_ptr<AbstractStimulusFunction> GetStimulusFunction();
00368 
00375     const boost::shared_ptr<AbstractStimulusFunction> GetStimulusFunction() const;
00376 
00383     const boost::shared_ptr<AbstractIvpOdeSolver> GetSolver() const;
00384 
00389     virtual void SetVoltageDerivativeToZero(bool clamp=true);
00390 
00398     void SetFixedVoltage(double voltage);
00399 
00407     virtual void SetStretch(double stretch)
00408     {
00409     }
00410 
00418     virtual double GetIntracellularCalciumConcentration();
00419 
00420 protected:
00427     unsigned mVoltageIndex;
00428 
00430     boost::shared_ptr<AbstractIvpOdeSolver> mpOdeSolver;
00431 
00433     boost::shared_ptr<AbstractStimulusFunction> mpIntracellularStimulus;
00434 
00440     bool mSetVoltageDerivativeToZero;
00441 
00443     bool mIsUsedInTissue;
00444 
00446     bool mHasDefaultStimulusFromCellML;
00447 
00449     double mFixedVoltage;
00450 
00451 private:
00453     friend class boost::serialization::access;
00460     template<class Archive>
00461     void serialize(Archive & archive, const unsigned int version)
00462     {
00463         // For version 0 these were archived by AbstractCardiacCell, now
00464         // we have AbstractCvodeCells too, so doing it here.
00465         if (version > 0)
00466         {
00467             archive & mSetVoltageDerivativeToZero;
00468             archive & mIsUsedInTissue;
00469             archive & mHasDefaultStimulusFromCellML;
00470             // archive & mFixedVoltage; - this doesn't need archiving as it is reset every PDE time step if used.
00471         }
00472         // archive & mVoltageIndex; - always set by constructor - called by concrete class
00473         // archive & mpOdeSolver; - always set by constructor - called by concrete class
00474         // archive & mpIntracellularStimulus; - always set by constructor - called by concrete class
00475     }
00476 };
00477 
00478 CLASS_IS_ABSTRACT(AbstractCardiacCellInterface)
00479 BOOST_CLASS_VERSION(AbstractCardiacCellInterface, 1)
00480 
00481 #endif /*ABSTRACTCARDIACCELLINTERFACE_HPP_*/