svZeroDSolver
Loading...
Searching...
No Matches
ClosedLoopCoronaryBC.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 ClosedLoopCoronaryBC.h
32 * @brief model::ClosedLoopCoronaryBC source file
33 */
34#ifndef SVZERODSOLVER_MODEL_CLOSEDLOOPCORONARYBC_HPP_
35#define SVZERODSOLVER_MODEL_CLOSEDLOOPCORONARYBC_HPP_
36
37#include "Block.h"
39#include "SparseSystem.h"
40
41/**
42 * @brief Closed loop coronary boundary condition which is connected to
43 * other blocks on both sides and the intramyocardial pressure is
44 * specified by the pressure in a heart block (not as a parameter).
45 *
46 * \f[
47 * \begin{circuitikz} \draw
48 * node[left] {$Q_{in}$} [-latex] (0,0) -- (0.8,0);
49 * \draw (1,0) node[anchor=south]{$P_{in}$}
50 * to [R, l=$R_a$, *-] (3,0)
51 * to [R, l=$R_{am}$, -] (5,0)
52 * to [R, l=$R_v$, *-*] (7,0)
53 * node[anchor=south]{$P_{out}$}
54 * (5,0) to [C, l=$C_{im} \;V_{im}$, -*] (5,-1.5)
55 * node[left]{$P_{im}$}
56 * (3,0) to [C, l=$C_a$, -*] (3,-1.5)
57 * node[left]{$P_a$};
58 * \draw [-latex] (7.2,0) -- (8.0,0) node[right] {$Q_{out}$};
59 * \end{circuitikz}
60 * \f]
61 *
62 * ### Governing equations
63 *
64 * \f[
65 * P_{out} - P_{in} + (R_{am}+R_a)Q_{in} + R_v Q_{out} + R_{am} C_a
66 * \frac{dP_a}{dt} - R_{am} C_a \frac{dP_{in}}{dt} + R_{am} R_a C_a
67 * \frac{dQ_{in}}{dt} = 0 \f]
68 *
69 * \f[
70 * Q_{in} - Q_{out} + C_a \frac{dP_a}{dt} - C_a \frac{dP_{in}}{dt} + C_a R_a
71 * \frac{dQ_{in}}{dt} - \frac{dV_{im}}{dt} = 0 \f]
72 *
73 * \f[
74 * C_{im} P_{out} + C_{im} R_v Q_{out} - C_{im} P_{im} - V_{im} = 0
75 * \f]
76 *
77 * ### Local contributions
78 *
79 * \f[
80 * \mathbf{y}^{e}=\left[\begin{array}{lllll}P_{in} & Q_{in} & P_{out} &
81 * Q_{out} & V_{im}\end{array}\right]^{T}, \f]
82 *
83 * \f[
84 * \mathbf{E}^{e}=\left[\begin{array}{ccccc}
85 * -R_{am} C_{a} & R_{am} R_{a} C_{a} & 0 & 0 & 0 \\
86 * -C_{a} & R_{a} C_{a} & 0 & 0 & -1 \\
87 * 0 & 0 & 0 & 0 & 0 \\
88 * \end{array}\right] \f]
89 *
90 *
91 * \f[
92 * \mathbf{F}^{e}=\left[\begin{array}{ccccc}
93 * -1 & R_{am} + R_{a} & 1 & R_v & 0 \\
94 * 0 & 1 & 0 & -1 & 0 \\
95 * 0 & 0 & C_{im} & C_{im} R_v & -1 \\
96 * \end{array}\right] \f]
97 *
98 * \f[
99 * \mathbf{c}^{e}=\left[\begin{array}{c}
100 * C_{a} R_{am} \frac{d P_{a}}{d t} \\
101 * C_{a}\frac{d P_{a}}{d t} \\
102 * -C_{im} P_{im}
103 * \end{array}\right] \f]
104 *
105 * Assume \f$P_a=0\f$.
106 *
107 * ### Parameters
108 *
109 * Parameter sequence for constructing this block
110 *
111 * * `0` Ra: Small artery resistance
112 * * `1` Ram: Microvascular resistance
113 * * `2` Rv: Venous resistance
114 * * `3` Ca: Small artery capacitance
115 * * `4` Cim: Intramyocardial capacitance
116 *
117 * ### Internal variables
118 *
119 * Names of internal variables in this block's output:
120 *
121 * * `volume_im`: Intramyocardial volume
122 *
123 */
125 public:
126 /**
127 * @brief Construct a ClosedLoopCoronaryBC object.
128 *
129 * @param id Global ID of the block
130 * @param model The model to which the block belongs
131 * @param block_type The specific type of block (left or right)
132 */
134 : Block(id, model, block_type, BlockClass::closed_loop,
135 {{"Ra", InputParameter()},
136 {"Ram", InputParameter()},
137 {"Rv", InputParameter()},
138 {"Ca", InputParameter()},
139 {"Cim", InputParameter()}}) {}
140
141 /**
142 * @brief Local IDs of the parameters
143 *
144 */
145 enum ParamId { RA = 0, RAM = 1, RV = 2, CA = 3, CIM = 4 };
146
147 /**
148 * @brief Set up the degrees of freedom (DOF) of the block
149 *
150 * Set \ref global_var_ids and \ref global_eqn_ids of the element based on the
151 * number of equations and the number of internal variables of the
152 * element.
153 *
154 * @param dofhandler Degree-of-freedom handler to register variables and
155 * equations at
156 */
157 void setup_dofs(DOFHandler &dofhandler);
158
159 /**
160 * @brief Setup parameters that depend on the model
161 *
162 */
164
165 /**
166 * @brief Update the constant contributions of the element in a sparse 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 solution-dependent contributions of the element in a
175 * sparse system
176 *
177 * @param system System to update contributions at
178 * @param parameters Parameters of the model
179 * @param y Current solution
180 * @param dy Current derivate of the solution
181 */
182 void update_solution(SparseSystem &system, std::vector<double> &parameters,
183 const Eigen::Matrix<double, Eigen::Dynamic, 1> &y,
184 const Eigen::Matrix<double, Eigen::Dynamic, 1> &dy);
185
186 /**
187 * @brief Number of triplets of element
188 *
189 * Number of triplets that the element contributes to the global system
190 * (relevant for sparse memory reservation)
191 */
193
194 protected:
195 int ventricle_var_id; ///< Variable index of either left or right ventricle
196 int im_param_id; ///< Index of parameter Im
197};
198
199#endif // SVZERODSOLVER_MODEL_CLOSEDLOOPCORONARYBC_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::ClosedLoopHeartPulmonary 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
const BlockType block_type
Type of this block.
Definition Block.h:105
Closed loop coronary boundary condition which is connected to other blocks on both sides and the intr...
Definition ClosedLoopCoronaryBC.h:124
TripletsContributions num_triplets
Number of triplets of element.
Definition ClosedLoopCoronaryBC.h:192
ParamId
Local IDs of the parameters.
Definition ClosedLoopCoronaryBC.h:145
void update_constant(SparseSystem &system, std::vector< double > &parameters)
Update the constant contributions of the element in a sparse system.
Definition ClosedLoopCoronaryBC.cpp:39
void setup_dofs(DOFHandler &dofhandler)
Set up the degrees of freedom (DOF) of the block.
Definition ClosedLoopCoronaryBC.cpp:35
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 ClosedLoopCoronaryBC.cpp:64
int ventricle_var_id
Variable index of either left or right ventricle.
Definition ClosedLoopCoronaryBC.h:195
ClosedLoopCoronaryBC(int id, Model *model, BlockType block_type)
Construct a ClosedLoopCoronaryBC object.
Definition ClosedLoopCoronaryBC.h:133
virtual void setup_model_dependent_params()=0
Setup parameters that depend on the model.
int im_param_id
Index of parameter Im.
Definition ClosedLoopCoronaryBC.h:196
Degree-of-freedom handler.
Definition DOFHandler.h:48
Model of 0D elements.
Definition Model.h:75
Sparse system.
Definition SparseSystem.h:88
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