svMultiPhysics
Loading...
Searching...
No Matches
CepMod.h
1// SPDX-FileCopyrightText: Copyright (c) Stanford University, The Regents of the University of California, and others.
2// SPDX-License-Identifier: BSD-3-Clause
3
4// The classes defined here duplicate the data structures in the Fortran CEPMOD module
5// defined in CEPMOD.f.
6
7// This module defines data structures for cardiac electrophysiology
8// model equation. It also interfaces with individual modules for
9// the cellular activation model.
10
11#ifndef CEP_MOD_H
12#define CEP_MOD_H
13
14#include "consts.h"
15#include "IonicModel.h"
16
17#include "Array.h"
18#include "Vector.h"
19#include <map>
20#include <memory>
21
22/// @brief Type of cardiac electrophysiology models.
23enum class ElectrophysiologyModelType {
24 NA = 100,
25 AP = 101,
26 BO = 102,
27 FN = 103,
28 TTP = 104
29};
30
31extern const std::map<ElectrophysiologyModelType, std::string> cep_model_type_to_name;
32extern const std::map<std::string,ElectrophysiologyModelType> cep_model_name_to_type;
33
34/// @brief Print ElectrophysiologyModelType as a string.
35static std::ostream &operator << ( std::ostream& strm, ElectrophysiologyModelType type)
36{
37 const std::map<ElectrophysiologyModelType, std::string> names = {
38 {ElectrophysiologyModelType::NA, "NA"},
39 {ElectrophysiologyModelType::AP,"AP"},
40 {ElectrophysiologyModelType::BO, "BO"},
41 {ElectrophysiologyModelType::FN, "FN"},
42 {ElectrophysiologyModelType::TTP, "TTP"},
43 };
44 return strm << names.at(type);
45}
46
47class ComMod;
48class CmMod;
49class cmType;
51
52/// @brief External stimulus type
54{
55 public:
56 /// @brief Spatial bounds for a CEP stimulus region.
58 {
59 public:
60 /// @brief Set box bounds.
61 void set_box(const Vector<double>& min, const Vector<double>& max);
62
63 /// @brief Set sphere bounds.
64 void set_sphere(const Vector<double>& center, const double radius);
65
66 /// @brief Return true if the point lies inside all active spatial bounds.
67 bool contains(const Vector<double>& x) const;
68
69 /// @brief Broadcast spatial bounds to all MPI ranks.
70 void distribute(const CmMod& cm_mod, const cmType& cm);
71
72 private:
73 /// @brief True if a box region has been set.
74 bool has_box = false;
75 /// @brief True if a sphere region has been set.
76 bool has_sphere = false;
77
78 /// @brief Minimum corner of the box region.
79 Vector<double> box_min;
80 /// @brief Maximum corner of the box region.
81 Vector<double> box_max;
82 /// @brief Center of the sphere region.
83 Vector<double> sphere_center;
84 /// @brief Radius of the sphere region.
85 double sphere_radius = 0.0;
86
87 /// @brief Return true if x lies inside the box. Assumes has_box is true.
88 bool inside_box(const Vector<double>& x) const;
89 /// @brief Return true if x lies inside the sphere. Assumes has_sphere is true.
90 bool inside_sphere(const Vector<double>& x) const;
91 };
92
93 /// @brief Return the applied stimulus value at a point and time.
94 double operator()(const double time, const Vector<double>& x) const;
95
96 /// @brief Set stimulus parameters from parsed XML parameters.
97 void read_parameters(const StimulusParameters& params, const int nsd, const double default_cycle_length);
98
99 /// @brief Broadcast stimulus parameters to all ranks.
100 void distribute(const CmMod& cm_mod, const cmType& cm);
101
102 private:
103 /// @brief Time at which the stimulus begins within each cycle.
104 double start_time = 0.0;
105 /// @brief Duration of the stimulus pulse within each cycle.
106 double duration = 0.0;
107 /// @brief Length of one stimulus cycle.
108 double cycle_length = 0.0;
109 /// @brief Amplitude of the applied stimulus.
110 double amplitude = 0.0;
111
112 /// @brief Spatial region to which the stimulus is applied.
113 SpatialBounds spatial_bounds;
114
115 /// @brief Return true if the stimulus is active at the given time.
116 bool is_active(const double time) const;
117};
118
119/// @brief ECG leads type
121{
122 public:
123 /// @brief Number of leads
124 int num_leads = 0;
125
126 /// @brief x coordinates
128
129 /// @brief y coordinates
131
132 /// @brief z coordinates
134
135 /// @brief Pseudo ECG over each lead
137
138 /// @brief Output files
139 std::vector<std::string> out_files;
140};
141
142/// @brief Cardiac electrophysiology model type
144{
145 public:
146 cepModelType();
148
149 /// @brief Type of cardiac electrophysiology model
150 ElectrophysiologyModelType cepType = ElectrophysiologyModelType::NA;
151
152 /// @brief Number of state variables
153 int nX = 0;
154
155 /// @brief Number of gating variables
156 int nG = 0;
157
158 /// @brief Number of fiber directions
159 int nFn = 0;
160
161 /// @brief Myocardium zone id, default to epicardium.
162 int imyo = 1;
163
164 /// @brief Time step for integration
165 double dt = 0.0;
166
167 /// @brief Constant for stretch-activated-currents
168 double Ksac = 0.0;
169
170 /// @brief Isotropic conductivity
171 double Diso = 0.0;
172
173 /// @brief Anisotropic conductivity
175
176 /// @brief External stimuli applied within this domain.
177 std::vector<stimType> Istim;
178
179 /// @brief Summed applied stimulus at a point and time (0.0 if none active).
180 double stimulus_value(const double time, const Vector<double>& x) const;
181
182 /// @brief Time integration options
184
185 /// @brief Ionic model instance.
186 std::shared_ptr<IonicModel> ionic_model;
187};
188
189/// @brief Cardiac electromechanics model type
191{
192 public:
193 /// @brief Whether electrophysiology and mechanics are coupled
194 bool cpld = false;
195 //bool cpld = .FALSE.
196
197 /// @brief Whether active strain formulation is employed
198 bool aStrain = false;
199 //bool aStrain = .FALSE.
200
201 /// @brief Activation along fibers.
202 ///
203 /// Corresponds to active tension along fibers if using active stress, and
204 /// to fiber stretch if using active strain.
206
207 /// @brief Activation along sheets.
208 ///
209 /// Only used if using active stress, in which case it represents the active
210 /// tension along sheets.
212
213 /// @brief Activation along sheet normals.
214 ///
215 /// Only used if using active stress, in which case it represents the active
216 /// tension along sheet normals.
218};
219
220class 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 Calcium vector at all nodes.
235
236 /// @brief Cardiac electromechanics type
238
239 /// @brief ECG leads
241};
242
243#endif
244
Definition CepMod.h:221
int nXion
Max. dof in cellular activation model.
Definition CepMod.h:228
bool cepEq
Whether cardiac electrophysiology is solved.
Definition CepMod.h:225
cemModelType cem
Cardiac electromechanics type.
Definition CepMod.h:237
Array< double > Xion
Unknowns stored at all nodes.
Definition CepMod.h:231
ecgLeadsType ecgleads
ECG leads.
Definition CepMod.h:240
Vector< double > calcium
Calcium vector at all nodes.
Definition CepMod.h:234
The CmMod class duplicates the data structures in the Fortran CMMOD module defined in COMU....
Definition CmMod.h:36
The ComMod class duplicates the data structures in the Fortran COMMOD module defined in MOD....
Definition ComMod.h:1597
The StimulusParameters class stores parameters for 'Stimulus' XML element used to parameters for pace...
Definition Parameters.h:1231
Ten Tusscher-Panfilov ionic model.
Definition IonicModelTTP.h:32
The Vector template class is used for storing int and double data.
Definition Vector.h:26
Cardiac electromechanics model type.
Definition CepMod.h:191
Vector< double > Ya_f
Activation along fibers.
Definition CepMod.h:205
Vector< double > Ya_s
Activation along sheets.
Definition CepMod.h:211
Vector< double > Ya_n
Activation along sheet normals.
Definition CepMod.h:217
bool cpld
Whether electrophysiology and mechanics are coupled.
Definition CepMod.h:194
bool aStrain
Whether active strain formulation is employed.
Definition CepMod.h:198
Cardiac electrophysiology model type.
Definition CepMod.h:144
double Diso
Isotropic conductivity.
Definition CepMod.h:171
std::vector< stimType > Istim
External stimuli applied within this domain.
Definition CepMod.h:177
int nFn
Number of fiber directions.
Definition CepMod.h:159
double Ksac
Constant for stretch-activated-currents.
Definition CepMod.h:168
odeType odes
Time integration options.
Definition CepMod.h:183
ElectrophysiologyModelType cepType
Type of cardiac electrophysiology model.
Definition CepMod.h:150
int nX
Number of state variables.
Definition CepMod.h:153
Vector< double > Dani
Anisotropic conductivity.
Definition CepMod.h:174
int nG
Number of gating variables.
Definition CepMod.h:156
std::shared_ptr< IonicModel > ionic_model
Ionic model instance.
Definition CepMod.h:186
double dt
Time step for integration.
Definition CepMod.h:165
double stimulus_value(const double time, const Vector< double > &x) const
Summed applied stimulus at a point and time (0.0 if none active).
Definition CepMod.cpp:249
int imyo
Myocardium zone id, default to epicardium.
Definition CepMod.h:162
The cmType class stores data and defines methods used for mpi communication.
Definition CmMod.h:56
ECG leads type.
Definition CepMod.h:121
Vector< double > pseudo_ECG
Pseudo ECG over each lead.
Definition CepMod.h:136
Vector< double > x_coords
x coordinates
Definition CepMod.h:127
int num_leads
Number of leads.
Definition CepMod.h:124
Vector< double > y_coords
y coordinates
Definition CepMod.h:130
Vector< double > z_coords
z coordinates
Definition CepMod.h:133
std::vector< std::string > out_files
Output files.
Definition CepMod.h:139
Time integration scheme and related parameters.
Definition IonicModel.h:50
Spatial bounds for a CEP stimulus region.
Definition CepMod.h:58
bool contains(const Vector< double > &x) const
Return true if the point lies inside all active spatial bounds.
Definition CepMod.cpp:97
void distribute(const CmMod &cm_mod, const cmType &cm)
Broadcast spatial bounds to all MPI ranks.
Definition CepMod.cpp:104
void set_sphere(const Vector< double > &center, const double radius)
Set sphere bounds.
Definition CepMod.cpp:53
void set_box(const Vector< double > &min, const Vector< double > &max)
Set box bounds.
Definition CepMod.cpp:42
External stimulus type.
Definition CepMod.h:54
double operator()(const double time, const Vector< double > &x) const
Return the applied stimulus value at a point and time.
Definition CepMod.cpp:135
void distribute(const CmMod &cm_mod, const cmType &cm)
Broadcast stimulus parameters to all ranks.
Definition CepMod.cpp:146
void read_parameters(const StimulusParameters &params, const int nsd, const double default_cycle_length)
Set stimulus parameters from parsed XML parameters.
Definition CepMod.cpp:155