1 | package Cardiovascular
|
---|
2 | package Model
|
---|
3 | extends Modelica.Icons.ExamplesPackage;
|
---|
4 |
|
---|
5 | package Smith2004
|
---|
6 | extends Modelica.Icons.ExamplesPackage;
|
---|
7 |
|
---|
8 | package Parts
|
---|
9 | extends Modelica.Icons.UtilitiesPackage;
|
---|
10 | type HydraulicLambda = Real(final quantity = "HydraulicLambda", final unit = "1/m3", displayUnit = "1/ml", nominal = 1e-5, min = 0);
|
---|
11 | end Parts;
|
---|
12 | end Smith2004;
|
---|
13 | end Model;
|
---|
14 |
|
---|
15 | package Icons
|
---|
16 | model Runnable_Shallow annotation(experiment(StopTime = 5, __Dymola_NumberOfIntervals = 5000)); end Runnable_Shallow;
|
---|
17 | end Icons;
|
---|
18 | end Cardiovascular;
|
---|
19 |
|
---|
20 | package Physiolibrary "Modelica library for Physiology (version 2.3.2-beta)"
|
---|
21 | extends Modelica.Icons.Package;
|
---|
22 |
|
---|
23 | package Hydraulic "Domain with Pressure and Volumetric Flow"
|
---|
24 | extends Modelica.Icons.Package;
|
---|
25 |
|
---|
26 | package Components
|
---|
27 | extends Modelica.Icons.Package;
|
---|
28 |
|
---|
29 | model Conductor "Hydraulic resistor, where conductance=1/resistance"
|
---|
30 | extends Hydraulic.Interfaces.OnePort;
|
---|
31 | extends Icons.HydraulicResistor;
|
---|
32 | parameter Boolean useConductanceInput = false "=true, if external conductance value is used" annotation(Evaluate = true, HideResult = true);
|
---|
33 | parameter Types.HydraulicConductance Conductance = 0 "Hydraulic conductance if useConductanceInput=false";
|
---|
34 | Types.RealIO.HydraulicConductanceInput cond(start = Conductance) = c if useConductanceInput;
|
---|
35 | protected
|
---|
36 | Types.HydraulicConductance c;
|
---|
37 | equation
|
---|
38 | if not useConductanceInput then
|
---|
39 | c = Conductance;
|
---|
40 | end if;
|
---|
41 | q_in.q = c * (q_in.pressure - q_out.pressure);
|
---|
42 | end Conductor;
|
---|
43 |
|
---|
44 | model Resistor
|
---|
45 | extends Physiolibrary.Hydraulic.Components.Conductor(final Conductance = 1 / Resistance);
|
---|
46 | parameter Physiolibrary.Types.HydraulicResistance Resistance "Hydraulic conductance if useConductanceInput=false";
|
---|
47 | end Resistor;
|
---|
48 |
|
---|
49 | model ElasticVessel "Elastic container for blood vessels, bladder, lumens"
|
---|
50 | extends Icons.ElasticBalloon;
|
---|
51 | extends SteadyStates.Interfaces.SteadyState(state_start = volume_start);
|
---|
52 | Interfaces.HydraulicPort_a q_in;
|
---|
53 | parameter Types.Volume volume_start = 1e-11 "Volume start value";
|
---|
54 | Types.Volume excessVolume "Additional volume, that generate pressure";
|
---|
55 | parameter Boolean useV0Input = false "=true, if zero-pressure-volume input is used" annotation(Evaluate = true, HideResult = true);
|
---|
56 | parameter Types.Volume ZeroPressureVolume = 1e-11 "Maximal volume, that does not generate pressure if useV0Input=false";
|
---|
57 | parameter Types.Volume CollapsingPressureVolume = 1e-12 "Maximal volume, which generate negative collapsing pressure";
|
---|
58 | Types.RealIO.VolumeInput zeroPressureVolume(start = ZeroPressureVolume) = zpv if useV0Input;
|
---|
59 | parameter Boolean useComplianceInput = false "=true, if compliance input is used" annotation(Evaluate = true, HideResult = true);
|
---|
60 | parameter Types.HydraulicCompliance Compliance = 1 "Compliance if useComplianceInput=false";
|
---|
61 | Types.RealIO.HydraulicComplianceInput compliance(start = Compliance) = c if useComplianceInput;
|
---|
62 | parameter Boolean useExternalPressureInput = false "=true, if external pressure input is used" annotation(Evaluate = true, HideResult = true);
|
---|
63 | parameter Types.Pressure ExternalPressure = 0 "External pressure. Set zero if internal pressure is relative to external. Valid only if useExternalPressureInput=false.";
|
---|
64 | parameter Types.Pressure MinimalCollapsingPressure = -101325;
|
---|
65 | Types.RealIO.PressureInput externalPressure(start = ExternalPressure) = ep if useExternalPressureInput;
|
---|
66 | Types.RealIO.VolumeOutput volume;
|
---|
67 | protected
|
---|
68 | Types.Volume zpv;
|
---|
69 | Types.HydraulicCompliance c;
|
---|
70 | Types.Pressure ep;
|
---|
71 | parameter Types.Pressure a = MinimalCollapsingPressure / log(Modelica.Constants.eps);
|
---|
72 | equation
|
---|
73 | if not useV0Input then
|
---|
74 | zpv = ZeroPressureVolume;
|
---|
75 | end if;
|
---|
76 | if not useComplianceInput then
|
---|
77 | c = Compliance;
|
---|
78 | end if;
|
---|
79 | if not useExternalPressureInput then
|
---|
80 | ep = ExternalPressure;
|
---|
81 | end if;
|
---|
82 | excessVolume = max(0, volume - zpv);
|
---|
83 | q_in.pressure = smooth(0, if noEvent(volume > CollapsingPressureVolume) then excessVolume / c + ep else a * log(max(Modelica.Constants.eps, volume / CollapsingPressureVolume)) + ep);
|
---|
84 | state = volume;
|
---|
85 | change = q_in.q;
|
---|
86 | end ElasticVessel;
|
---|
87 |
|
---|
88 | model ElasticVesselElastance
|
---|
89 | extends Physiolibrary.Hydraulic.Components.ElasticVessel(final Compliance = 1 / Elastance);
|
---|
90 | parameter Physiolibrary.Types.HydraulicElastance Elastance = 1 "Elastance if useComplianceInput=false";
|
---|
91 | end ElasticVesselElastance;
|
---|
92 |
|
---|
93 | model Inertia "Inertia of the volumetric flow"
|
---|
94 | extends SteadyStates.Interfaces.SteadyState(state_start = volumeFlow_start);
|
---|
95 | extends Interfaces.OnePort;
|
---|
96 | extends Icons.Inertance;
|
---|
97 | parameter Types.VolumeFlowRate volumeFlow_start = 0.3 "Volumetric flow start value";
|
---|
98 | parameter Types.HydraulicInertance I "Inertance";
|
---|
99 | equation
|
---|
100 | state = q_in.q;
|
---|
101 | change = (q_in.pressure - q_out.pressure) / I;
|
---|
102 | end Inertia;
|
---|
103 |
|
---|
104 | model IdealValve
|
---|
105 | extends Interfaces.OnePort;
|
---|
106 | Boolean open(start = true) "Switching state";
|
---|
107 | Real passableVariable(start = 0, final unit = "1") "Auxiliary variable for actual position on the ideal diode characteristic";
|
---|
108 | parameter Types.HydraulicConductance _Gon(final min = 0, displayUnit = "l/(mmHg.min)") = 1.2501026264094e-02 "Forward state-on conductance (open valve conductance)";
|
---|
109 | parameter Types.HydraulicConductance _Goff(final min = 0, displayUnit = "l/(mmHg.min)") = 1.2501026264094e-12 "Backward state-off conductance (closed valve conductance)";
|
---|
110 | parameter Types.Pressure Pknee(final min = 0) = 0 "Forward threshold pressure";
|
---|
111 | parameter Boolean useLimitationInputs = false "=true, if Gon and Goff are from inputs" annotation(Evaluate = true, HideResult = true);
|
---|
112 | Types.RealIO.HydraulicConductanceInput Gon(start = _Gon) = gon if useLimitationInputs "open valve conductance = infinity for ideal case";
|
---|
113 | Types.RealIO.HydraulicConductanceInput Goff(start = _Goff) = goff if useLimitationInputs "closed valve conductance = zero for ideal case";
|
---|
114 | protected
|
---|
115 | Types.HydraulicConductance gon;
|
---|
116 | Types.HydraulicConductance goff;
|
---|
117 | constant Types.Pressure unitPressure = 1;
|
---|
118 | constant Types.VolumeFlowRate unitFlow = 1;
|
---|
119 | equation
|
---|
120 | if not useLimitationInputs then
|
---|
121 | gon = _Gon;
|
---|
122 | goff = _Goff;
|
---|
123 | end if;
|
---|
124 | open = passableVariable > Modelica.Constants.eps;
|
---|
125 | dp = passableVariable * unitFlow * (if open then 1 / gon else 1) + Pknee;
|
---|
126 | volumeFlowRate = passableVariable * unitPressure * (if open then 1 else goff) + goff * Pknee;
|
---|
127 | end IdealValve;
|
---|
128 |
|
---|
129 | model IdealValveResistance
|
---|
130 | extends Physiolibrary.Hydraulic.Components.IdealValve(final _Gon = 1 / _Ron);
|
---|
131 | parameter Physiolibrary.Types.HydraulicResistance _Ron = 79.993432449 "forward state resistance";
|
---|
132 | end IdealValveResistance;
|
---|
133 | end Components;
|
---|
134 |
|
---|
135 | package Sensors
|
---|
136 | extends Modelica.Icons.SensorsPackage;
|
---|
137 |
|
---|
138 | model PressureMeasure "Hydraulic pressure at port"
|
---|
139 | extends Icons.PressureMeasure;
|
---|
140 | Interfaces.HydraulicPort_a q_in;
|
---|
141 | Types.RealIO.PressureOutput pressure "Pressure";
|
---|
142 | equation
|
---|
143 | pressure = q_in.pressure;
|
---|
144 | q_in.q = 0;
|
---|
145 | end PressureMeasure;
|
---|
146 | end Sensors;
|
---|
147 |
|
---|
148 | package Interfaces
|
---|
149 | extends Modelica.Icons.InterfacesPackage;
|
---|
150 |
|
---|
151 | connector HydraulicPort "Hydraulical connector with pressure and volumetric flow"
|
---|
152 | Types.Pressure pressure "Pressure";
|
---|
153 | flow Types.VolumeFlowRate q "Volume flow";
|
---|
154 | end HydraulicPort;
|
---|
155 |
|
---|
156 | connector HydraulicPort_a "Hydraulical inflow connector"
|
---|
157 | extends HydraulicPort;
|
---|
158 | end HydraulicPort_a;
|
---|
159 |
|
---|
160 | connector HydraulicPort_b "Hydraulical outflow connector"
|
---|
161 | extends HydraulicPort;
|
---|
162 | end HydraulicPort_b;
|
---|
163 |
|
---|
164 | partial model OnePort "Hydraulical OnePort"
|
---|
165 | HydraulicPort_a q_in "Volume inflow";
|
---|
166 | HydraulicPort_b q_out "Volume outflow";
|
---|
167 | Types.VolumeFlowRate volumeFlowRate "Volumetric flow";
|
---|
168 | Types.Pressure dp "Pressure gradient";
|
---|
169 | equation
|
---|
170 | q_in.q + q_out.q = 0;
|
---|
171 | volumeFlowRate = q_in.q;
|
---|
172 | dp = q_in.pressure - q_out.pressure;
|
---|
173 | end OnePort;
|
---|
174 | end Interfaces;
|
---|
175 | end Hydraulic;
|
---|
176 |
|
---|
177 | package SteadyStates "Dynamic Simulation / Steady State"
|
---|
178 | extends Modelica.Icons.Package;
|
---|
179 |
|
---|
180 | package Interfaces
|
---|
181 | extends Modelica.Icons.InterfacesPackage;
|
---|
182 |
|
---|
183 | partial model SteadyState "Abstract class for any dynamic state calculation (for any derivation), which is driven by SimulationType option."
|
---|
184 | parameter Types.SimulationType Simulation = Types.SimulationType.NormalInit "Dynamic with Initialization or Steady State" annotation(Evaluate = true, HideResult = true);
|
---|
185 | parameter Real state_start "State start or init value" annotation(HideResult = true);
|
---|
186 | Real state(start = state_start, stateSelect = StateSelect.prefer) "This state must be connected in inherited class definition" annotation(HideResult = true);
|
---|
187 | Real change "Dynamic change of state value per minute" annotation(HideResult = true);
|
---|
188 | initial equation
|
---|
189 | if Simulation == Types.SimulationType.NormalInit then
|
---|
190 | state = state_start;
|
---|
191 | end if;
|
---|
192 | equation
|
---|
193 | der(state) = change;
|
---|
194 | end SteadyState;
|
---|
195 | end Interfaces;
|
---|
196 | end SteadyStates;
|
---|
197 |
|
---|
198 | package Icons "Icons for physiological models"
|
---|
199 | extends Modelica.Icons.Package;
|
---|
200 |
|
---|
201 | class ElasticBalloon end ElasticBalloon;
|
---|
202 |
|
---|
203 | partial class HydraulicResistor end HydraulicResistor;
|
---|
204 |
|
---|
205 | class PressureMeasure end PressureMeasure;
|
---|
206 |
|
---|
207 | class Inertance end Inertance;
|
---|
208 | end Icons;
|
---|
209 |
|
---|
210 | package Types "Physiological units with nominals"
|
---|
211 | extends Modelica.Icons.Package;
|
---|
212 |
|
---|
213 | package Constants
|
---|
214 | extends Modelica.Icons.SourcesPackage;
|
---|
215 |
|
---|
216 | block FrequencyConst "Constant signal of type Frequency"
|
---|
217 | parameter Types.Frequency k "Constant Frequency output value";
|
---|
218 | RealIO.FrequencyOutput y "Frequency constant";
|
---|
219 | equation
|
---|
220 | y = k;
|
---|
221 | end FrequencyConst;
|
---|
222 |
|
---|
223 | block PressureConst "Constant signal of type Pressure"
|
---|
224 | parameter Types.Pressure k "Constant Pressure output value";
|
---|
225 | RealIO.PressureOutput y "Pressure constant";
|
---|
226 | equation
|
---|
227 | y = k;
|
---|
228 | end PressureConst;
|
---|
229 | end Constants;
|
---|
230 |
|
---|
231 | package RealIO
|
---|
232 | extends Modelica.Icons.Package;
|
---|
233 | connector PressureInput = input Pressure "input Pressure as connector";
|
---|
234 | connector PressureOutput = output Pressure "output Pressure as connector";
|
---|
235 | connector VolumeInput = input Volume "input Volume as connector";
|
---|
236 | connector VolumeOutput = output Volume "output Volume as connector";
|
---|
237 | connector FrequencyInput = input Frequency "input Frequency as connector";
|
---|
238 | connector FrequencyOutput = output Frequency "output Frequency as connector";
|
---|
239 | connector HydraulicConductanceInput = input HydraulicConductance "input HydraulicConductance as connector";
|
---|
240 | connector HydraulicComplianceInput = input HydraulicCompliance "input HydraulicCompliance as connector";
|
---|
241 | end RealIO;
|
---|
242 |
|
---|
243 | type Time = Modelica.SIunits.Time(displayUnit = "min", nominal = 60);
|
---|
244 | type Frequency = Modelica.SIunits.Frequency(displayUnit = "1/min");
|
---|
245 | type Mass = Modelica.SIunits.Mass(displayUnit = "g", nominal = 1e-3, min = 0);
|
---|
246 | type Pressure = Modelica.SIunits.Pressure(displayUnit = "mmHg", nominal = 133.322387415);
|
---|
247 | type Volume = Modelica.SIunits.Volume(displayUnit = "ml", nominal = 1e-6, min = 0);
|
---|
248 | type VolumeFlowRate = Modelica.SIunits.VolumeFlowRate(displayUnit = "ml/min", nominal = 1e-6 / 60);
|
---|
249 | type HydraulicConductance = Real(final quantity = "HydraulicConductance", final unit = "m3/(Pa.s)", displayUnit = "ml/(mmHg.min)", nominal = 1e-6 / (133.322387415 * 60), min = 0);
|
---|
250 | type HydraulicResistance = Real(final quantity = "HydraulicConductance", final unit = "(Pa.s)/m3", displayUnit = "(mmHg.min)/ml", nominal = 1e+6 * 133.322387415 * 60, min = 0);
|
---|
251 | type HydraulicCompliance = Real(final quantity = "HydraulicCompliance", final unit = "m3/Pa", displayUnit = "ml/mmHg", nominal = 1e-6 / 133.322387415);
|
---|
252 | type HydraulicElastance = Real(final quantity = "HydraulicElastance", final unit = "Pa/m3", displayUnit = "mmHg/ml", nominal = 133.322387415 / 1e-6);
|
---|
253 | type HydraulicInertance = Real(final quantity = "HydraulicInertance", final unit = "Pa.s2/m3", displayUnit = "mmHg.min2/ml", nominal = 133.322387415 * 60 ^ 2 / 1e-6);
|
---|
254 | type SimulationType = enumeration(NoInit "Use start values only as a guess of state values", NormalInit "Initialization by start values", InitSteadyState "Initialization in Steady State (initial derivations are zeros)", SteadyState "Steady State = Derivations are zeros during simulation") "Initialization or Steady state options (to determine model type before simulating)" annotation(Evaluate = true);
|
---|
255 | end Types;
|
---|
256 | annotation(version = "2.3.2-beta", versionBuild = 1, versionDate = "2015-09-15", dateModified = "2015-09-15 12:49:00Z");
|
---|
257 | end Physiolibrary;
|
---|
258 |
|
---|
259 | package FMITest
|
---|
260 | model HemodynamicsSmith_shallow
|
---|
261 | extends Cardiovascular.Icons.Runnable_Shallow;
|
---|
262 | .Physiolibrary.Hydraulic.Components.ElasticVesselElastance aorta(ZeroPressureVolume = 0, volume_start = 0.0001241, Elastance = 92165766.41999);
|
---|
263 | .Physiolibrary.Hydraulic.Components.ElasticVesselElastance venaCava(ZeroPressureVolume = 0, volume_start = 0.0002952, Elastance(displayUnit = "Pa/m3") = 786602.0857485);
|
---|
264 | .Physiolibrary.Hydraulic.Components.IdealValveResistance aorticValve(Pknee = 0, _Ron(displayUnit = "(mmHg.s)/ml") = 2399802.97347);
|
---|
265 | .Physiolibrary.Hydraulic.Components.Resistor Rsys(Resistance(displayUnit = "(mmHg.s)/ml") = 145054757.50752);
|
---|
266 | .Physiolibrary.Hydraulic.Components.IdealValveResistance tricuspidValve(Pknee = 0, _Ron(displayUnit = "(mmHg.s)/ml") = 3159740.5817355);
|
---|
267 | .Physiolibrary.Hydraulic.Components.Inertia Lav(I(displayUnit = "mmHg.s2/ml") = 16250.665802014, volumeFlow_start(displayUnit = "m3/s") = -1.4e-8);
|
---|
268 | .Physiolibrary.Hydraulic.Components.Inertia Lpv(I(displayUnit = "mmHg.s2/ml") = 19822.372560862, volumeFlow_start(displayUnit = "m3/s") = -1.9e-9);
|
---|
269 | .Physiolibrary.Hydraulic.Components.IdealValveResistance pulmonaryValve(Pknee = 0, _Ron(displayUnit = "(mmHg.s)/ml") = 733273.1307825);
|
---|
270 | .Physiolibrary.Hydraulic.Components.ElasticVesselElastance pulmonaryArteries(ZeroPressureVolume = 0, useExternalPressureInput = true, volume_start = 3.904e-05, Elastance(displayUnit = "Pa/m3") = 49195960.956135);
|
---|
271 | .Physiolibrary.Hydraulic.Components.Resistor Rpul(Resistance(displayUnit = "(mmHg.s)/ml") = 20691634.526808);
|
---|
272 | .Physiolibrary.Hydraulic.Components.ElasticVesselElastance pulmonaryVeins(ZeroPressureVolume = 0, useExternalPressureInput = true, volume_start = 0.0008269, Elastance(displayUnit = "Pa/m3") = 973253.4281295);
|
---|
273 | .Physiolibrary.Hydraulic.Components.IdealValveResistance mitralValve(Pknee = 0, _Ron(displayUnit = "(mmHg.s)/ml") = 2106493.721157);
|
---|
274 | .Physiolibrary.Hydraulic.Components.Inertia Ltc(I(displayUnit = "mmHg.s2/ml") = 10678.18997523, volumeFlow_start(displayUnit = "m3/s") = 0.0001372);
|
---|
275 | .Physiolibrary.Hydraulic.Components.Inertia Lmt(I(displayUnit = "mmHg.s2/ml") = 10261.557514558, volumeFlow_start(displayUnit = "m3/s") = 0.0001141);
|
---|
276 | Physiolibrary.Types.Constants.FrequencyConst HR(k = 1.3333333333333);
|
---|
277 | Physiolibrary.Types.Constants.PressureConst IntraThoracicPressure(k = -533.28954966);
|
---|
278 | VentricularInteraction_flat ventricularInteraction_flat(lambdas(displayUnit = "1/m3") = 435000, lambdarv(displayUnit = "1/m3") = 23000, Essept(displayUnit = "mmHg/ml") = 6499999676.0309, V0peri = 0.0002, Pi0sept = 148.00118226939, Pi0rv = 28.757638965416, Pi0lv = 16.038683206025, Pi0peri = 66.701190423724, Esrv = 77993596.637775, Eslv = 383941811.27772, lambdalv = 33000, lambdaperi = 30000);
|
---|
279 | equation
|
---|
280 | connect(aorta.q_in, Rsys.q_in);
|
---|
281 | connect(Rsys.q_out, venaCava.q_in);
|
---|
282 | connect(pulmonaryValve.q_out, pulmonaryArteries.q_in);
|
---|
283 | connect(pulmonaryArteries.q_in, Rpul.q_in);
|
---|
284 | connect(Rpul.q_out, pulmonaryVeins.q_in);
|
---|
285 | connect(aorticValve.q_out, aorta.q_in);
|
---|
286 | connect(venaCava.q_in, Ltc.q_in);
|
---|
287 | connect(pulmonaryVeins.q_in, Lmt.q_in);
|
---|
288 | connect(Lav.q_out, aorticValve.q_in);
|
---|
289 | connect(Ltc.q_out, tricuspidValve.q_in);
|
---|
290 | connect(Lpv.q_out, pulmonaryValve.q_in);
|
---|
291 | connect(mitralValve.q_in, Lmt.q_out);
|
---|
292 | connect(tricuspidValve.q_out, ventricularInteraction_flat.rvflow);
|
---|
293 | connect(Lpv.q_in, ventricularInteraction_flat.rvflow);
|
---|
294 | connect(ventricularInteraction_flat.lvflow, Lav.q_in);
|
---|
295 | connect(mitralValve.q_out, Lav.q_in);
|
---|
296 | connect(HR.y, ventricularInteraction_flat.HR);
|
---|
297 | connect(IntraThoracicPressure.y, ventricularInteraction_flat.Pth);
|
---|
298 | connect(pulmonaryArteries.externalPressure, IntraThoracicPressure.y);
|
---|
299 | connect(pulmonaryVeins.externalPressure, IntraThoracicPressure.y);
|
---|
300 | annotation(experiment(StopTime = 5));
|
---|
301 | end HemodynamicsSmith_shallow;
|
---|
302 |
|
---|
303 | model VentricularInteraction_flat
|
---|
304 | .Physiolibrary.Types.Volume Vsept(start = 0.000002);
|
---|
305 | .Physiolibrary.Types.Volume Vperi;
|
---|
306 | parameter .Physiolibrary.Types.Volume V0sept = 0.000002;
|
---|
307 | parameter .Physiolibrary.Types.Volume V0peri;
|
---|
308 | .Physiolibrary.Types.Pressure Psept;
|
---|
309 | .Physiolibrary.Types.Pressure Pperi;
|
---|
310 | parameter .Physiolibrary.Types.Pressure Pi0sept;
|
---|
311 | parameter .Physiolibrary.Types.Pressure Pi0rv;
|
---|
312 | parameter .Physiolibrary.Types.Pressure Pi0lv;
|
---|
313 | parameter .Physiolibrary.Types.Pressure Pi0peri "peak isovolumic pressure";
|
---|
314 | parameter .Physiolibrary.Types.HydraulicElastance Essept;
|
---|
315 | parameter .Physiolibrary.Types.HydraulicElastance Esrv;
|
---|
316 | parameter .Physiolibrary.Types.HydraulicElastance Eslv "elastance of systole";
|
---|
317 | parameter Real A = 1;
|
---|
318 | parameter Real B = 80;
|
---|
319 | parameter Real CC = 60 / B / 2;
|
---|
320 | .Physiolibrary.Types.Time tm;
|
---|
321 | discrete .Physiolibrary.Types.Time HP "heart period";
|
---|
322 | discrete .Physiolibrary.Types.Time t0 "time of beginning of the cardiac cycle";
|
---|
323 | discrete .Physiolibrary.Types.Time ts "duration of systole";
|
---|
324 | parameter Cardiovascular.Model.Smith2004.Parts.HydraulicLambda lambdas;
|
---|
325 | parameter Cardiovascular.Model.Smith2004.Parts.HydraulicLambda lambdarv;
|
---|
326 | parameter Cardiovascular.Model.Smith2004.Parts.HydraulicLambda lambdalv;
|
---|
327 | parameter Cardiovascular.Model.Smith2004.Parts.HydraulicLambda lambdaperi;
|
---|
328 | Physiolibrary.Hydraulic.Interfaces.HydraulicPort_a rvflow;
|
---|
329 | Physiolibrary.Hydraulic.Interfaces.HydraulicPort_a lvflow;
|
---|
330 | .Physiolibrary.Types.RealIO.FrequencyInput HR;
|
---|
331 | .Physiolibrary.Types.RealIO.PressureInput Pth;
|
---|
332 | Physiolibrary.Types.RealIO.VolumeOutput Vlv(start = 0.0001042);
|
---|
333 | Physiolibrary.Types.RealIO.VolumeOutput Vrv(start = 0.0001042);
|
---|
334 | equation
|
---|
335 | tm = time - pre(t0);
|
---|
336 | when {initial(), tm >= pre(HP)} then
|
---|
337 | HP = 1 / HR;
|
---|
338 | t0 = time;
|
---|
339 | ts = 0.16 + 0.3 * HP;
|
---|
340 | end when;
|
---|
341 | Psept = lvflow.pressure - rvflow.pressure;
|
---|
342 | Psept = (Vsept - V0sept) * A * exp(-B * (tm - CC) ^ 2) * Essept + (1 - A * exp(-B * (tm - CC) ^ 2)) * Pi0sept * (exp(lambdas * Vsept) - 1);
|
---|
343 | rvflow.pressure - Pperi = (Vrv + Vsept) * A * exp(-B * (tm - CC) ^ 2) * Esrv + (1 - A * exp(-B * (tm - CC) ^ 2)) * Pi0rv * (exp(lambdarv * (Vrv + Vsept)) - 1);
|
---|
344 | der(Vrv) = rvflow.q;
|
---|
345 | lvflow.pressure - Pperi = (Vlv - Vsept) * A * exp(-B * (tm - CC) ^ 2) * Eslv + (1 - A * exp(-B * (tm - CC) ^ 2)) * Pi0lv * (exp(lambdalv * (Vlv - Vsept)) - 1);
|
---|
346 | der(Vlv) = lvflow.q;
|
---|
347 | Vperi = Vrv + Vlv;
|
---|
348 | Pperi = Pth + Pi0peri * (exp(lambdaperi * (Vperi - V0peri)) - 1);
|
---|
349 | end VentricularInteraction_flat;
|
---|
350 |
|
---|
351 | model Smith_patSpec
|
---|
352 | extends HemodynamicsSmith_shallow(venaCava(volume_start = V_vc0), Ltc(volumeFlow_start = Q_tc0), pulmonaryArteries(volume_start = V_pa0), pulmonaryVeins(volume_start = V_pu0), Lpv(volumeFlow_start(displayUnit = "ml/min") = Q_pv0), Lmt(volumeFlow_start(displayUnit = "ml/min") = Q_mt0), Lav(volumeFlow_start(displayUnit = "ml/min") = Q_av0), aorta(volume_start = V_ao0), ventricularInteraction_flat(Vlv(start = V_lv0), Vrv(start = V_rv0)));
|
---|
353 | parameter Physiolibrary.Types.Mass BW = 72.3 "Body weight";
|
---|
354 | parameter Modelica.SIunits.Length Hgt = 178 "Body height";
|
---|
355 | parameter Boolean isMan = true;
|
---|
356 | parameter Physiolibrary.Types.Volume TotBV = if isMan then (0.3669 * (Hgt / 100) ^ 3 + 0.03219 * BW + 0.6041) * 1000 else (0.3561 * (Hgt / 100) ^ 3 + 0.03308 * BW + 0.1833) * 1000 "total blood volume ( Nadler et al. Surgery 51:224,1962)";
|
---|
357 | constant Real ml2m3 = 1 / 1000 / 1000;
|
---|
358 | constant Real min2s = 1 / 60;
|
---|
359 | parameter Physiolibrary.Types.Volume CircBV = 0.30 * TotBV * ml2m3;
|
---|
360 | parameter Physiolibrary.Types.Volume V_lv0 = 94.6812 / 1500 * CircBV;
|
---|
361 | parameter Physiolibrary.Types.Volume V_rv0 = 90.7302 / 1500 * CircBV;
|
---|
362 | parameter Physiolibrary.Types.Volume V_pa0 = 43.0123 / 1500 * CircBV;
|
---|
363 | parameter Physiolibrary.Types.Volume V_pu0 = 808.458 / 1500 * CircBV;
|
---|
364 | parameter Physiolibrary.Types.Volume V_ao0 = 133.338 / 1500 * CircBV;
|
---|
365 | parameter Physiolibrary.Types.Volume V_vc0 = 329.780 / 1500 * CircBV;
|
---|
366 | parameter Physiolibrary.Types.VolumeFlowRate Q_mt0 = 245.581 * min2s * ml2m3;
|
---|
367 | parameter Physiolibrary.Types.VolumeFlowRate Q_av0 = -1e-3 * min2s * ml2m3;
|
---|
368 | parameter Physiolibrary.Types.VolumeFlowRate Q_tc0 = 190.066 * min2s * ml2m3;
|
---|
369 | parameter Physiolibrary.Types.VolumeFlowRate Q_pv0 = -1e-3 * min2s * ml2m3;
|
---|
370 | Physiolibrary.Hydraulic.Sensors.PressureMeasure pressureMeasure;
|
---|
371 | Modelica.Blocks.Interfaces.RealOutput pressure;
|
---|
372 | equation
|
---|
373 | connect(pressureMeasure.q_in, aorta.q_in);
|
---|
374 | connect(pressureMeasure.pressure, pressure);
|
---|
375 | end Smith_patSpec;
|
---|
376 | end FMITest;
|
---|
377 |
|
---|
378 | package ModelicaServices "ModelicaServices (OpenModelica implementation) - Models and functions used in the Modelica Standard Library requiring a tool specific implementation"
|
---|
379 | extends Modelica.Icons.Package;
|
---|
380 |
|
---|
381 | package Machine
|
---|
382 | extends Modelica.Icons.Package;
|
---|
383 | final constant Real eps = 1.e-15 "Biggest number such that 1.0 + eps = 1.0";
|
---|
384 | final constant Real small = 1.e-60 "Smallest number such that small and -small are representable on the machine";
|
---|
385 | final constant Real inf = 1.e+60 "Biggest Real number such that inf and -inf are representable on the machine";
|
---|
386 | final constant Integer Integer_inf = OpenModelica.Internal.Architecture.integerMax() "Biggest Integer number such that Integer_inf and -Integer_inf are representable on the machine";
|
---|
387 | end Machine;
|
---|
388 | annotation(Protection(access = Access.hide), version = "3.2.2", versionBuild = 0, versionDate = "2016-01-15", dateModified = "2016-01-15 08:44:41Z");
|
---|
389 | end ModelicaServices;
|
---|
390 |
|
---|
391 | package Modelica "Modelica Standard Library - Version 3.2.2"
|
---|
392 | extends Modelica.Icons.Package;
|
---|
393 |
|
---|
394 | package Blocks "Library of basic input/output control blocks (continuous, discrete, logical, table blocks)"
|
---|
395 | extends Modelica.Icons.Package;
|
---|
396 |
|
---|
397 | package Interfaces "Library of connectors and partial models for input/output blocks"
|
---|
398 | extends Modelica.Icons.InterfacesPackage;
|
---|
399 | connector RealOutput = output Real "'output Real' as connector";
|
---|
400 | end Interfaces;
|
---|
401 | end Blocks;
|
---|
402 |
|
---|
403 | package Math "Library of mathematical functions (e.g., sin, cos) and of functions operating on vectors and matrices"
|
---|
404 | extends Modelica.Icons.Package;
|
---|
405 |
|
---|
406 | package Icons "Icons for Math"
|
---|
407 | extends Modelica.Icons.IconsPackage;
|
---|
408 |
|
---|
409 | partial function AxisCenter "Basic icon for mathematical function with y-axis in the center" end AxisCenter;
|
---|
410 | end Icons;
|
---|
411 |
|
---|
412 | function asin "Inverse sine (-1 <= u <= 1)"
|
---|
413 | extends Modelica.Math.Icons.AxisCenter;
|
---|
414 | input Real u;
|
---|
415 | output .Modelica.SIunits.Angle y;
|
---|
416 | external "builtin" y = asin(u);
|
---|
417 | end asin;
|
---|
418 |
|
---|
419 | function exp "Exponential, base e"
|
---|
420 | extends Modelica.Math.Icons.AxisCenter;
|
---|
421 | input Real u;
|
---|
422 | output Real y;
|
---|
423 | external "builtin" y = exp(u);
|
---|
424 | end exp;
|
---|
425 | end Math;
|
---|
426 |
|
---|
427 | package Constants "Library of mathematical constants and constants of nature (e.g., pi, eps, R, sigma)"
|
---|
428 | extends Modelica.Icons.Package;
|
---|
429 | final constant Real pi = 2 * Math.asin(1.0);
|
---|
430 | final constant Real eps = ModelicaServices.Machine.eps "Biggest number such that 1.0 + eps = 1.0";
|
---|
431 | final constant .Modelica.SIunits.Velocity c = 299792458 "Speed of light in vacuum";
|
---|
432 | final constant Real mue_0(final unit = "N/A2") = 4 * pi * 1.e-7 "Magnetic constant";
|
---|
433 | end Constants;
|
---|
434 |
|
---|
435 | package Icons "Library of icons"
|
---|
436 | extends Icons.Package;
|
---|
437 |
|
---|
438 | partial package ExamplesPackage "Icon for packages containing runnable examples"
|
---|
439 | extends Modelica.Icons.Package;
|
---|
440 | end ExamplesPackage;
|
---|
441 |
|
---|
442 | partial package Package "Icon for standard packages" end Package;
|
---|
443 |
|
---|
444 | partial package InterfacesPackage "Icon for packages containing interfaces"
|
---|
445 | extends Modelica.Icons.Package;
|
---|
446 | end InterfacesPackage;
|
---|
447 |
|
---|
448 | partial package SourcesPackage "Icon for packages containing sources"
|
---|
449 | extends Modelica.Icons.Package;
|
---|
450 | end SourcesPackage;
|
---|
451 |
|
---|
452 | partial package SensorsPackage "Icon for packages containing sensors"
|
---|
453 | extends Modelica.Icons.Package;
|
---|
454 | end SensorsPackage;
|
---|
455 |
|
---|
456 | partial package UtilitiesPackage "Icon for utility packages"
|
---|
457 | extends Modelica.Icons.Package;
|
---|
458 | end UtilitiesPackage;
|
---|
459 |
|
---|
460 | partial package IconsPackage "Icon for packages containing icons"
|
---|
461 | extends Modelica.Icons.Package;
|
---|
462 | end IconsPackage;
|
---|
463 | end Icons;
|
---|
464 |
|
---|
465 | package SIunits "Library of type and unit definitions based on SI units according to ISO 31-1992"
|
---|
466 | extends Modelica.Icons.Package;
|
---|
467 |
|
---|
468 | package Conversions "Conversion functions to/from non SI units and type definitions of non SI units"
|
---|
469 | extends Modelica.Icons.Package;
|
---|
470 |
|
---|
471 | package NonSIunits "Type definitions of non SI units"
|
---|
472 | extends Modelica.Icons.Package;
|
---|
473 | type Temperature_degC = Real(final quantity = "ThermodynamicTemperature", final unit = "degC") "Absolute temperature in degree Celsius (for relative temperature use SIunits.TemperatureDifference)" annotation(absoluteValue = true);
|
---|
474 | end NonSIunits;
|
---|
475 | end Conversions;
|
---|
476 |
|
---|
477 | type Angle = Real(final quantity = "Angle", final unit = "rad", displayUnit = "deg");
|
---|
478 | type Length = Real(final quantity = "Length", final unit = "m");
|
---|
479 | type Volume = Real(final quantity = "Volume", final unit = "m3");
|
---|
480 | type Time = Real(final quantity = "Time", final unit = "s");
|
---|
481 | type Velocity = Real(final quantity = "Velocity", final unit = "m/s");
|
---|
482 | type Acceleration = Real(final quantity = "Acceleration", final unit = "m/s2");
|
---|
483 | type Frequency = Real(final quantity = "Frequency", final unit = "Hz");
|
---|
484 | type Mass = Real(quantity = "Mass", final unit = "kg", min = 0);
|
---|
485 | type Pressure = Real(final quantity = "Pressure", final unit = "Pa", displayUnit = "bar");
|
---|
486 | type VolumeFlowRate = Real(final quantity = "VolumeFlowRate", final unit = "m3/s");
|
---|
487 | type FaradayConstant = Real(final quantity = "FaradayConstant", final unit = "C/mol");
|
---|
488 | end SIunits;
|
---|
489 | annotation(version = "3.2.2", versionBuild = 3, versionDate = "2016-04-03", dateModified = "2016-04-03 08:44:41Z");
|
---|
490 | end Modelica;
|
---|
491 |
|
---|
492 | model Smith_patSpec_total
|
---|
493 | extends FMITest.Smith_patSpec;
|
---|
494 | end Smith_patSpec_total;
|
---|