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 * ### Internal variables
97 *
98 * Names of internal variables in this block's output:
99 *
100 * * `radius` - Chamber radius \f$r\f$
101 * * `velo` - Chamber velocity \f$\dot{r}\f$
102 * * `stress` - Spherical stress \f$S\f$
103 * * `tau` - Active stress \f$\tau\f$
104 * * `volume` - Chamber volume \f$V\f$
105 *
106 */
107class ChamberSphere : public Block {
108 public:
109 /**
110 * @brief Local IDs of the parameters
111 *
112 */
113 enum ParamId {
114 rho = 0,
115 thick0 = 1,
116 radius0 = 2,
117 W1 = 3,
118 W2 = 4,
119 eta = 5,
120 sigma_max = 6,
121 alpha_max = 7,
122 alpha_min = 8,
123 tsys = 9,
124 tdias = 10,
125 steepness = 11
126 };
127
128 /**
129 * @brief Construct a new ChamberSphere object
130 *
131 * @param id Global ID of the block
132 * @param model The model to which the block belongs
133 */
135 : Block(id, model, BlockType::chamber_sphere, BlockClass::vessel,
136 {{"rho", InputParameter()},
137 {"thick0", InputParameter()},
138 {"radius0", InputParameter()},
139 {"W1", InputParameter()},
140 {"W2", InputParameter()},
141 {"eta", InputParameter()},
142 {"sigma_max", InputParameter()},
143 {"alpha_max", InputParameter()},
144 {"alpha_min", InputParameter()},
145 {"tsys", InputParameter()},
146 {"tdias", InputParameter()},
147 {"steepness", InputParameter()}}) {}
148
149 /**
150 * @brief Set up the degrees of freedom (DOF) of the block
151 *
152 * Set \ref global_var_ids and \ref global_eqn_ids of the element based on the
153 * number of equations and the number of internal variables of the
154 * element.
155 *
156 * @param dofhandler Degree-of-freedom handler to register variables and
157 * equations at
158 */
159 void setup_dofs(DOFHandler &dofhandler);
160
161 /**
162 * @brief Update the constant contributions of the element in a sparse
163 system
164 *
165 * @param system System to update contributions at
166 * @param parameters Parameters of the model
167 */
168 void update_constant(SparseSystem &system, std::vector<double> &parameters);
169
170 /**
171 * @brief Update the time-dependent contributions of the element in a sparse
172 * system
173 *
174 * @param system System to update contributions at
175 * @param parameters Parameters of the model
176 */
177 void update_time(SparseSystem &system, std::vector<double> &parameters);
178
179 /**
180 * @brief Update the solution-dependent contributions of the element in a
181 * sparse system
182 *
183 * @param system System to update contributions at
184 * @param parameters Parameters of the model
185 * @param y Current solution
186 * @param dy Current derivate of the solution
187 */
188 void update_solution(SparseSystem &system, std::vector<double> &parameters,
189 const Eigen::Matrix<double, Eigen::Dynamic, 1> &y,
190 const Eigen::Matrix<double, Eigen::Dynamic, 1> &dy);
191
192 /**
193 * @brief Update the elastance functions which depend on time
194 *
195 * @param parameters Parameters of the model
196 */
197 void get_elastance_values(std::vector<double> &parameters);
198
199 private:
200 double act = 0.0; // activation function
201 double act_plus = 0.0; // act_plus = max(act, 0)
202
203 /**
204 * @brief Number of triplets of element
205 *
206 * Number of triplets that the element contributes to the global system
207 * (relevant for sparse memory reservation)
208 */
209 TripletsContributions num_triplets{0, 0, 18};
210};
211
212#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:134
ParamId
Local IDs of the parameters.
Definition ChamberSphere.h:113
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