Chaste Release::3.1
AbstractCvodeCell.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 #ifdef CHASTE_CVODE
00037 #ifndef _ABSTRACTCVODECELL_HPP_
00038 #define _ABSTRACTCVODECELL_HPP_
00039 
00040 // Serialization headers
00041 #include "ChasteSerialization.hpp"
00042 #include "ClassIsAbstract.hpp"
00043 #include <boost/serialization/base_object.hpp>
00044 #include <boost/shared_ptr.hpp>
00045 #include <boost/serialization/shared_ptr.hpp>
00046 
00047 // Chaste headers
00048 #include "AbstractOdeSystemInformation.hpp"
00049 #include "AbstractStimulusFunction.hpp"
00050 #include "AbstractIvpOdeSolver.hpp"
00051 #include "AbstractCvodeSystem.hpp"
00052 #include "AbstractCardiacCellInterface.hpp"
00053 #include "VectorHelperFunctions.hpp"
00054 
00055 
00078 class AbstractCvodeCell : public AbstractCardiacCellInterface, public AbstractCvodeSystem
00079 {
00080 private:
00082     friend class boost::serialization::access;
00089     template<class Archive>
00090     void serialize(Archive & archive, const unsigned int version)
00091     {
00092         // This calls serialize on the base classes.
00093         archive & boost::serialization::base_object<AbstractCvodeSystem>(*this);
00094         archive & boost::serialization::base_object<AbstractCardiacCellInterface>(*this);
00095         archive & mMaxDt;
00096     }
00097 
00098 protected:
00100     double mMaxDt;
00101 
00102 public:
00113     AbstractCvodeCell(boost::shared_ptr<AbstractIvpOdeSolver> pSolver,
00114                       unsigned numberOfStateVariables,
00115                       unsigned voltageIndex,
00116                       boost::shared_ptr<AbstractStimulusFunction> pIntracellularStimulus);
00117 
00121     virtual ~AbstractCvodeCell();
00122 
00127     double GetVoltage();
00128 
00133     void SetVoltage(double voltage);
00134 
00140     void SetTimestep(double maxDt);
00141 
00152     virtual void SolveAndUpdateState(double tStart, double tEnd);
00153 
00166     OdeSolution Compute(double tStart, double tEnd, double tSamp=0.0);
00167 
00175     void ComputeExceptVoltage(double tStart, double tEnd);
00176 
00182     void SetVoltageDerivativeToZero(bool clamp=true);
00183 
00193     unsigned GetNumberOfStateVariables() const;
00194 
00204     unsigned GetNumberOfParameters() const;
00205 
00215     std::vector<double> GetStdVecStateVariables();
00216 
00226     const std::vector<std::string>& rGetStateVariableNames() const;
00227 
00237     void SetStateVariables(const std::vector<double>& rVariables);
00238 
00243     void SetStateVariables(const N_Vector& rVariables);
00244 
00255     void SetStateVariable(unsigned index, double newValue);
00256 
00267     void SetStateVariable(const std::string& rName, double newValue);
00268 
00280     double GetAnyVariable(const std::string& rName, double time=0.0);
00281 
00292     double GetParameter(const std::string& rParameterName);
00293 
00302     double GetParameter(unsigned parameterIndex);
00303 
00314     void SetParameter(const std::string& rParameterName, double value);
00315 
00324     void SetParameter(unsigned parameterIndex, double value);
00325 
00326 };
00327 
00328 CLASS_IS_ABSTRACT(AbstractCvodeCell)
00329 
00330 #endif // _ABSTRACTCVODECELL_HPP_
00331 #endif // CHASTE_CVODE