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 * ### Internal variables
113 *
114 * Names of internal variables in this block's output:
115 *
116 * * `Vc`: Chamber volume
117 *
118 */
120 public:
121 /**
122 * @brief Construct a new BloodVessel object
123 *
124 * @param id Global ID of the block
125 * @param model The model to which the block belongs
126 */
128 : Block(id, model, BlockType::chamber_elastance_inductor,
129 BlockClass::chamber,
130 {{"Emax", InputParameter()},
131 {"Emin", InputParameter()},
132 {"Vrd", InputParameter()},
133 {"Vrs", InputParameter()},
134 {"t_active", InputParameter()},
135 {"t_twitch", InputParameter()},
136 {"Impedance", InputParameter()}}) {}
137
138 /**
139 * @brief Local IDs of the parameters
140 *
141 */
142 enum ParamId {
143 EMAX = 0,
144 EMIN = 1,
145 VRD = 2,
146 VRS = 3,
147 TACTIVE = 4,
148 TTWITCH = 5,
149 IMPEDANCE = 6
150 };
151
152 /**
153 * @brief Set up the degrees of freedom (DOF) of the block
154 *
155 * Set global_var_ids and global_eqn_ids of the element based on the
156 * number of equations and the number of internal variables of the
157 * element.
158 *
159 * @param dofhandler Degree-of-freedom handler to register variables and
160 * equations at
161 */
162 void setup_dofs(DOFHandler &dofhandler);
163
164 /**
165 * @brief Update the constant contributions of the element in a sparse
166 system
167 *
168 * @param system System to update contributions at
169 * @param parameters Parameters of the model
170 */
171 void update_constant(SparseSystem &system, std::vector<double> &parameters);
172
173 /**
174 * @brief Update the time-dependent contributions of the element in a sparse
175 * system
176 *
177 * @param system System to update contributions at
178 * @param parameters Parameters of the model
179 */
180 void update_time(SparseSystem &system, std::vector<double> &parameters);
181
182 /**
183 * @brief Number of triplets of element
184 *
185 * Number of triplets that the element contributes to the global system
186 * (relevant for sparse memory reservation)
187 */
189
190 private:
191 double Elas; // Chamber Elastance
192 double Vrest; // Rest Volume
193
194 /**
195 * @brief Update the elastance functions which depend on time
196 *
197 * @param parameters Parameters of the model
198 */
199 void get_elastance_values(std::vector<double> &parameters);
200};
201
202#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:37
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:188
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 BloodVessel object.
Definition ChamberElastanceInductor.h:127
ParamId
Local IDs of the parameters.
Definition ChamberElastanceInductor.h:142
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:48
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