svZeroDSolver
Loading...
Searching...
No Matches
OpenLoopCoronaryBC.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 OpenLoopCoronaryBC.h
32 * @brief model::OpenLoopCoronaryBC source file
33 */
34#ifndef SVZERODSOLVER_MODEL_OPENLOOPCORONARYBC_HPP_
35#define SVZERODSOLVER_MODEL_OPENLOOPCORONARYBC_HPP_
36
37#include "Block.h"
38#include "Parameter.h"
39#include "SparseSystem.h"
40
41/**
42 * @brief Open loop coronary boundary condition based on \cite kim_coronary.
43 *
44 * \f[
45 * \begin{circuitikz} \draw
46 * node[left] {$Q_{in}$} [-latex] (0,0) -- (0.8,0);
47 * \draw (1,0) node[anchor=south]{$P_{in}$}
48 * to [R, l=$R_a$, *-*] (3,0)
49 * to [R, l=$R_{am}$, -] (5,0)
50 * node[anchor=south]{$P_{cim}$}
51 * to [R, l=$R_v$, *-*] (7,0)
52 * node[anchor=south]{$P_{v}$}
53 * (5,0) to [C, l=$C_{im} \;V_{im}$, -*] (5,-1.5)
54 * node[left]{$P_{im}$}
55 * (3,0) to [C, l=$C_a$, -*] (3,-1.5)
56 * node[left]{$P_a$};
57 * \end{circuitikz}
58 * \f]
59 *
60 * ### Governing equations
61 *
62 * \f{eqnarray*}{
63 * &C_{i m} R_{v} Q_{in}-V_{i m}+C_{i m} \left(-P_{c i m}(0)+P_{i m}(0)-P_{i
64 * m}+P_{v}\right)-C_{i m} R_{v} \frac{d V_{i m}}{d t}-C_{a} C_{i m} R_{v}
65 * \frac{d P_{in}}{d t}+R_{a} C_{a} C_{i m} R_{v} \frac{d Q_{in}}{d t}\\ &+C_{a}
66 * C_{i m} R_{v} \frac{d P_{a}}{d t}=0
67 * \f}
68 *
69 * \f{eqnarray*}{
70 * &C_{i m} R_v P_{in}-C_{i m} R_{v} R_{a} Q_{in}-R_{v} V_{i m}-C_{i
71 * m}\left(R_{v}+R_{a m}\right) \left(P_{c i m}(0)-P_{i m}(0)+P_{i
72 * m}\right)-C_{i m} R_{v} R_{a m} \frac{d V_{i m}}{d t} \\ &-R_{a m} V_{i
73 * m}+R_{a m} C_{i m} P_{v}=0 \f}
74 *
75 * ### Local contributions
76 *
77 * \f[
78 * \mathbf{y}^{e}=\left[\begin{array}{lll}P_{in} & Q_{in} & V_{i
79 * m}\end{array}\right]^{T}, \f]
80 *
81 * \f[
82 * \mathbf{E}^{e}=\left[\begin{array}{ccc}-C_{a} C_{i m} R_{v} & R_{a} C_{a}
83 * C_{i m} R_{v} & -C_{i m} R_{v} \\ 0 & 0 & -C_{i m} R_{v} R_{a
84 * m}\end{array}\right] \f]
85 *
86 * \f[
87 * \mathbf{F}^{e}=\left[\begin{array}{ccc}0 & C_{i m} R_{v} & -1 \\C_{i m} R_{v}
88 * & -C_{i m} R_{v} R_{a} & -\left(R_{v}+R_{a m}\right)\end{array}\right] \f]
89 *
90 * \f[
91 * \mathbf{c}^{e}=\left[\begin{array}{c}C_{i m}\left(-P_{i m}+P_{i m}(0)-P_{c i
92 * m}(0)+P_{v}\right)+C_{a} C_{i m} R_{v} \frac{d P_{a}}{d t} \\-C_{i
93 * m}\left(R_{v} + R_{a m}\right)\left(P_{cim}(0)-P_{i m}(0)+P_{i m}\right)+R_{a
94 * m} C_{i m} P_{v}\end{array}\right] \f]
95 *
96 * Assume \f$P_a=0\f$.
97 *
98 * ### Parameters
99 *
100 * Parameter sequence for constructing this block
101 *
102 * * `0` Ra: Small artery resistance
103 * * `1` Ram: Microvascualar resistance
104 * * `2` Rv: Venous resistance
105 * * `3` Ca: Small artery capacitance
106 * * `4` Cim: Intramyocardial capacitance
107 * * `5` Pim: Intramyocardial pressure
108 * * `6` Pv: Venous pressure
109 *
110 * ### Internal variables
111 *
112 * Names of internal variables in this block's output:
113 *
114 * * `volume_im`: Intramyocardial volume
115 *
116 */
117class OpenLoopCoronaryBC : public Block {
118 public:
119 /**
120 * @brief Construct a new OpenLoopCoronaryBC object
121 *
122 * @param id Global ID of the block
123 * @param model The model to which the block belongs
124 */
126 : Block(id, model, BlockType::open_loop_coronary_bc,
127 BlockClass::boundary_condition,
128 {{"Ra1", InputParameter()},
129 {"Ra2", InputParameter()},
130 {"Rv1", InputParameter()},
131 {"Ca", InputParameter()},
132 {"Cc", InputParameter()},
133 {"t", InputParameter(false, true)},
134 {"Pim", InputParameter(false, true)},
135 {"P_v", InputParameter()},
136 {"closed_loop_outlet", InputParameter(true, false, false)}}) {}
137
138 /**
139 * @brief Set up the degrees of freedom (DOF) of the block
140 *
141 * Set \ref global_var_ids and \ref global_eqn_ids of the element based on the
142 * number of equations and the number of internal variables of the
143 * element.
144 *
145 * @param dofhandler Degree-of-freedom handler to register variables and
146 * equations at
147 */
148 void setup_dofs(DOFHandler &dofhandler);
149
150 /**
151 * @brief Setup parameters that depend on the initial state
152 *
153 * @param initial_state The initial state of the system
154 * @param parameters The parameter values vector (at time 0)
155 */
157 std::vector<double> &parameters);
158
159 /**
160 * @brief Update the constant contributions of the element in a sparse system
161 *
162 * @param system System to update contributions at
163 * @param parameters Parameters of the model
164 */
165 void update_constant(SparseSystem &system, std::vector<double> &parameters);
166
167 /**
168 * @brief Update the time-dependent contributions of the element in a sparse
169 * system
170 *
171 * @param system System to update contributions at
172 * @param parameters Parameters of the model
173 */
174 void update_time(SparseSystem &system, std::vector<double> &parameters);
175
176 /**
177 * @brief Number of triplets of element
178 *
179 * Number of triplets that the element contributes to the global system
180 * (relevant for sparse memory reservation)
181 */
183
184 protected:
185 double P_Cim_0 = 0; ///< Pressure proximal to Cim/Vim at initial state
186 double Pim_0 = 0; ///< Pim at initial state
187};
188
189#endif // SVZERODSOLVER_MODEL_OPENLOOPCORONARYBC_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::Parameter 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
Degree-of-freedom handler.
Definition DOFHandler.h:48
Model of 0D elements.
Definition Model.h:75
Open loop coronary boundary condition based on kim_coronary.
Definition OpenLoopCoronaryBC.h:117
OpenLoopCoronaryBC(int id, Model *model)
Construct a new OpenLoopCoronaryBC object.
Definition OpenLoopCoronaryBC.h:125
void setup_initial_state_dependent_params(State initial_state, std::vector< double > &parameters)
Setup parameters that depend on the initial state.
Definition OpenLoopCoronaryBC.cpp:87
void setup_dofs(DOFHandler &dofhandler)
Set up the degrees of freedom (DOF) of the block.
Definition OpenLoopCoronaryBC.cpp:33
TripletsContributions num_triplets
Number of triplets of element.
Definition OpenLoopCoronaryBC.h:182
void update_time(SparseSystem &system, std::vector< double > &parameters)
Update the time-dependent contributions of the element in a sparse system.
Definition OpenLoopCoronaryBC.cpp:68
double Pim_0
Pim at initial state.
Definition OpenLoopCoronaryBC.h:186
double P_Cim_0
Pressure proximal to Cim/Vim at initial state.
Definition OpenLoopCoronaryBC.h:185
void update_constant(SparseSystem &system, std::vector< double > &parameters)
Update the constant contributions of the element in a sparse system.
Definition OpenLoopCoronaryBC.cpp:37
Sparse system.
Definition SparseSystem.h:88
State of the system.
Definition State.h:46
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