svZeroDSolver
Loading...
Searching...
No Matches
ChamberElastanceInductor.h
Go to the documentation of this file.
1// Copyright (c) Stanford University, The Regents of the University of
2// California, and others.
3//
4// All Rights Reserved.
5//
6// See Copyright-SimVascular.txt for additional details.
7//
8// Permission is hereby granted, free of charge, to any person obtaining
9// a copy of this software and associated documentation files (the
10// "Software"), to deal in the Software without restriction, including
11// without limitation the rights to use, copy, modify, merge, publish,
12// distribute, sublicense, and/or sell copies of the Software, and to
13// permit persons to whom the Software is furnished to do so, subject
14// to the following conditions:
15//
16// The above copyright notice and this permission notice shall be included
17// in all copies or substantial portions of the Software.
18//
19// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
20// IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21// TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
22// PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
23// OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
24// EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
25// PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
26// PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
27// LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
28// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
29// SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
30/**
31 * @file ChamberElastanceInductor.h
32 * @brief model::ChamberElastanceInductor source file
33 */
34#ifndef SVZERODSOLVER_MODEL_CHAMBERELASTANCEINDUCTOR_HPP_
35#define SVZERODSOLVER_MODEL_CHAMBERELASTANCEINDUCTOR_HPP_
36
37#include <math.h>
38
39#include "Block.h"
40#include "Model.h"
41#include "SparseSystem.h"
42#include "debug.h"
43
44/**
45 * @brief Cardiac chamber with elastance and inductor.
46 *
47 * Models a cardiac chamber as a time-varying capacitor (elastance with
48 * specified resting volumes) and an inductor. See \cite kerckhoffs2007coupling
49 * (equations 1 and 2). The addition of the inductor is similar to the models in
50 * \cite sankaran2012patient and \cite menon2023predictors.
51 *
52 * This chamber block can be connected to other blocks using junctions.
53 *
54 * \f[
55 * \begin{circuitikz} \draw
56 * node[left] {$Q_{in}$} [-latex] (0,0) -- (0.8,0);
57 * \draw (1,0) node[anchor=south]{$P_{in}$}
58 * to (1,0)
59 * node[anchor=south]{}
60 * to [L, l=$L$, *-*] (3,0)
61 * node[anchor=south]{$P_{out}$}
62 * (1,0) to [vC, l=$E$, *-] (1,-1.5)
63 * node[ground]{};
64 * \draw [-latex] (3.2,0) -- (4.0,0) node[right] {$Q_{out}$} ;
65 * \end{circuitikz}
66 * \f]
67 *
68 * ### Governing equations
69 *
70 * \f[
71 * P_{in}-E(t)(V_c-V_{rest})=0
72 * \f]
73 *
74 * \f[
75 * P_{in}-P_{out}-L\dot{Q}_{out}=0
76 * \f]
77 *
78 * \f[
79 * Q_{in}-Q_{out}-\dot{V}_c=0
80 * \f]
81 *
82 * ### Local contributions
83 *
84 * \f[
85 * \mathbf{y}^{e}=\left[\begin{array}{lllll}P_{in} & Q_{in} &
86 * P_{out} & Q_{out} & V_c\end{array}\right]^{T} \f]
87 *
88 * \f[
89 * \mathbf{E}^{e}=\left[\begin{array}{ccccc}
90 * 0 & 0 & 0 & 0 & 0\\
91 * 0 & 0 & 0 & -L & 0\\
92 * 0 & 0 & 0 & 0 & -1
93 * \end{array}\right]
94 * \f]
95 *
96 * \f[
97 * \mathbf{F}^{e}=\left[\begin{array}{ccccc}
98 * 1 & 0 & 0 & 0 & E(t) \\
99 * 1 & 0 & -1 & 0 & 0 \\
100 * 0 & 1 & 0 & -1 & 0
101 * \end{array}\right]
102 * \f]
103 *
104 * \f[
105 * \mathbf{c}^{e}=\left[\begin{array}{c}
106 * E(t)V_{rest} \\
107 * 0 \\
108 * 0
109 * \end{array}\right]
110 * \f]
111 *
112 * In the above equations,
113 *
114 * \f[
115 * V_{rest}(t)= \{1-A(t)\}(V_{rd}-V_{rs})+V_{rs}
116 * \f]
117 *
118 * \f[
119 * A(t)=-\frac{1}{2}cos(2 \pi T_{contract}/T_{twitch})
120 * \f]
121 *
122 * \f[
123 * E(t)=(E_{max}-E_{min})A(t) + E_{min}
124 * \f]
125 *
126 *
127 * ### Parameters
128 *
129 * Parameter sequence for constructing this block
130 *
131 * * `0` Emax: Maximum elastance
132 * * `1` Emin: Minimum elastance
133 * * `2` Vrd: Rest diastolic volume
134 * * `3` Vrs: Rest systolic volume
135 * * `4` t_active: Activation time
136 * * `5` t_twitch: Twitch time
137 * * `6` Impedance: Impedance of the outflow
138 *
139 * ### Internal variables
140 *
141 * Names of internal variables in this block's output:
142 *
143 * * `Vc`: Chamber volume
144 *
145 */
147 public:
148 /**
149 * @brief Construct a new BloodVessel object
150 *
151 * @param id Global ID of the block
152 * @param model The model to which the block belongs
153 */
155 : Block(id, model, BlockType::chamber_elastance_inductor,
156 BlockClass::chamber,
157 {{"Emax", InputParameter()},
158 {"Emin", InputParameter()},
159 {"Vrd", InputParameter()},
160 {"Vrs", InputParameter()},
161 {"t_active", InputParameter()},
162 {"t_twitch", InputParameter()},
163 {"Impedance", InputParameter()}}) {}
164
165 /**
166 * @brief Local IDs of the parameters
167 *
168 */
169 enum ParamId {
170 EMAX = 0,
171 EMIN = 1,
172 VRD = 2,
173 VRS = 3,
174 TACTIVE = 4,
175 TTWITCH = 5,
176 IMPEDANCE = 6
177 };
178
179 /**
180 * @brief Set up the degrees of freedom (DOF) of the block
181 *
182 * Set global_var_ids and global_eqn_ids of the element based on the
183 * number of equations and the number of internal variables of the
184 * element.
185 *
186 * @param dofhandler Degree-of-freedom handler to register variables and
187 * equations at
188 */
189 void setup_dofs(DOFHandler &dofhandler);
190
191 /**
192 * @brief Update the constant contributions of the element in a sparse
193 system
194 *
195 * @param system System to update contributions at
196 * @param parameters Parameters of the model
197 */
198 void update_constant(SparseSystem &system, std::vector<double> &parameters);
199
200 /**
201 * @brief Update the time-dependent contributions of the element in a sparse
202 * system
203 *
204 * @param system System to update contributions at
205 * @param parameters Parameters of the model
206 */
207 void update_time(SparseSystem &system, std::vector<double> &parameters);
208
209 /**
210 * @brief Number of triplets of element
211 *
212 * Number of triplets that the element contributes to the global system
213 * (relevant for sparse memory reservation)
214 */
216
217 private:
218 double Elas; // Chamber Elastance
219 double Vrest; // Rest Volume
220
221 /**
222 * @brief Update the elastance functions which depend on time
223 *
224 * @param parameters Parameters of the model
225 */
226 void get_elastance_values(std::vector<double> &parameters);
227};
228
229#endif // SVZERODSOLVER_MODEL_CHAMBERELASTANCEINDUCTOR_HPP_
model::Block source file
BlockType
The types of blocks supported by the solver.
Definition BlockType.h:42
BlockClass
The classes/categories of blocks supported. Some classes require special handling (e....
Definition BlockType.h:64
model::Model source file
SparseSystem source file.
Base class for 0D model components.
Definition Block.h:101
const int id
Global ID of the block.
Definition Block.h:103
const Model * model
The model to which the block belongs.
Definition Block.h:104
Cardiac chamber with elastance and inductor.
Definition ChamberElastanceInductor.h:146
void setup_dofs(DOFHandler &dofhandler)
Set up the degrees of freedom (DOF) of the block.
Definition ChamberElastanceInductor.cpp:33
TripletsContributions num_triplets
Number of triplets of element.
Definition ChamberElastanceInductor.h:215
void update_time(SparseSystem &system, std::vector< double > &parameters)
Update the time-dependent contributions of the element in a sparse system.
Definition ChamberElastanceInductor.cpp:56
ChamberElastanceInductor(int id, Model *model)
Construct a new BloodVessel object.
Definition ChamberElastanceInductor.h:154
ParamId
Local IDs of the parameters.
Definition ChamberElastanceInductor.h:169
void update_constant(SparseSystem &system, std::vector< double > &parameters)
Update the constant contributions of the element in a sparse system.
Definition ChamberElastanceInductor.cpp:38
Degree-of-freedom handler.
Definition DOFHandler.h:48
Model of 0D elements.
Definition Model.h:75
Sparse system.
Definition SparseSystem.h:57
DEBUG_MSG source file.
Handles the properties of input parameters.
Definition Parameter.h:127
The number of triplets that the element contributes to the global system.
Definition Block.h:52