svZeroDSolver
Loading...
Searching...
No Matches
ClosedLoopRCRBC.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 ClosedLoopRCRbc.h
5 * @brief model::ClosedLoopRCRBC source file
6 */
7#ifndef SVZERODSOLVER_MODEL_CLOSEDLOOPRCRBC_HPP_
8#define SVZERODSOLVER_MODEL_CLOSEDLOOPRCRBC_HPP_
9
10#include "Block.h"
11#include "SparseSystem.h"
12
13/**
14 * @brief Closed-loop RCR boundary condition.
15 *
16 * Models the mechanical behavior of a Windkessel boundary condition that is
17 * connected to other blocks on both sides.
18 *
19 * \f[
20 * \begin{circuitikz} \draw
21 * node[left] {$Q_{in}$} [-latex] (0,0) -- (0.8,0);
22 * \draw (1,0) node[anchor=south]{$P_{in}$}
23 * to [R, l=$R_p$, *-] (3,0)
24 * node[anchor=south]{$P_{c}$}
25 * to [R, l=$R_d$, *-*] (5,0)
26 * node[anchor=south]{$P_{out}$}
27 * (3,0) to [C, l=$C$, *-] (3,-1.5)
28 * node[ground]{};
29 * \draw [-latex] (5.2,0) -- (6.0,0) node[right] {$Q_{out}$} ;
30 * \end{circuitikz}
31 * \f]
32 *
33 * ### Governing equations
34 *
35 * \f[
36 * C \frac{d P_c}{dt} + Q_{out} -Q_{in} = 0
37 * \f]
38 *
39 * \f[
40 * P_{in}-P_{c}-R_{p} Q_{in}=0
41 * \f]
42 *
43 * \f[
44 * P_{c} - P_{out} - R_{d} Q_{out}=0
45 * \f]
46 *
47 * ### Local contributions
48 *
49 * \f[
50 * \mathbf{y}^e=\left[\begin{array}{lllll}P_{in} & Q_{in} & P_{out} & Q_{out} &
51 * P_{c}\end{array}\right]^{T} \f]
52 *
53 * \f[
54 * \mathbf{E}^{e}=\left[\begin{array}{ccccc}
55 * 0 & 0 & 0 & 0 & C \\
56 * 0 & 0 & 0 & 0 & 0 \\
57 * 0 & 0 & 0 & 0 & 0 \\
58 * \end{array}\right]
59 * \f]
60 *
61 * \f[
62 * \mathbf{F}^{e}=\left[\begin{array}{ccccc}
63 * 0 & -1 & 1 & 0 & 0 \\
64 * 1 & -R_p & 0 & 0 & -1 \\
65 * 0 & 0 & -1 & -R_d & +1 \\
66 * \end{array}\right]
67 * \f]
68 *
69 * \f[
70 * \mathbf{c}^{e}=\left[\begin{array}{c}
71 * 0 \\
72 * 0 \\
73 * 0
74 * \end{array}\right]
75 * \f]
76 *
77 * ### Parameters
78 *
79 * Parameter sequence for constructing this block
80 *
81 * * `0` Proximal resistance
82 * * `1` Capacitance
83 * * `2` Distal resistance
84 *
85 * ### Usage in json configuration file
86 *
87 * "boundary_conditions": [
88 * {
89 * "bc_name": "RCR_aorta",
90 * "bc_type": "ClosedLoopRCR",
91 * "bc_values": {
92 * "_comment_": "R_total = 1.570879*0.948914 = 1.490629075, Rp =
93 * 0.09*R_total, Rd = 0.91*R_total, C = 0.228215*1.044637", "Rp": 0.134156617,
94 * "Rd": 1.356472458,
95 * "C": 0.238401833,
96 * "closed_loop_outlet": true
97 * }
98 * }
99 * ]
100 *
101 * ### Internal variables
102 *
103 * Names of internal variables in this block's output:
104 *
105 * * `P_c`: Pressure at the capacitor
106 *
107 */
108class ClosedLoopRCRBC : public Block {
109 public:
110 /**
111 * @brief Construct a new ClosedLoopRCRBC object
112 *
113 * @param id Global ID of the block
114 * @param model The model to which the block belongs
115 */
117 : Block(id, model, BlockType::closed_loop_rcr_bc,
118 BlockClass::boundary_condition,
119 {{"Rp", InputParameter()},
120 {"C", InputParameter()},
121 {"Rd", InputParameter()},
122 {"closed_loop_outlet", InputParameter(true, false, false)}}) {}
123
124 /**
125 * @brief Local IDs of the parameters
126 *
127 */
128 enum ParamId {
129 RP = 0,
130 C = 1,
131 RD = 2,
132 };
133
134 /**
135 * @brief Set up the degrees of freedom (DOF) of the block
136 *
137 * Set \ref global_var_ids and \ref global_eqn_ids of the element based on the
138 * number of equations and the number of internal variables of the
139 * element.
140 *
141 * @param dofhandler Degree-of-freedom handler to register variables and
142 * equations at
143 */
144 void setup_dofs(DOFHandler& dofhandler);
145
146 /**
147 * @brief Update the constant contributions of the element in a sparse
148 system
149 *
150 * @param system System to update contributions at
151 * @param parameters Parameters of the model
152 */
153 void update_constant(SparseSystem& system, std::vector<double>& parameters);
154
155 /**
156 * @brief Number of triplets of element
157 *
158 * Number of triplets that the element contributes to the global system
159 * (relevant for sparse memory reservation)
160 */
162};
163
164#endif // SVZERODSOLVER_MODEL_CLOSEDLOOPRCRBCBC_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:38
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
ClosedLoopRCRBC(int id, Model *model)
Construct a new ClosedLoopRCRBC object.
Definition ClosedLoopRCRBC.h:116
void update_constant(SparseSystem &system, std::vector< double > &parameters)
Update the constant contributions of the element in a sparse system.
Definition ClosedLoopRCRBC.cpp:9
void setup_dofs(DOFHandler &dofhandler)
Set up the degrees of freedom (DOF) of the block.
Definition ClosedLoopRCRBC.cpp:5
ParamId
Local IDs of the parameters.
Definition ClosedLoopRCRBC.h:128
TripletsContributions num_triplets
Number of triplets of element.
Definition ClosedLoopRCRBC.h:161
Degree-of-freedom handler.
Definition DOFHandler.h:21
Model of 0D elements.
Definition Model.h:49
Sparse system.
Definition SparseSystem.h:30
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