svZeroDSolver
Loading...
Searching...
No Matches
ChamberSphere.h
Go to the documentation of this file.
1// SPDX-FileCopyrightText: Copyright (c) Stanford University, The Regents of the
2// University of California, and others. SPDX-License-Identifier: BSD-3-Clause
3/**
4 * @file ChamberSphere.h
5 * @brief model::ChamberSphere source file
6 */
7#ifndef SVZERODSOLVER_MODEL_ChamberSphere_HPP_
8#define SVZERODSOLVER_MODEL_ChamberSphere_HPP_
9
10#include <math.h>
11
12#include "Block.h"
13#include "SparseSystem.h"
14
15/**
16 * @brief Spherical heart chamber model
17 *
18 * Models the mechanical behavior of a spherical heart chamber with active
19 * contraction. For reference, see \cite caruel13 Equations (13a-b) for
20 * continuum mechanics (without length-dependent contraction valves, vessels)
21 * and \cite pfaller2019importance Equations (12-16) for the simplified active
22 * contraction model.
23 *
24 * ### Helper Functions
25 *
26 * Cauchy-Green deformation tensor and time derivative:
27 * \f[
28 * C = \left(1 + \frac{r}{r_0} \right)^2
29 * \f]
30 * \f[
31 * \dot{C} = 2 \left(1 + \frac{r}{r_0} \right) \frac{\dot{r}}{r_0}
32 * \f]
33 *
34 * ### Governing equations
35 *
36 * 1. Balance of linear momentum:
37 * \f[
38 * \rho d_0 \dot{v} + \frac{d_0}{r_0} \left(1 + \frac{r}{r_0} \right) S -
39 P_\text{out} C = 0
40 * \f]
41 *
42 * 2. Spherical stress:
43 * \f[
44 * -S + \tau + 4 (1 - C^{-3}) (W_1 + C W_2) + 2 \eta \dot{C}
45 * (1 - 2 C^{-6}) = 0
46 * \f]
47 *
48 * 3. Volume change:
49 * \f[
50 * 4 \pi r_0^2 Cv - \dot{V} = 0
51 * \f]
52 *
53 * 4. Active stress:
54 * \f[
55 * \dot{\tau} + a \tau - \sigma_\text{max} a_+ = 0, \quad a_+ = \max(a, 0),
56 \quad a = f\alpha_\text{max} + (1 - f)\alpha_\text{min}
57 * \f]
58 * with indicator function
59 * \f[
60 * f = S_+ \cdot S_-, \quad S_\pm = \frac{1}{2} \left(1.0 \pm \text{tanh}\left(
61 \frac{t - t_\text{sys/dias}} {\gamma} \right) \right)
62 * \f]
63 *
64 * 5. Acceleration:
65 * \f[
66 * \dot{r} - v = 0
67 * \f]
68 *
69 * 6. Conservation of mass:
70 * \f[
71 * Q_\text{in} - Q_\text{out} - \dot{V} = 0
72 * \f]
73 *
74 * 7. Pressure equality:
75 * \f[
76 * P_\text{in} - P_\text{out} = 0
77 * \f]
78 *
79 * ### Parameters
80 *
81 * Parameter sequence for constructing this block:
82 *
83 * * `rho` - Density \f$\rho\f$
84 * * `thick0` - Wall thickness \f$d_0\f$
85 * * `radius0` - Reference radius \f$r_0\f$
86 * * `W1` - Material constant \f$W_1\f$
87 * * `W2` - Material constant \f$W_2\f$
88 * * `eta` - Viscosity parameter \f$\eta\f$
89 * * `sigma_max` - Maximum active stress \f$\sigma_\text{max}\f$
90 * * `alpha_max` - Maximum activation parameter \f$\alpha_\text{max}\f$
91 * * `alpha_min` - Minimum activation parameter \f$\alpha_\text{min}\f$
92 * * `tsys` - Systole timing parameter \f$t_\text{sys}\f$
93 * * `tdias` - Diastole timing parameter \f$t_\text{dias}\f$
94 * * `steepness` - Activation steepness parameter \f$\gamma\f$
95 *
96 * ### Usage in json configuration file
97 *
98 * "vessels": [
99 * {
100 * "boundary_conditions": {},
101 * "vessel_id": 1,
102 * "vessel_length": 1.0,
103 * "vessel_name": "ventricle",
104 * "zero_d_element_type": "ChamberSphere",
105 * "zero_d_element_values": {
106 * "rho" : 1e3,
107 * "thick0" : 0.01,
108 * "radius0" : 0.05,
109 * "W1" : 10e3,
110 * "W2" : 40,
111 * "eta" : 10.0,
112 * "sigma_max" : 185e3,
113 * "alpha_max": 30.0,
114 * "alpha_min": -30.0,
115 * "tsys": 0.170,
116 * "tdias": 0.484,
117 * "steepness": 0.005
118 * }
119 * }
120 * ]
121 *
122 * ### Internal variables
123 *
124 * Names of internal variables in this block's output:
125 *
126 * * `radius` - Chamber radius \f$r\f$
127 * * `velo` - Chamber velocity \f$\dot{r}\f$
128 * * `stress` - Spherical stress \f$S\f$
129 * * `tau` - Active stress \f$\tau\f$
130 * * `volume` - Chamber volume \f$V\f$
131 *
132 */
133class ChamberSphere : public Block {
134 public:
135 /**
136 * @brief Local IDs of the parameters
137 *
138 */
139 enum ParamId {
140 rho = 0,
141 thick0 = 1,
142 radius0 = 2,
143 W1 = 3,
144 W2 = 4,
145 eta = 5,
146 sigma_max = 6,
147 alpha_max = 7,
148 alpha_min = 8,
149 tsys = 9,
150 tdias = 10,
151 steepness = 11
152 };
153
154 /**
155 * @brief Construct a new ChamberSphere object
156 *
157 * @param id Global ID of the block
158 * @param model The model to which the block belongs
159 */
161 : Block(id, model, BlockType::chamber_sphere, BlockClass::vessel,
162 {{"rho", InputParameter()},
163 {"thick0", InputParameter()},
164 {"radius0", InputParameter()},
165 {"W1", InputParameter()},
166 {"W2", InputParameter()},
167 {"eta", InputParameter()},
168 {"sigma_max", InputParameter()},
169 {"alpha_max", InputParameter()},
170 {"alpha_min", InputParameter()},
171 {"tsys", InputParameter()},
172 {"tdias", InputParameter()},
173 {"steepness", InputParameter()}}) {}
174
175 /**
176 * @brief Set up the degrees of freedom (DOF) of the block
177 *
178 * Set \ref global_var_ids and \ref global_eqn_ids of the element based on the
179 * number of equations and the number of internal variables of the
180 * element.
181 *
182 * @param dofhandler Degree-of-freedom handler to register variables and
183 * equations at
184 */
185 void setup_dofs(DOFHandler& dofhandler);
186
187 /**
188 * @brief Update the constant contributions of the element in a sparse
189 system
190 *
191 * @param system System to update contributions at
192 * @param parameters Parameters of the model
193 */
194 void update_constant(SparseSystem& system, std::vector<double>& parameters);
195
196 /**
197 * @brief Update the time-dependent contributions of the element in a sparse
198 * system
199 *
200 * @param system System to update contributions at
201 * @param parameters Parameters of the model
202 */
203 void update_time(SparseSystem& system, std::vector<double>& parameters);
204
205 /**
206 * @brief Update the solution-dependent contributions of the element in a
207 * sparse system
208 *
209 * @param system System to update contributions at
210 * @param parameters Parameters of the model
211 * @param y Current solution
212 * @param dy Current derivate of the solution
213 */
214 void update_solution(SparseSystem& system, std::vector<double>& parameters,
215 const Eigen::Matrix<double, Eigen::Dynamic, 1>& y,
216 const Eigen::Matrix<double, Eigen::Dynamic, 1>& dy);
217
218 /**
219 * @brief Update the elastance functions which depend on time
220 *
221 * @param parameters Parameters of the model
222 */
223 void get_elastance_values(std::vector<double>& parameters);
224
225 private:
226 double act = 0.0; // activation function
227 double act_plus = 0.0; // act_plus = max(act, 0)
228
229 /**
230 * @brief Number of triplets of element
231 *
232 * Number of triplets that the element contributes to the global system
233 * (relevant for sparse memory reservation)
234 */
235 TripletsContributions num_triplets{0, 0, 18};
236};
237
238#endif // SVZERODSOLVER_MODEL_ChamberSphere_HPP_
model::Block source file
BlockType
The types of blocks supported by the solver.
Definition BlockType.h:15
BlockClass
The classes/categories of blocks supported. Some classes require special handling (e....
Definition BlockType.h:38
SparseSystem source file.
Block(int id, Model *model, BlockType block_type, BlockClass block_class, std::vector< std::pair< std::string, InputParameter > > input_params)
Construct a new Block object.
Definition Block.h:100
const int id
Global ID of the block.
Definition Block.h:77
const Model * model
The model to which the block belongs.
Definition Block.h:78
void update_constant(SparseSystem &system, std::vector< double > &parameters)
Update the constant contributions of the element in a sparse system.
Definition ChamberSphere.cpp:13
void update_time(SparseSystem &system, std::vector< double > &parameters)
Update the time-dependent contributions of the element in a sparse system.
Definition ChamberSphere.cpp:45
void setup_dofs(DOFHandler &dofhandler)
Set up the degrees of freedom (DOF) of the block.
Definition ChamberSphere.cpp:8
ChamberSphere(int id, Model *model)
Construct a new ChamberSphere object.
Definition ChamberSphere.h:160
ParamId
Local IDs of the parameters.
Definition ChamberSphere.h:139
void update_solution(SparseSystem &system, std::vector< double > &parameters, const Eigen::Matrix< double, Eigen::Dynamic, 1 > &y, const Eigen::Matrix< double, Eigen::Dynamic, 1 > &dy)
Update the solution-dependent contributions of the element in a sparse system.
Definition ChamberSphere.cpp:52
void get_elastance_values(std::vector< double > &parameters)
Update the elastance functions which depend on time.
Definition ChamberSphere.cpp:110
Model of 0D elements.
Definition Model.h:49
Handles the properties of input parameters.
Definition Parameter.h:100