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