1313
1414#include " ActivationFunction.h"
1515#include " Block.h"
16- #include " Model.h"
1716#include " SparseSystem.h"
1817#include " debug.h"
1918
2019/* *
21- * @brief Cardiac chamber with elastance and inductor.
20+ * @brief Cardiac chamber with linear elastance and inductor.
2221 *
2322 * Models a cardiac chamber as a time-varying capacitor (elastance with
2423 * specified resting volumes) and an inductor. See \cite kerckhoffs2007coupling
5554 * Q_{in}-Q_{out}-\dot{V}_c=0
5655 * \f]
5756 *
58- * ### Local contributions
59- *
60- * \f[
61- * \mathbf{y}^{e}=\left[\begin{array}{lllll}P_{in} & Q_{in} &
62- * P_{out} & Q_{out} & V_c\end{array}\right]^{T} \f]
63- *
64- * \f[
65- * \mathbf{E}^{e}=\left[\begin{array}{ccccc}
66- * 0 & 0 & 0 & 0 & 0\\
67- * 0 & 0 & 0 & -L & 0\\
68- * 0 & 0 & 0 & 0 & -1
69- * \end{array}\right]
70- * \f]
71- *
72- * \f[
73- * \mathbf{F}^{e}=\left[\begin{array}{ccccc}
74- * 1 & 0 & 0 & 0 & E(t) \\
75- * 1 & 0 & -1 & 0 & 0 \\
76- * 0 & 1 & 0 & -1 & 0
77- * \end{array}\right]
78- * \f]
79- *
80- * \f[
81- * \mathbf{c}^{e}=\left[\begin{array}{c}
82- * E(t)V_{rest} \\
83- * 0 \\
84- * 0
85- * \end{array}\right]
86- * \f]
87- *
88- * In the above equations,
57+ * where
8958 *
9059 * \f[
9160 * V_{rest}(t)= \{1-A(t)\}(V_{rd}-V_{rs})+V_{rs}
9261 * \f]
9362 *
9463 * \f[
95- * A(t)=-\frac{1}{2}cos(2 \pi T_{contract}/T_{twitch})
96- * \f]
97- *
98- * \f[
9964 * E(t)=(E_{max}-E_{min})A(t) + E_{min}
10065 * \f]
10166 *
102- *
10367 * ### Parameters
10468 *
105- * Parameter sequence for constructing this block
106- *
10769 * * `0` Emax: Maximum elastance
10870 * * `1` Emin: Minimum elastance
10971 * * `2` Vrd: Rest diastolic volume
11072 * * `3` Vrs: Rest systolic volume
111- * * `4` t_active: Activation time
112- * * `5` t_twitch: Twitch time
113- * * `6` Impedance: Impedance of the outflow
114- *
115- * ### Usage in json configuration file
116- *
117- * "chambers": [
118- * {
119- * "type": "ChamberElastanceInductor",
120- * "name": "ventricle",
121- * "values": {
122- * "Emax": 1.057,
123- * "Emin": 0.091,
124- * "Vrd": 26.1,
125- * "Vrs": 18.0,
126- * "Impedance": 0.000351787
127- * },
128- * "activation_function": {
129- * "type": "half_cosine",
130- * "t_active": 0.2,
131- * "t_twitch": 0.3
132- * }
133- * }
134- * ],
135- * "initial_condition": {
136- * "Vc:ventricle": 96.07
137- * }
73+ * * `4` Impedance: Impedance of the outflow
13874 *
13975 * ### Internal variables
14076 *
141- * Names of internal variables in this block's output:
142- *
14377 * * `Vc`: Chamber volume
14478 *
14579 */
@@ -158,93 +92,46 @@ class ChamberElastanceInductor : public Block {
15892 {" Emin" , InputParameter ()},
15993 {" Vrd" , InputParameter ()},
16094 {" Vrs" , InputParameter ()},
161- {" Impedance" , InputParameter ()},
162- {" Kxp" , InputParameter (true )},
163- {" Kxv" , InputParameter (true )},
164- {" Vaso" , InputParameter (true )}}) {}
95+ {" Impedance" , InputParameter ()}}) {}
16596
16697 /* *
16798 * @brief Local IDs of the parameters
168- *
16999 */
170100 enum ParamId {
171101 EMAX = 0 ,
172102 EMIN = 1 ,
173103 VRD = 2 ,
174104 VRS = 3 ,
175105 IMPEDANCE = 4 ,
176- KXP = 5 , // /< Passive pressure scaling (optional, 0 = linear mode)
177- KXV = 6 , // /< Passive volume scaling (optional)
178- VASO = 7 // /< Passive resting volume (optional)
179106 };
180107
181- /* *
182- * @brief Set up the degrees of freedom (DOF) of the block
183- *
184- * Set global_var_ids and global_eqn_ids of the element based on the
185- * number of equations and the number of internal variables of the
186- * element.
187- *
188- * @param dofhandler Degree-of-freedom handler to register variables and
189- * equations at
190- */
191108 void setup_dofs (DOFHandler& dofhandler);
192-
193- /* *
194- * @brief Update the constant contributions of the element in a sparse
195- system
196- *
197- * @param system System to update contributions at
198- * @param parameters Parameters of the model
199- */
200109 void update_constant (SparseSystem& system, std::vector<double >& parameters);
201-
202- /* *
203- * @brief Update the time-dependent contributions of the element in a sparse
204- * system
205- *
206- * @param system System to update contributions at
207- * @param parameters Parameters of the model
208- */
209110 void update_time (SparseSystem& system, std::vector<double >& parameters);
210111
211- /* *
212- * @brief Update the solution-dependent contributions of the element in a
213- * sparse system. Only active when Kxp > 0 (exponential passive atrial mode).
214- */
215- void update_solution (SparseSystem& system, std::vector<double >& parameters,
216- const Eigen::Matrix<double , Eigen::Dynamic, 1 >& y,
217- const Eigen::Matrix<double , Eigen::Dynamic, 1 >& dy);
218-
219- /* *
220- * @brief Number of triplets of element
221- *
222- * Number of triplets that the element contributes to the global system
223- * (relevant for sparse memory reservation)
224- */
225- TripletsContributions num_triplets{6 , 2 , 1 };
112+ TripletsContributions num_triplets{6 , 2 , 0 };
226113
227- private:
228- double Elas; // Chamber Elastance
229- double Vrest; // Rest Volume
230- double act_ = 0.0 ; // Last computed activation
231- std::unique_ptr<ActivationFunction> activation_func_; // Activation function
114+ void set_activation_function (std::unique_ptr<ActivationFunction> af) override ;
232115
233- public :
116+ protected :
234117 /* *
235- * @brief Set the activation function (takes ownership)
236- *
237- * @param af Unique pointer to the activation function
118+ * @brief Construct a ChamberElastanceInductor with custom block type and
119+ * parameters. Used by derived classes.
238120 */
239- void set_activation_function (std::unique_ptr<ActivationFunction> af) override ;
121+ ChamberElastanceInductor (
122+ int id, Model* model, BlockType block_type,
123+ std::vector<std::pair<std::string, InputParameter>> params)
124+ : Block(id, model, block_type, BlockClass::chamber, params) {}
125+
126+ double Elas = 0.0 ; // /< Current chamber elastance
127+ double Vrest = 0.0 ; // /< Current rest volume
128+ double act_ = 0.0 ; // /< Last computed activation
129+ std::unique_ptr<ActivationFunction> activation_func_;
240130
241- private:
242131 /* *
243- * @brief Update the elastance functions which depend on time
244- *
245- * @param parameters Parameters of the model
132+ * @brief Compute elastance and rest volume from activation and parameters.
246133 */
247- void get_elastance_values (std::vector<double >& parameters);
134+ virtual void get_elastance_values (std::vector<double >& parameters);
248135};
249136
250137#endif // SVZERODSOLVER_MODEL_CHAMBERELASTANCEINDUCTOR_HPP_
0 commit comments