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