svZeroDSolver
Loading...
Searching...
No Matches
ChamberElastanceInductor.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 ChamberElastanceInductor.h
5 * @brief model::ChamberElastanceInductor source file
6 */
7#ifndef SVZERODSOLVER_MODEL_CHAMBERELASTANCEINDUCTOR_HPP_
8#define SVZERODSOLVER_MODEL_CHAMBERELASTANCEINDUCTOR_HPP_
9
10#include <math.h>
11
12#include "Block.h"
13#include "Model.h"
14#include "SparseSystem.h"
15#include "debug.h"
16
17/**
18 * @brief Cardiac chamber with elastance and inductor.
19 *
20 * Models a cardiac chamber as a time-varying capacitor (elastance with
21 * specified resting volumes) and an inductor. See \cite kerckhoffs2007coupling
22 * (equations 1 and 2). The addition of the inductor is similar to the models in
23 * \cite sankaran2012patient and \cite menon2023predictors.
24 *
25 * This chamber block can be connected to other blocks using junctions.
26 *
27 * \f[
28 * \begin{circuitikz} \draw
29 * node[left] {$Q_{in}$} [-latex] (0,0) -- (0.8,0);
30 * \draw (1,0) node[anchor=south]{$P_{in}$}
31 * to (1,0)
32 * node[anchor=south]{}
33 * to [L, l=$L$, *-*] (3,0)
34 * node[anchor=south]{$P_{out}$}
35 * (1,0) to [vC, l=$E$, *-] (1,-1.5)
36 * node[ground]{};
37 * \draw [-latex] (3.2,0) -- (4.0,0) node[right] {$Q_{out}$} ;
38 * \end{circuitikz}
39 * \f]
40 *
41 * ### Governing equations
42 *
43 * \f[
44 * P_{in}-E(t)(V_c-V_{rest})=0
45 * \f]
46 *
47 * \f[
48 * P_{in}-P_{out}-L\dot{Q}_{out}=0
49 * \f]
50 *
51 * \f[
52 * Q_{in}-Q_{out}-\dot{V}_c=0
53 * \f]
54 *
55 * ### Local contributions
56 *
57 * \f[
58 * \mathbf{y}^{e}=\left[\begin{array}{lllll}P_{in} & Q_{in} &
59 * P_{out} & Q_{out} & V_c\end{array}\right]^{T} \f]
60 *
61 * \f[
62 * \mathbf{E}^{e}=\left[\begin{array}{ccccc}
63 * 0 & 0 & 0 & 0 & 0\\
64 * 0 & 0 & 0 & -L & 0\\
65 * 0 & 0 & 0 & 0 & -1
66 * \end{array}\right]
67 * \f]
68 *
69 * \f[
70 * \mathbf{F}^{e}=\left[\begin{array}{ccccc}
71 * 1 & 0 & 0 & 0 & E(t) \\
72 * 1 & 0 & -1 & 0 & 0 \\
73 * 0 & 1 & 0 & -1 & 0
74 * \end{array}\right]
75 * \f]
76 *
77 * \f[
78 * \mathbf{c}^{e}=\left[\begin{array}{c}
79 * E(t)V_{rest} \\
80 * 0 \\
81 * 0
82 * \end{array}\right]
83 * \f]
84 *
85 * In the above equations,
86 *
87 * \f[
88 * V_{rest}(t)= \{1-A(t)\}(V_{rd}-V_{rs})+V_{rs}
89 * \f]
90 *
91 * \f[
92 * A(t)=-\frac{1}{2}cos(2 \pi T_{contract}/T_{twitch})
93 * \f]
94 *
95 * \f[
96 * E(t)=(E_{max}-E_{min})A(t) + E_{min}
97 * \f]
98 *
99 *
100 * ### Parameters
101 *
102 * Parameter sequence for constructing this block
103 *
104 * * `0` Emax: Maximum elastance
105 * * `1` Emin: Minimum elastance
106 * * `2` Vrd: Rest diastolic volume
107 * * `3` Vrs: Rest systolic volume
108 * * `4` t_active: Activation time
109 * * `5` t_twitch: Twitch time
110 * * `6` Impedance: Impedance of the outflow
111 *
112 * ### Usage in json configuration file
113 *
114 * "chambers": [
115 * {
116 * "type": "ChamberElastanceInductor",
117 * "name": "ventricle",
118 * "values": {
119 * "Emax": 1.057,
120 * "Emin": 0.091,
121 * "Vrd": 26.1,
122 * "Vrs": 18.0,
123 * "t_active": 0.2,
124 * "t_twitch": 0.3,
125 * "Impedance": 0.000351787
126 * }
127 * }
128 * ],
129 * "initial_condition": {
130 * "Vc:ventricle": 96.07
131 * }
132 *
133 * ### Internal variables
134 *
135 * Names of internal variables in this block's output:
136 *
137 * * `Vc`: Chamber volume
138 *
139 */
141 public:
142 /**
143 * @brief Construct a new ChamberElastanceInductor object
144 *
145 * @param id Global ID of the block
146 * @param model The model to which the block belongs
147 */
149 : Block(id, model, BlockType::chamber_elastance_inductor,
150 BlockClass::chamber,
151 {{"Emax", InputParameter()},
152 {"Emin", InputParameter()},
153 {"Vrd", InputParameter()},
154 {"Vrs", InputParameter()},
155 {"t_active", InputParameter()},
156 {"t_twitch", InputParameter()},
157 {"Impedance", InputParameter()}}) {}
158
159 /**
160 * @brief Local IDs of the parameters
161 *
162 */
163 enum ParamId {
164 EMAX = 0,
165 EMIN = 1,
166 VRD = 2,
167 VRS = 3,
168 TACTIVE = 4,
169 TTWITCH = 5,
170 IMPEDANCE = 6
171 };
172
173 /**
174 * @brief Set up the degrees of freedom (DOF) of the block
175 *
176 * Set global_var_ids and global_eqn_ids of the element based on the
177 * number of equations and the number of internal variables of the
178 * element.
179 *
180 * @param dofhandler Degree-of-freedom handler to register variables and
181 * equations at
182 */
183 void setup_dofs(DOFHandler& dofhandler);
184
185 /**
186 * @brief Update the constant contributions of the element in a sparse
187 system
188 *
189 * @param system System to update contributions at
190 * @param parameters Parameters of the model
191 */
192 void update_constant(SparseSystem& system, std::vector<double>& parameters);
193
194 /**
195 * @brief Update the time-dependent contributions of the element in a sparse
196 * system
197 *
198 * @param system System to update contributions at
199 * @param parameters Parameters of the model
200 */
201 void update_time(SparseSystem& system, std::vector<double>& parameters);
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 */
210
211 private:
212 double Elas; // Chamber Elastance
213 double Vrest; // Rest Volume
214
215 /**
216 * @brief Update the elastance functions which depend on time
217 *
218 * @param parameters Parameters of the model
219 */
220 void get_elastance_values(std::vector<double>& parameters);
221};
222
223#endif // SVZERODSOLVER_MODEL_CHAMBERELASTANCEINDUCTOR_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
model::Model source file
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 setup_dofs(DOFHandler &dofhandler)
Set up the degrees of freedom (DOF) of the block.
Definition ChamberElastanceInductor.cpp:5
TripletsContributions num_triplets
Number of triplets of element.
Definition ChamberElastanceInductor.h:209
void update_time(SparseSystem &system, std::vector< double > &parameters)
Update the time-dependent contributions of the element in a sparse system.
Definition ChamberElastanceInductor.cpp:28
ChamberElastanceInductor(int id, Model *model)
Construct a new ChamberElastanceInductor object.
Definition ChamberElastanceInductor.h:148
ParamId
Local IDs of the parameters.
Definition ChamberElastanceInductor.h:163
void update_constant(SparseSystem &system, std::vector< double > &parameters)
Update the constant contributions of the element in a sparse system.
Definition ChamberElastanceInductor.cpp:10
Degree-of-freedom handler.
Definition DOFHandler.h:21
Model of 0D elements.
Definition Model.h:49
Sparse system.
Definition SparseSystem.h:30
DEBUG_MSG source file.
Handles the properties of input parameters.
Definition Parameter.h:100
The number of triplets that the element contributes to the global system.
Definition Block.h:26