svMultiPhysics
CepMod.h
1 /* Copyright (c) Stanford University, The Regents of the University of California, and others.
2  *
3  * All Rights Reserved.
4  *
5  * See Copyright-SimVascular.txt for additional details.
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining
8  * a copy of this software and associated documentation files (the
9  * "Software"), to deal in the Software without restriction, including
10  * without limitation the rights to use, copy, modify, merge, publish,
11  * distribute, sublicense, and/or sell copies of the Software, and to
12  * permit persons to whom the Software is furnished to do so, subject
13  * to the following conditions:
14  *
15  * The above copyright notice and this permission notice shall be included
16  * in all copies or substantial portions of the Software.
17  *
18  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
19  * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
20  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
21  * PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
22  * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29  */
30 
31 // The classes defined here duplicate the data structures in the Fortran CEPMOD module
32 // defined in CEPMOD.f.
33 
34 // This module defines data structures for cardiac electrophysiology
35 // model equation. It also interfaces with individual modules for
36 // the cellular activation model.
37 
38 
39 #ifndef CEP_MOD_H
40 #define CEP_MOD_H
41 
42 #include "CepModAp.h"
43 #include "CepModBo.h"
44 #include "CepModFn.h"
45 #include "CepModTtp.h"
46 #include "consts.h"
47 
48 #include "Array.h"
49 #include "Vector.h"
50 #include <map>
51 
52 /// @brief Type of cardiac electrophysiology models.
53 enum class ElectrophysiologyModelType {
54  NA = 100,
55  AP = 101,
56  BO = 102,
57  FN = 103,
58  TTP = 104
59 };
60 
61 extern const std::map<std::string,ElectrophysiologyModelType> cep_model_name_to_type;
62 
63 /// @brief Print ElectrophysiologyModelType as a string.
64 static std::ostream &operator << ( std::ostream& strm, ElectrophysiologyModelType type)
65 {
66  const std::map<ElectrophysiologyModelType, std::string> names = {
67  {ElectrophysiologyModelType::NA, "NA"},
68  {ElectrophysiologyModelType::AP,"AP"},
69  {ElectrophysiologyModelType::BO, "BO"},
70  {ElectrophysiologyModelType::FN, "FN"},
71  {ElectrophysiologyModelType::TTP, "TTP"},
72  };
73  return strm << names.at(type);
74 }
75 
76 /// @brief Time integration scheme.
77 enum class TimeIntegratioType {
78  NA = 200,
79  FE = 201,
80  RK4 = 202,
81  CN2 = 203
82 };
83 
84 extern const std::map<std::string,TimeIntegratioType> cep_time_int_to_type;
85 
86 static std::ostream &operator << ( std::ostream& strm, TimeIntegratioType type)
87 {
88  const std::map<TimeIntegratioType, std::string> names = {
89  {TimeIntegratioType::NA, "NA"},
90  {TimeIntegratioType::FE, "FE"},
91  {TimeIntegratioType::RK4, "RK4"},
92  {TimeIntegratioType::CN2, "CN2"},
93  };
94  return strm << names.at(type);
95 }
96 
97 /// @brief Time integration scheme and related parameters
98 class odeType {
99  public:
100  odeType() {};
101 
102  /// @brief Time integration method type
103  TimeIntegratioType tIntType = TimeIntegratioType::NA;
104  //int tIntType = tIntType_NA;
105 
106  /// @brief Max. iterations for Newton-Raphson method
107  int maxItr = 5;
108 
109  /// @brief Absolute tolerance
110  double absTol = 1.E-8;
111 
112  /// @brief Relative tolerance
113  double relTol = 1.E-4;
114 };
115 
116 /// @brief External stimulus type
117 class stimType
118 {
119  public:
120  /// @brief start time
121  double Ts = 0.0;
122 
123  /// @brief duration of stimulus
124  double Td = 0.0;
125 
126  /// @brief cycle length
127  double CL = 0.0;
128 
129  /// @brief stimulus amplitude
130  double A = 0.0;
131 };
132 
133 /// @brief ECG leads type
135 {
136  public:
137  /// @brief Number of leads
138  int num_leads = 0;
139 
140  /// @brief x coordinates
142 
143  /// @brief y coordinates
145 
146  /// @brief z coordinates
148 
149  /// @brief Pseudo ECG over each lead
151 
152  /// @brief Output files
153  std::vector<std::string> out_files;
154 };
155 
156 /// @brief Cardiac electrophysiology model type
158 {
159  public:
160  cepModelType();
161  ~cepModelType();
162 
163  /// @brief Type of cardiac electrophysiology model
164  ElectrophysiologyModelType cepType = ElectrophysiologyModelType::NA;
165 
166  /// @brief Number of state variables
167  int nX = 0;
168 
169  /// @brief Number of gating variables
170  int nG = 0;
171 
172  /// @brief Number of fiber directions
173  int nFn = 0;
174 
175  /// @brief Myocardium zone id, default to epicardium.
176  int imyo = 1;
177 
178  /// @brief Time step for integration
179  double dt = 0.0;
180 
181  /// @brief Constant for stretch-activated-currents
182  double Ksac = 0.0;
183 
184  /// @brief Isotropic conductivity
185  double Diso = 0.0;
186 
187  /// @brief Anisotropic conductivity
189 
190  /// @brief External stimulus
192 
193  /// @brief Time integration options
195 };
196 
197 /// @brief Cardiac electromechanics model type
199 {
200  public:
201  /// @brief Whether electrophysiology and mechanics are coupled
202  bool cpld = false;
203  //bool cpld = .FALSE.
204 
205  /// @brief Whether active stress formulation is employed
206  bool aStress = false;
207  //bool aStress = .FALSE.
208 
209  /// @brief Whether active strain formulation is employed
210  bool aStrain = false;
211  //bool aStrain = .FALSE.
212 
213  /// @brief Local variable integrated in time
214  /// := activation force for active stress model
215  /// := fiber stretch for active strain model
217 };
218 
219 class CepMod
220 {
221  public:
222 
223  /// @brief Whether cardiac electrophysiology is solved
224  bool cepEq;
225 
226  /// @brief Max. dof in cellular activation model
227  int nXion = 0;
228 
229  /// @brief Unknowns stored at all nodes
230  Array<double> Xion;
231 
232  /// @brief Cardiac electromechanics type
234 
235  /// @brief Interface for Aliev-Panfilov cellular activation model.
237 
238  /// @brief Interface for ABueno-Orovio cellular activation model.
240 
241  /// @brief Interface for Fitzhugh-Nagumo cellular activation model.
243 
244  /// @brief Interface for Tusscher-Panfilov cellular activation model.
246 
247  /// @brief ECG leads
249 };
250 
251 #endif
252 
This module defines data structures for Aliev-Panfilov cellular activation model for cardiac electrop...
Definition: CepModAp.h:43
This module defines data structures for Bueno-Orovio cellular activation model for cardiac electrophy...
Definition: CepModBo.h:46
This module defines data structures for Fitzhugh-Nagumo cellular activation model for cardiac electro...
Definition: CepModFn.h:43
Definition: CepMod.h:220
int nXion
Max. dof in cellular activation model.
Definition: CepMod.h:227
CepModBo bo
Interface for ABueno-Orovio cellular activation model.
Definition: CepMod.h:239
bool cepEq
Whether cardiac electrophysiology is solved.
Definition: CepMod.h:224
CepModAp ap
Interface for Aliev-Panfilov cellular activation model.
Definition: CepMod.h:236
CepModFn fn
Interface for Fitzhugh-Nagumo cellular activation model.
Definition: CepMod.h:242
cemModelType cem
Cardiac electromechanics type.
Definition: CepMod.h:233
CepModTtp ttp
Interface for Tusscher-Panfilov cellular activation model.
Definition: CepMod.h:245
Array< double > Xion
Unknowns stored at all nodes.
Definition: CepMod.h:230
ecgLeadsType ecgleads
ECG leads.
Definition: CepMod.h:248
This module defines data structures for ten Tusscher-Panfilov epicardial cellular activation model fo...
Definition: CepModTtp.h:50
Cardiac electromechanics model type.
Definition: CepMod.h:199
bool aStress
Whether active stress formulation is employed.
Definition: CepMod.h:206
bool cpld
Whether electrophysiology and mechanics are coupled.
Definition: CepMod.h:202
bool aStrain
Whether active strain formulation is employed.
Definition: CepMod.h:210
Vector< double > Ya
Local variable integrated in time := activation force for active stress model := fiber stretch for ac...
Definition: CepMod.h:216
Cardiac electrophysiology model type.
Definition: CepMod.h:158
double Diso
Isotropic conductivity.
Definition: CepMod.h:185
int nFn
Number of fiber directions.
Definition: CepMod.h:173
double Ksac
Constant for stretch-activated-currents.
Definition: CepMod.h:182
odeType odes
Time integration options.
Definition: CepMod.h:194
ElectrophysiologyModelType cepType
Type of cardiac electrophysiology model.
Definition: CepMod.h:164
int nX
Number of state variables.
Definition: CepMod.h:167
Vector< double > Dani
Anisotropic conductivity.
Definition: CepMod.h:188
int nG
Number of gating variables.
Definition: CepMod.h:170
double dt
Time step for integration.
Definition: CepMod.h:179
stimType Istim
External stimulus.
Definition: CepMod.h:191
int imyo
Myocardium zone id, default to epicardium.
Definition: CepMod.h:176
ECG leads type.
Definition: CepMod.h:135
Vector< double > pseudo_ECG
Pseudo ECG over each lead.
Definition: CepMod.h:150
Vector< double > x_coords
x coordinates
Definition: CepMod.h:141
int num_leads
Number of leads.
Definition: CepMod.h:138
Vector< double > y_coords
y coordinates
Definition: CepMod.h:144
Vector< double > z_coords
z coordinates
Definition: CepMod.h:147
std::vector< std::string > out_files
Output files.
Definition: CepMod.h:153
Time integration scheme and related parameters.
Definition: CepMod.h:98
double absTol
Absolute tolerance.
Definition: CepMod.h:110
double relTol
Relative tolerance.
Definition: CepMod.h:113
TimeIntegratioType tIntType
Time integration method type.
Definition: CepMod.h:103
int maxItr
Max. iterations for Newton-Raphson method.
Definition: CepMod.h:107
External stimulus type.
Definition: CepMod.h:118
double Ts
start time
Definition: CepMod.h:121
double A
stimulus amplitude
Definition: CepMod.h:130
double CL
cycle length
Definition: CepMod.h:127
double Td
duration of stimulus
Definition: CepMod.h:124