AbstractCardiacCellInterface.cpp

00001 /*
00002 
00003 Copyright (c) 2005-2015, 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 #include "HeartConfig.hpp" // First for Boost 1.33/PETSc 2.2
00037 #include "AbstractCardiacCellInterface.hpp"
00038 #include "Exception.hpp"
00039 
00040 #include "Citations.hpp"
00041 static PetscBool CardiacCellChasteCite = PETSC_FALSE;
00042 const char CardiacCellChasteCitation[] = "@article{cooper2015cce,\n"
00043 " title = {{Cellular cardiac electrophysiology modelling with Chaste and CellML}},\n"
00044 "  author = {Cooper, Jonathan and Spiteri, Raymond and Mirams, Gary R},\n"
00045 "  year = {2015},\n"
00046 "  journal = {Frontiers in Physiology},\n"
00047 "  pages = {511},\n"
00048 "  url = {http://journal.frontiersin.org/Journal/10.3389/fphys.2014.00511},\n"
00049 "  volume = {5},\n"
00050 "  doi = {10.3389/fphys.2014.00511},\n"
00051 "}\n";
00052 
00053 AbstractCardiacCellInterface::AbstractCardiacCellInterface(
00054             boost::shared_ptr<AbstractIvpOdeSolver> pOdeSolver,
00055             unsigned voltageIndex,
00056             boost::shared_ptr<AbstractStimulusFunction> pIntracellularStimulus)
00057     : mVoltageIndex(voltageIndex),
00058       mpOdeSolver(pOdeSolver),
00059       mpIntracellularStimulus(pIntracellularStimulus),
00060       mSetVoltageDerivativeToZero(false),
00061       mIsUsedInTissue(false),
00062       mHasDefaultStimulusFromCellML(false),
00063       mFixedVoltage(DOUBLE_UNSET)
00064 {
00065     // Record a reference for the calculations performed using this class,
00066     // can be extracted with the '-citations' flag as an argument to any executable.
00067     Citations::Register(CardiacCellChasteCitation, &CardiacCellChasteCite);
00068 }
00069 
00070 
00071 AbstractCardiacCellInterface::~AbstractCardiacCellInterface()
00072 {
00073 }
00074 
00075 
00076 unsigned AbstractCardiacCellInterface::GetVoltageIndex()
00077 {
00078     return mVoltageIndex;
00079 }
00080 
00081 
00082 void AbstractCardiacCellInterface::SetStimulusFunction(boost::shared_ptr<AbstractStimulusFunction> pStimulus)
00083 {
00084     SetIntracellularStimulusFunction(pStimulus);
00085 }
00086 
00087 
00088 double AbstractCardiacCellInterface::GetStimulus(double time)
00089 {
00090     return GetIntracellularStimulus(time);
00091 }
00092 
00093 
00094 void AbstractCardiacCellInterface::SetIntracellularStimulusFunction(boost::shared_ptr<AbstractStimulusFunction> pStimulus)
00095 {
00096     mpIntracellularStimulus = pStimulus;
00097 }
00098 
00099 
00100 double AbstractCardiacCellInterface::GetIntracellularStimulus(double time)
00101 {
00102     return mpIntracellularStimulus->GetStimulus(time);
00103 }
00104 
00105 
00106 double AbstractCardiacCellInterface::GetIntracellularAreaStimulus(double time)
00107 {
00108     double stim;
00109     if (mIsUsedInTissue)
00110     {
00111         // Convert from uA/cm^3 to uA/cm^2 by dividing by Am
00112         stim = GetIntracellularStimulus(time) / HeartConfig::Instance()->GetSurfaceAreaToVolumeRatio();
00113     }
00114     else
00115     {
00116         stim = GetIntracellularStimulus(time);
00117     }
00118     return stim;
00119 }
00120 
00121 void AbstractCardiacCellInterface::SetUsedInTissueSimulation(bool tissue)
00122 {
00123     mIsUsedInTissue = tissue;
00124 }
00125 
00126 boost::shared_ptr<RegularStimulus> AbstractCardiacCellInterface::UseCellMLDefaultStimulus()
00127 {
00128     assert(!mHasDefaultStimulusFromCellML);
00129     EXCEPTION("This class has no default stimulus from CellML metadata.");
00130     return boost::shared_ptr<RegularStimulus>();
00131 }
00132 
00133 bool AbstractCardiacCellInterface::HasCellMLDefaultStimulus()
00134 {
00135     return mHasDefaultStimulusFromCellML;
00136 }
00137 
00138 boost::shared_ptr<AbstractStimulusFunction> AbstractCardiacCellInterface::GetStimulusFunction()
00139 {
00140     return mpIntracellularStimulus;
00141 }
00142 
00143 // Methods needed by boost serialization.
00144 const boost::shared_ptr<AbstractStimulusFunction> AbstractCardiacCellInterface::GetStimulusFunction() const
00145 {
00146     return mpIntracellularStimulus;
00147 }
00148 
00149 const boost::shared_ptr<AbstractIvpOdeSolver> AbstractCardiacCellInterface::GetSolver() const
00150 {
00151     return mpOdeSolver;
00152 }
00153 
00154 void AbstractCardiacCellInterface::SetSolver(boost::shared_ptr<AbstractIvpOdeSolver> pSolver)
00155 {
00156     mpOdeSolver = pSolver;
00157 }
00158 
00159 void AbstractCardiacCellInterface::SetVoltageDerivativeToZero(bool clamp)
00160 {
00161     mSetVoltageDerivativeToZero = clamp;
00162     if (clamp)
00163     {
00164         mFixedVoltage = GetVoltage();
00165     }
00166 }
00167 
00168 void AbstractCardiacCellInterface::SetFixedVoltage(double voltage)
00169 {
00170     mFixedVoltage = voltage;
00171 }
00172 
00173 double AbstractCardiacCellInterface::GetIntracellularCalciumConcentration()
00174 {
00175     EXCEPTION("AbstractCardiacCellInterface::GetIntracellularCalciumConcentration() called. "
00176               "Either model has no [Ca_i] or method has not been implemented yet");
00177 }
00178 
00179 

Generated by  doxygen 1.6.2