CEPS  24.01
Cardiac ElectroPhysiology Simulator
AbstractIonicModel.cpp
Go to the documentation of this file.
1 /*~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2  This file is part of CEPS.
3 
4  CEPS is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  CEPS is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with CEPS (see file LICENSE at root of project).
16  If not, see <https://www.gnu.org/licenses/>.
17 
18 
19  Copyright 2019-2024 Inria, Universite de Bordeaux
20 
21  Authors, in alphabetical order:
22 
23  Pierre-Elliott BECUE, Florian CARO, Yves COUDIERE(*), Andjela DAVIDOVIC,
24  Charlie DOUANLA-LONTSI, Marc FUENTES, Mehdi JUHOOR, Michael LEGUEBE(*),
25  Pauline MIGERDITICHAN, Valentin PANNETIER(*), Nejib ZEMZEMI.
26  * : currently active authors
27 
28 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~*/
31 
34 {
37 }
38 
41 {
42  return m_name;
43 }
44 
45 Unknown*
47 {
48  return m_unknown;
49 }
50 
53 {
54  return m_cm;
55 }
56 
57 void
59 {
60  m_cm = cm;
61 }
62 
65 {
66  if (cepsUnit)
68  return m_paperCm;
69 }
70 
73 {
75 }
76 
77 void
79 {
80  m_stims.push_back(stim);
81 }
82 
85 {
86  CepsReal res = 0.;
87  for (ScalarSourceTerm* stim: m_stims)
88  res += stim->getValue(x,t);
89  return convertCurrentFromCepsUnit(res);
90 }
91 
94 {
95  return m_nStateVars;
96 }
97 
100 {
102  "Requesting name of state variable #" << i << " of ionic model which has " << m_nStateVars
103  );
104  return m_stateVarNames[i];
105 }
106 
107 CepsReal
109 {
110  return v;
111 }
112 
113 CepsReal
115 {
116  return v;
117 }
118 
119 CepsReal
121 {
122  return dtv;
123 }
124 
125 CepsReal
127 {
128  return i;
129 }
130 
131 CepsReal
133 {
134  return cm;
135 }
136 
137 CepsReal
139 {
140  return cm;
141 }
142 
143 void
145 {
146  m_solver = solver;
147 }
148 
151 {
152  return m_solver;
153 }
154 
155 // Protected ---------------------------------------------------------------------------------------
156 
159  Unknown* u,
160  const CepsSet<CepsAttribute>& attrs
161 ):
162  ceps::HoldsAttributes(attrs),
163  m_unknown (u),
164  m_constants (nullptr),
165  m_dconstants(nullptr),
166  m_cm (nullptr),
167  m_nStateVars(0),
168  m_name ("")
169 {
171  "Pointer to unknown is null"
172  );
173 }
174 
175 CepsReal
177 {
178  if (ceps::isNullPtr(m_cm))
179  return m_paperCm;
180 
181  return convertCmFromCepsUnit(m_cm->getValue(dof,t));
182 }
183 
184 CepsReal
186 {
187  return 1/(2.+std::expm1((v-c)/k));
188 }
189 
190 CepsReal
192 {
193  return std::exp(-std::pow(v-c,2)/s);
194 }
195 
196 CepsReal
198 {
199  if (std::abs(u)<std::numeric_limits<CepsReal>::epsilon()*1.e2)
200  return 1;
201  else
202  return u/std::expm1(u);
203 }
#define CEPS_ABORT_IF(condition, message)
Stops the execution with a message if condition is true. If testing is enabled, only throws a runtime...
std::basic_string< CepsChar > CepsString
C++ format string.
Definition: CepsTypes.hpp:128
std::set< _Type, _Compare, _Alloc > CepsSet
C++ set.
Definition: CepsTypes.hpp:209
bool CepsBool
Booleans.
Definition: CepsTypes.hpp:124
std::make_unsigned_t< CepsInt > CepsUInt
Unsigned version on CepsInt.
Definition: CepsTypes.hpp:109
float CepsReal
Need single precision floating point.
Definition: CepsTypes.hpp:100
CepsReal gaussian(CepsReal x, CepsReal c, CepsReal s) const
Function often used in rates evaluations.
Unknown * getUnknown() const
The unknown object of the transmembrane voltage.
IonicSolver * getLinkedSolver() const
Get link to solver.
IonicSolver * m_solver
Link to solver, set when solver is created.
CepsReal m_paperStim
Original stim amplitude.
ScalarField< DegreeOfFreedom > * m_cm
Link to coef Cm of the PDE, for unit conversion.
virtual CepsReal convertDtvToCepsUnit(const CepsReal &dtv) const
Convert current from ionic model units to ceps units (mV ms-1). Does nothing by default.
ScalarField< DegreeOfFreedom > * getCm() const
Link to Cm coefficient of PDE.
CepsString getName() const
Name of the solver for info display.
virtual CepsReal convertCmFromCepsUnit(const CepsReal &cm) const
Convert capacitance from ceps units (uF/cm2) to ionic model units. Does nothing by default.
CepsReal * m_dconstants
Constant parameters of the model, computed from others.
CepsUInt m_nStateVars
Dimensionality of the ODE system, -1 for vm.
virtual CepsReal convertCurrentFromCepsUnit(const CepsReal &i) const
Convert current from ionic model units to ceps units (uA per cm2). Does nothing by default.
virtual CepsReal convertCmToCepsUnit(const CepsReal &cm) const
Convert capacitance from ionic model units to ceps units (uF/cm2). Does nothing by default.
CepsReal * m_constants
Constant parameters of the model, from inputs.
virtual CepsUInt getNbStateVariables() const
The number of state variables, except transmembrane voltage.
AbstractIonicModel(Unknown *u, const CepsSet< CepsAttribute > &attrs={})
Called only by derived classes.
CepsReal getStimulation(DegreeOfFreedom *x, CepsReal t) const
Get the sum of all stimulations at time t and dof x.
CepsReal uOverExpm1u(CepsReal u) const
Functions u/(1-exp(u)) that returns 2 (from expansion around 0)
CepsVector< CepsString > m_stateVarNames
Names of state variables.
virtual CepsReal convertVoltageToCepsUnit(const CepsReal &v) const
Convert voltage from ionic model units to ceps units (mV). Does nothing by default.
CepsReal getCmInternal(CepsReal t, DegreeOfFreedom *dof) const
Get either the value of cm on dof, or the default value from the paper.
CepsReal getPaperStim() const
Get the original amplitude of stimulation, converted into ceps units.
Unknown * m_unknown
Pointer on unknown on which the model applies.
virtual ~AbstractIonicModel()
Destructor.
void addStimulation(ScalarSourceTerm *stim)
Links the model to a stimulation function, needed for computation of _ki.
CepsReal getPaperCm(CepsBool cepsUnit) const
Get the original value of Cm used in paper.
CepsVector< ScalarSourceTerm * > m_stims
Link to excitations.
void setCm(ScalarField< DegreeOfFreedom > *)
Link to Cm coefficient of PDE.
CepsString getStateVariableName(CepsUInt i) const
Gives the name of the i-th state variable.
virtual CepsReal convertVoltageFromCepsUnit(const CepsReal &v) const
Convert voltage from ceps units (mV) to ionic model units. Does nothing by default.
CepsReal m_paperCm
Original value of Cm.
CepsReal sigmoid(CepsReal x, CepsReal c, CepsReal k) const
Function often used in rates evaluations.
CepsString m_name
A label for display.
void setLinkedSolver(IonicSolver *solver)
Links instance to solver.
A degree of freedom for any kind of problem The dof can be associated to a geometrical element or not...
A Field is an object wrapped around a SAFunc functor, defined on at least one domain.
Definition: Field.hpp:80
Groups two ODE solvers for ionic variables and interacts with cardiac problem.
Definition: IonicSolver.hpp:44
Source term, essentially a ScalarField.
Definition: SourceTerm.hpp:50
A class used to defined an unknown of a PDE problem The unknown can be defined on a specific region,...
Definition: Unknown.hpp:45
A namespace for all utility methods.
void destroyTabular(_Type &)
Destroy[delete] any type.
Definition: CepsMemory.hpp:149
CepsBool isNullPtr(_Type *ptr)
Tells if passed pointer is null.
Definition: CepsMemory.hpp:45