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 <map>
13#include <memory>
14#include <string>
15
16#include "ActivationFunction.h"
17#include "ActiveStress.h"
18#include "Block.h"
19#include "SparseSystem.h"
20#include "SphereMaterial.h"
21
22/**
23 * @brief Spherical heart chamber model
24 *
25 * Models the mechanical behavior of a spherical heart chamber with active
26 * contraction. For reference, see \cite caruel13 Equations (13a-b) for
27 * continuum mechanics (without length-dependent contraction valves, vessels)
28 * and \cite pfaller2019importance Equations (12-16) for the simplified active
29 * contraction model.
30 *
31 * ### Helper Functions
32 *
33 * Cauchy-Green deformation tensor and time derivative:
34 * \f[
35 * C = \left(1 + \frac{r}{r_0} \right)^2
36 * \f]
37 * \f[
38 * \dot{C} = 2 \left(1 + \frac{r}{r_0} \right) \frac{\dot{r}}{r_0}
39 * \f]
40 *
41 * ### Governing equations
42 *
43 * 1. Balance of linear momentum:
44 * \f[
45 * \rho d_0 \dot{v} + \frac{d_0}{r_0} \left(1 + \frac{r}{r_0} \right) S -
46 P_\text{out} C = 0
47 * \f]
48 *
49 * 2. Spherical stress:
50 * \f[
51 * -S + \tau + S_\text{el}(r, r_0) + \eta \dot{C}
52 * (1 + 2 C^{-6}) = 0
53 * \f]
54 * where \f$S_\text{el}\f$ is the elastic stress term supplied by the
55 * chamber's \ref SphereMaterial.
56 *
57 * 3. Volume change:
58 * \f[
59 * 4 \pi r_0^2 Cv - \dot{V} = 0
60 * \f]
61 *
62 * 4. Active stress:
63 * \f[
64 * \tau = \tau(t, r, r_0, \dots)
65 * \f]
66 * the specific form of which (and any accompanying internal state and
67 * equations) is supplied by a separate \ref ActiveStress object (e.g.
68 * `strain_independent`, `strain_dependent`) selected in the JSON
69 * configuration. The active stress model is driven by the chamber's
70 * \ref ActivationFunction (e.g. `two_hill`, `half_cosine`, `piecewise_cosine`,
71 * `piecewise_rate`), also selected in the JSON configuration.
72 *
73 * 5. Acceleration:
74 * \f[
75 * \dot{r} - v = 0
76 * \f]
77 *
78 * 6. Conservation of mass:
79 * \f[
80 * Q_\text{in} - Q_\text{out} - \dot{V} = 0
81 * \f]
82 *
83 * 7. Pressure equality:
84 * \f[
85 * P_\text{in} - P_\text{out} = 0
86 * \f]
87 *
88 * ### Parameters
89 *
90 * Parameter sequence for constructing this block:
91 *
92 * * `rho` - Density \f$\rho\f$
93 * * `thick0` - Wall thickness \f$d_0\f$
94 * * `radius0` - Reference radius \f$r_0\f$
95 * * `eta` - Viscosity parameter \f$\eta\f$
96 *
97 * An `activation_function` object is also required alongside
98 * `zero_d_element_values` to select and parameterize the activation function
99 * \f$f(t)\f$ (see \ref ActivationFunction, e.g. `two_hill`, `half_cosine`,
100 * `piecewise_cosine`, `wrapping_cosine`, `fourier`, `double_tanh`,
101 * `piecewise_rate`).
102 *
103 * Furthermore, a `material` object is required to select and parameterize
104 * the material model for the elastic stress term \f$S_\text{el}(r, r_0)\f$
105 * (see \ref SphereMaterial, e.g. `exponential`, `mooney_rivlin`).
106 *
107 * Finally, an `active_stress` object is required to select and parameterize
108 * the active stress model (see \ref ActiveStress, e.g. `strain_independent`,
109 * `strain_dependent`).
110 *
111 * ### Usage in json configuration file
112 *
113 * "chambers": [
114 * {
115 * "type": "ChamberSphere",
116 * "name": "ventricle",
117 * "values": {
118 * "rho" : 1e3,
119 * "thick0" : 0.01,
120 * "radius0" : 0.05,
121 * "eta" : 10.0
122 * },
123 * "activation_function": {},
124 * "material": {},
125 * "active_stress": {}
126 * }
127 * ]
128 *
129 * A chamber is connected to the rest of the circuit via valve blocks (see
130 * \ref ValveTanh, \ref PiecewiseValve) referencing its `name` as their
131 * `upstream_block`/`downstream_block`.
132 *
133 * ### Internal variables
134 *
135 * Names of internal variables in this block's output:
136 *
137 * * `radius` - Chamber radius \f$r\f$
138 * * `velo` - Chamber velocity \f$\dot{r}\f$
139 * * `stress` - Spherical stress \f$S\f$
140 * * `tau` - Active stress \f$\tau\f$
141 * * `volume` - Chamber volume \f$V\f$
142 *
143 * Active stress models may introduce additional internal variables (e.g.
144 * `e_c`, `tau_c`, `k_c`, `omega` for the `strain_dependent` model, see
145 * \ref ActiveStress).
146 *
147 */
148class ChamberSphere : public Block {
149 public:
150 /**
151 * @brief Local IDs of the parameters
152 *
153 */
154 enum ParamId {
155 rho = 0,
156 thick0 = 1,
157 radius0 = 2,
158 eta = 3,
159 };
160
161 /**
162 * @brief Construct a new ChamberSphere object
163 *
164 * @param id Global ID of the block
165 * @param model The model to which the block belongs
166 */
168 : Block(id, model, BlockType::chamber_sphere, BlockClass::chamber,
169 {{"rho", InputParameter()},
170 {"thick0", InputParameter()},
171 {"radius0", InputParameter()},
172 {"eta", InputParameter()}}) {}
173
174 /**
175 * @brief Set up the degrees of freedom (DOF) of the block
176 *
177 * Set \ref global_var_ids and \ref global_eqn_ids of the element based on the
178 * number of equations and the number of internal variables of the
179 * element.
180 *
181 * @param dofhandler Degree-of-freedom handler to register variables and
182 * equations at
183 */
184 void setup_dofs(DOFHandler& dofhandler) override;
185
186 /**
187 * @brief Update the constant contributions of the element in a sparse
188 system
189 *
190 * @param system System to update contributions at
191 * @param parameters Parameters of the model
192 */
193 void update_constant(SparseSystem& system,
194 std::vector<double>& parameters) override;
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,
204 std::vector<double>& parameters) override;
205
206 /**
207 * @brief Update the solution-dependent contributions of the element in a
208 * sparse system
209 *
210 * @param system System to update contributions at
211 * @param parameters Parameters of the model
212 * @param y Current solution
213 * @param dy Current derivate of the solution
214 */
215 void update_solution(
216 SparseSystem& system, std::vector<double>& parameters,
217 const Eigen::Matrix<double, Eigen::Dynamic, 1>& y,
218 const Eigen::Matrix<double, Eigen::Dynamic, 1>& dy) override;
219
220 void set_activation_function(std::unique_ptr<ActivationFunction> af) override;
221
222 void set_active_stress(std::unique_ptr<ActiveStress> as) override;
223
224 void set_material(std::unique_ptr<SphereMaterial> m) override;
225
226 private:
227 double activation_signal_ = 0.0; // activation_function_->compute(time),
228 // cached for use in update_solution
229 std::unique_ptr<ActivationFunction> activation_function_;
230
231 std::unique_ptr<ActiveStress> active_stress_;
232
233 std::unique_ptr<SphereMaterial> material_;
234
235 /**
236 * @brief Number of triplets of element
237 *
238 * Number of triplets that the element contributes to the global system
239 * (relevant for sparse memory reservation)
240 */
241 TripletsContributions num_triplets{0, 0, 18};
242};
243
244#endif // SVZERODSOLVER_MODEL_ChamberSphere_HPP_
Activation function classes for cardiac chamber models.
Active stress models for chamber blocks.
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:45
SparseSystem source file.
Material models for the ChamberSphere block.
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:103
const int id
Global ID of the block.
Definition Block.h:80
const Model * model
The model to which the block belongs.
Definition Block.h:81
void set_active_stress(std::unique_ptr< ActiveStress > as) override
Set active stress model (for chamber blocks that use one).
Definition ChamberSphere.cpp:160
ChamberSphere(int id, Model *model)
Construct a new ChamberSphere object.
Definition ChamberSphere.h:167
void update_constant(SparseSystem &system, std::vector< double > &parameters) override
Update the constant contributions of the element in a sparse system.
Definition ChamberSphere.cpp:55
ParamId
Local IDs of the parameters.
Definition ChamberSphere.h:154
void set_activation_function(std::unique_ptr< ActivationFunction > af) override
Set activation function (for chamber blocks that use one).
Definition ChamberSphere.cpp:155
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) override
Update the solution-dependent contributions of the element in a sparse system.
Definition ChamberSphere.cpp:94
void update_time(SparseSystem &system, std::vector< double > &parameters) override
Update the time-dependent contributions of the element in a sparse system.
Definition ChamberSphere.cpp:87
void setup_dofs(DOFHandler &dofhandler) override
Set up the degrees of freedom (DOF) of the block.
Definition ChamberSphere.cpp:11
void set_material(std::unique_ptr< SphereMaterial > m) override
Set wall material (for ChamberSphere blocks).
Definition ChamberSphere.cpp:151
Model of 0D elements.
Definition Model.h:56
InputParameter(bool is_optional=false, bool is_array=false, bool is_number=true, double default_val=0.0)
Handles input parameters.
Definition Parameter.h:114