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 * ### Internal variables
86 *
87 * Names of internal variables in this block's output:
88 *
89 * * `P_c`: Pressure at the capacitor
90 *
91 */
92class ClosedLoopRCRBC : public Block {
93 public:
94 /**
95 * @brief Construct a new ClosedLoopRCRBC object
96 *
97 * @param id Global ID of the block
98 * @param model The model to which the block belongs
99 */
101 : Block(id, model, BlockType::closed_loop_rcr_bc,
102 BlockClass::boundary_condition,
103 {{"Rp", InputParameter()},
104 {"C", InputParameter()},
105 {"Rd", InputParameter()},
106 {"closed_loop_outlet", InputParameter(true, false, false)}}) {}
107
108 /**
109 * @brief Local IDs of the parameters
110 *
111 */
112 enum ParamId {
113 RP = 0,
114 C = 1,
115 RD = 2,
116 };
117
118 /**
119 * @brief Set up the degrees of freedom (DOF) of the block
120 *
121 * Set \ref global_var_ids and \ref global_eqn_ids of the element based on the
122 * number of equations and the number of internal variables of the
123 * element.
124 *
125 * @param dofhandler Degree-of-freedom handler to register variables and
126 * equations at
127 */
128 void setup_dofs(DOFHandler &dofhandler);
129
130 /**
131 * @brief Update the constant contributions of the element in a sparse
132 system
133 *
134 * @param system System to update contributions at
135 * @param parameters Parameters of the model
136 */
137 void update_constant(SparseSystem &system, std::vector<double> &parameters);
138
139 /**
140 * @brief Number of triplets of element
141 *
142 * Number of triplets that the element contributes to the global system
143 * (relevant for sparse memory reservation)
144 */
146};
147
148#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:37
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:100
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:112
TripletsContributions num_triplets
Number of triplets of element.
Definition ClosedLoopRCRBC.h:145
Degree-of-freedom handler.
Definition DOFHandler.h:21
Model of 0D elements.
Definition Model.h:48
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