Chaste  Release::2017.1
AbstractCardiacCellInterface.cpp
1 /*
2 
3 Copyright (c) 2005-2017, University of Oxford.
4 All rights reserved.
5 
6 University of Oxford means the Chancellor, Masters and Scholars of the
7 University of Oxford, having an administrative office at Wellington
8 Square, Oxford OX1 2JD, UK.
9 
10 This file is part of Chaste.
11 
12 Redistribution and use in source and binary forms, with or without
13 modification, are permitted provided that the following conditions are met:
14  * Redistributions of source code must retain the above copyright notice,
15  this list of conditions and the following disclaimer.
16  * Redistributions in binary form must reproduce the above copyright notice,
17  this list of conditions and the following disclaimer in the documentation
18  and/or other materials provided with the distribution.
19  * Neither the name of the University of Oxford nor the names of its
20  contributors may be used to endorse or promote products derived from this
21  software without specific prior written permission.
22 
23 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
24 AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
25 IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
26 ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
27 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
28 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
29 GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
30 HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31 LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
32 OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
33 
34 */
35 
36 #include "HeartConfig.hpp" // First for Boost 1.33/PETSc 2.2
37 #include "AbstractCardiacCellInterface.hpp"
38 #include "Exception.hpp"
39 
40 #include "Citations.hpp"
41 static PetscBool CardiacCellChasteCite = PETSC_FALSE;
42 const char CardiacCellChasteCitation[] = "@article{cooper2015cce,\n"
43 " title = {{Cellular cardiac electrophysiology modelling with Chaste and CellML}},\n"
44 " author = {Cooper, Jonathan and Spiteri, Raymond and Mirams, Gary R},\n"
45 " year = {2015},\n"
46 " journal = {Frontiers in Physiology},\n"
47 " pages = {511},\n"
48 " url = {http://journal.frontiersin.org/Journal/10.3389/fphys.2014.00511},\n"
49 " volume = {5},\n"
50 " doi = {10.3389/fphys.2014.00511},\n"
51 "}\n";
52 
54  boost::shared_ptr<AbstractIvpOdeSolver> pOdeSolver,
55  unsigned voltageIndex,
56  boost::shared_ptr<AbstractStimulusFunction> pIntracellularStimulus)
57  : mVoltageIndex(voltageIndex),
58  mpOdeSolver(pOdeSolver),
59  mpIntracellularStimulus(pIntracellularStimulus),
60  mSetVoltageDerivativeToZero(false),
61  mIsUsedInTissue(false),
62  mHasDefaultStimulusFromCellML(false),
63  mFixedVoltage(DOUBLE_UNSET)
64 {
65  // Record a reference for the calculations performed using this class,
66  // can be extracted with the '-citations' flag as an argument to any executable.
67  Citations::Register(CardiacCellChasteCitation, &CardiacCellChasteCite);
68 }
69 
70 
72 {
73 }
74 
75 
77 {
78  return mVoltageIndex;
79 }
80 
81 
82 void AbstractCardiacCellInterface::SetStimulusFunction(boost::shared_ptr<AbstractStimulusFunction> pStimulus)
83 {
85 }
86 
87 
89 {
90  return GetIntracellularStimulus(time);
91 }
92 
93 
94 void AbstractCardiacCellInterface::SetIntracellularStimulusFunction(boost::shared_ptr<AbstractStimulusFunction> pStimulus)
95 {
96  mpIntracellularStimulus = pStimulus;
97 }
98 
99 
101 {
102  return mpIntracellularStimulus->GetStimulus(time);
103 }
104 
105 
107 {
108  double stim;
109  if (mIsUsedInTissue)
110  {
111  // Convert from uA/cm^3 to uA/cm^2 by dividing by Am
113  }
114  else
115  {
116  stim = GetIntracellularStimulus(time);
117  }
118  return stim;
119 }
120 
122 {
123  mIsUsedInTissue = tissue;
124 }
125 
126 boost::shared_ptr<RegularStimulus> AbstractCardiacCellInterface::UseCellMLDefaultStimulus()
127 {
129  EXCEPTION("This class has no default stimulus from CellML metadata.");
130  return boost::shared_ptr<RegularStimulus>();
131 }
132 
134 {
136 }
137 
138 boost::shared_ptr<AbstractStimulusFunction> AbstractCardiacCellInterface::GetStimulusFunction()
139 {
141 }
142 
143 // Methods needed by boost serialization.
144 const boost::shared_ptr<AbstractStimulusFunction> AbstractCardiacCellInterface::GetStimulusFunction() const
145 {
147 }
148 
149 const boost::shared_ptr<AbstractIvpOdeSolver> AbstractCardiacCellInterface::GetSolver() const
150 {
151  return mpOdeSolver;
152 }
153 
154 void AbstractCardiacCellInterface::SetSolver(boost::shared_ptr<AbstractIvpOdeSolver> pSolver)
155 {
156  mpOdeSolver = pSolver;
157 }
158 
160 {
162  if (clamp)
163  {
165  }
166 }
167 
169 {
170  mFixedVoltage = voltage;
171 }
172 
174 {
175  EXCEPTION("AbstractCardiacCellInterface::GetIntracellularCalciumConcentration() called. "
176  "Either model has no [Ca_i] or method has not been implemented yet");
177 }
178 
179 
AbstractCardiacCellInterface(boost::shared_ptr< AbstractIvpOdeSolver > pOdeSolver, unsigned voltageIndex, boost::shared_ptr< AbstractStimulusFunction > pIntracellularStimulus)
boost::shared_ptr< AbstractStimulusFunction > mpIntracellularStimulus
const boost::shared_ptr< AbstractIvpOdeSolver > GetSolver() const
virtual double GetVoltage()=0
#define EXCEPTION(message)
Definition: Exception.hpp:143
void SetStimulusFunction(boost::shared_ptr< AbstractStimulusFunction > pStimulus)
void SetIntracellularStimulusFunction(boost::shared_ptr< AbstractStimulusFunction > pStimulus)
const double DOUBLE_UNSET
Definition: Exception.hpp:56
virtual boost::shared_ptr< RegularStimulus > UseCellMLDefaultStimulus()
static void Register(const char *pCitation, PetscBool *pSet)
Definition: Citations.cpp:43
virtual void SetVoltageDerivativeToZero(bool clamp=true)
boost::shared_ptr< AbstractStimulusFunction > GetStimulusFunction()
boost::shared_ptr< AbstractIvpOdeSolver > mpOdeSolver
double GetSurfaceAreaToVolumeRatio() const
void SetSolver(boost::shared_ptr< AbstractIvpOdeSolver > pSolver)
static HeartConfig * Instance()