CardiovascularModel.h
1/* Distributed under the Apache License, Version 2.0.
2 See accompanying NOTICE file for details.*/
3
4#pragma once
5
6#include "engine/common/system/Model.h"
7#include "engine/common/system/Systems.h"
8#include "cdm/circuit/fluid/SEFluidCircuitCalculator.h"
9#include "cdm/compartment/fluid/SELiquidCompartmentGraph.h"
10
11class SEPatient;
12class SEHemorrhage;
18class SEFluidCircuit;
22
23namespace pulse
24{
25 class PBPhysiology;
26 class EngineTest;
39 class PULSE_DECL CardiovascularModel : public CardiovascularSystem, public Model
40 {
41 friend PBPhysiology;//friend the serialization class
42 friend EngineTest;
43 public:
44 CardiovascularModel(Data& data);
45 virtual ~CardiovascularModel();
46
47 void Clear() override;
48
49 // Set members to a stable homeostatic state
50 void Initialize() override;
51 // Set pointers and other member varialbes common to both homeostatic initialization and loading a state
52 void SetUp() override;
53
54 void SetHeartRhythm(eHeartRhythm Rhythm) override;
55 void SetHeartRhythm(eHeartRhythm Rhythm, bool force);
56
57 void AtSteadyState() override;
58 void PreProcess() override;
59 void Process(bool solve_and_transport=true) override;
60 void PostProcess(bool solve_and_transport=true) override;
61
62 protected:
63 void ComputeExposedModelParameters() override;
64
65 // Initialize
66 void TuneCircuit();
67 void TunePaths(double systemicResistanceScale, double systemicComplianceScale, double aortaResistanceScale, double aortaComplianceScale, double rightHeartResistanceScale, double venaCavaComplianceScale);
68 void TuneTissue(double time_s, DataTrack& track, std::ofstream& circuitFile);
69
70 //Condition Methods
71 void ChronicRenalStenosis();
72 void ChronicAnemia();
73 void ChronicHeartFailure();
74 void ChronicPericardialEffusion();
75
76 // PreProcess:
77 void HeartDriver();
78 void AdjustVascularTone();
79 /****/void MetabolicToneResponse();
80 void BeginDriverCycle();
81 /****/void RecordAndResetCardiacCycle();//Could be called out of order by arrythma
82 void CalculateHeartElastance();
83 void ProcessActions();
84 //Action methods
85 void CPR();
86 /****/double CalculateDepthForce(double compressionDepth_cm);
87 /****/double ShapeCPRForce(double compressionForce_N);
88 /****/void ApplyCPRForce(double compressionForce_N);
89 void Arrhythmia();
90 void Hemorrhage();
91 void PericardialEffusion();
92 void PericardialEffusionPressureApplication();
93 void TraumaticBrainInjury();
94 void UpdatePulmonaryCapillaries();
95 void CalculateHemothorax();
96 //Respiratory effects
97 void CalculatePleuralCavityVenousEffects();
98
99 // Process:
100 void CalculateVitalSigns();
101
102 // Serializable member variables (Set in Initialize and in schema)
103 //Driver
104 bool m_StartSystole;
105 bool m_HeartFlowDetected;
106 bool m_FullyCompressedHeart;
107 double m_StabilizedHeartRateBaseline_Per_min; // store for moving between arrhytmias
108 double m_StabilizedMeanArterialPressureBaseline_mmHg; // store for moving between arrhytmias
109 double m_CurrentDriverCycleTime_s;
110 double m_DriverCyclePeriod_s;
111 double m_LeftHeartElastanceModifier;// from Heart Failure and such
112 double m_LeftHeartElastance_mmHg_Per_mL;
113 double m_LeftHeartElastanceMax_mmHg_Per_mL;
114 double m_LeftHeartElastanceMin_mmHg_Per_mL;
115 double m_RightHeartElastance_mmHg_Per_mL;
116 double m_RightHeartElastanceMax_mmHg_Per_mL;
117 double m_RightHeartElastanceMin_mmHg_Per_mL;
118 // Arrhythmia
119 eSwitch m_EnableFeedbackAfterArrhythmiaTrasition;
120 bool m_StartCardiacArrest; // Can't go into cardiac arrest during the middle of a cycle
121 bool m_TransitionArrhythmia;
122 double m_CardiacArrestVitalsUpdateTimer_s;
123 // Transition Modifiers
124 SETemporalInterpolator* m_HeartRateBaseline_Per_min;
125 SETemporalInterpolator* m_HeartComplianceModifier;
126 SETemporalInterpolator* m_AortaComplianceModifier;
127 SETemporalInterpolator* m_VenaCavaComplianceModifier;
128 SETemporalInterpolator* m_RespiratoryComplianceModifier;
129 SETemporalInterpolator* m_SystemicVascularResistanceModifier;
130 SETemporalInterpolator* m_SystemicVascularComplianceModifier;
131 //CPR
132 double m_CompressionFrequencyCurrentTime_s;
133 double m_CompressionFrequencyDuration_s;
134 double m_CompressionPeriod_s;
135 double m_CompressionPeriodCurrentTime_s;
136 // Vitals and Averages
137 double m_CardiacCycleDiastolicVolume_mL; // Maximum left heart volume for the current cardiac cycle
138 double m_CardiacCycleAortaPressureLow_mmHg; // The current low for this cycle - Reset at the start of systole
139 double m_CardiacCycleAortaPressureHigh_mmHg; // The current high for this cycle - Reset at the start of systole
140 double m_CardiacCycleLeftHeartPressureLow_mmHg; // The current low for this cycle - Reset at the start of systole
141 double m_CardiacCycleLeftHeartPressureHigh_mmHg; // The current high for this cycle - Reset at the start of systole
142 double m_CardiacCyclePulmonaryArteryPressureLow_mmHg;
143 double m_CardiacCyclePulmonaryArteryPressureHigh_mmHg;
144 double m_CardiacCycleRightHeartPressureLow_mmHg; // The current low for this cycle - Reset at the start of systole
145 double m_CardiacCycleRightHeartPressureHigh_mmHg; // The current high for this cycle - Reset at the start of systole
146 double m_LastCardiacCycleMeanArterialCO2PartialPressure_mmHg;
147 double m_CardiacCycleStrokeVolume_mL; // Total volume of the left heart flow for the current cardiac cycle
148 double m_PeripheralVolumeHigh_mL; // Max cycle volume in arms and legs
149 double m_PeripheralVolumeLow_mL; // Min cycle volume in arms and legs
150 //Needed for expanded pulmonary methodology
151 std::vector<double> m_LeftCardiacCyclePerfusionVolumes_mL;
152 std::vector<double> m_RightCardiacCyclePerfusionVolumes_mL;
153
154 SERunningAverage* m_CardiacCycleArterialPressure_mmHg;
155 SERunningAverage* m_CardiacCycleArterialCO2PartialPressure_mmHg;
156 SERunningAverage* m_CardiacCyclePulmonaryCapillariesWedgePressure_mmHg;
157 SERunningAverage* m_CardiacCyclePulmonaryCapillariesFlow_mL_Per_s;
158 SERunningAverage* m_CardiacCyclePulmonaryShuntFlow_mL_Per_s;
159 SERunningAverage* m_CardiacCyclePulmonaryArteryPressure_mmHg;
160 SERunningAverage* m_CardiacCycleCentralVenousPressure_mmHg;
161 SERunningAverage* m_CardiacCycleSkinFlow_mL_Per_s;
162
163
164 // Stateless member variable (Set in SetUp())
165 SECardiovascularMechanicsModifiers* m_MechanicsModifiers;
166 // Hemorrhage
167 struct HemorrhageTrack
168 {
169 SELiquidCompartment* Compartment=nullptr;
170 std::map<SELiquidCompartment* , std::vector<SELiquidCompartmentLink*>> CmptHemorrhageLinks;
171 };
172 std::map<SEHemorrhage*, HemorrhageTrack*> m_HemorrhageTrack;
173 SEFluidCircuitPath* m_InternalHemorrhageToAorta;
174
175 double m_MAPCollapse_mmHg;
176 double m_MinIndividialSystemicResistance_mmHg_s_Per_mL;
177
178 SEFluidCircuitCalculator* m_CircuitCalculator;
179 SELiquidTransporter* m_Transporter;
180
181 SEFluidCircuit* m_CirculatoryCircuit;
182 SELiquidCompartmentGraph* m_CirculatoryGraph;
183
184 SEFluidCircuitNode* m_GroundNode;
185 SEFluidCircuitNode* m_AbdominalCavityNode;
186
187 SEFluidCircuitPath* m_AortaToBrain;
188 SEFluidCircuitPath* m_AortaToMyocardium;
189 SEFluidCircuitPath* m_AortaCompliancePath;
190 SEFluidCircuitPath* m_AortaResistancePath;
191 SEFluidCircuitNode* m_LeftPulmonaryVeinsNode;
192 SEFluidCircuitNode* m_RightPulmonaryVeinsNode;
193
194 SEFluidCircuitPath* m_VenaCavaCompliancePath;
195 SEFluidCircuitPath* m_VenaCavaResistancePath;
196
197 SEFluidCircuitPath* m_BrainToVenaCava;
198 SEFluidCircuitPath* m_MyocardiumToVenaCava;
199
200 SEFluidCircuitPath* m_LeftPulmonaryVeinsLeak;
201 SEFluidCircuitPath* m_RightPulmonaryVeinsLeak;
202
203 SEFluidCircuitPath* m_GndToPericardium;
204 SEFluidCircuitPath* m_PericardiumToGnd;
205
206 SEFluidCircuitPath* m_RightHeartToGnd;
207 SEFluidCircuitPath* m_RightHeartCompliancePath;
208 SEFluidCircuitPath* m_RightHeartResistancePath;
209
210 SEFluidCircuitPath* m_LeftHeartToGnd;
211 SEFluidCircuitPath* m_LeftHeartToAorta;
212 SEFluidCircuitPath* m_LeftHeartCompliancePath;
213
214 SEFluidCircuitPath* m_RightPulmonaryVenousReturnResistancePath;
215 SEFluidCircuitPath* m_LeftPulmonaryVenousReturnResistancePath;
216
217 SEFluidCircuitPath* m_BrainResistanceUpstreamPath;
218 SEFluidCircuitPath* m_BrainResistanceDownstreamPath;
219
220 SEFluidCircuitPath* m_GndToAbdominalCavity;
221 SEFluidCircuitPath* m_AbdominalCavityToGnd;
222
223 SEFluidCircuitPath* m_LeftRenalArteryPath;
224 SEFluidCircuitPath* m_RightRenalArteryPath;
225
226 SELiquidCompartment* m_Abdomen;
227 SELiquidCompartment* m_AbdominalCavity;
228 SELiquidCompartment* m_Aorta;
229 SELiquidSubstanceQuantity* m_AortaCO2;
230 SELiquidCompartment* m_Brain;
231 SELiquidCompartment* m_Ground;
232 SELiquidCompartment* m_LeftArm;
233 SELiquidCompartment* m_LeftHeart;
234 SELiquidCompartment* m_LeftLeg;
235 SELiquidCompartment* m_LeftPulmonaryCapillaries;
236 SELiquidCompartment* m_LeftPulmonaryArteries;
237 SELiquidCompartment* m_LeftPulmonaryVeins;
238 SELiquidCompartment* m_Pericardium;
239 SELiquidCompartment* m_RightArm;
240 SELiquidCompartment* m_RightHeart;
241 SELiquidCompartment* m_RightLeg;
242 SELiquidCompartment* m_RightPulmonaryCapillaries;
243 SELiquidCompartment* m_RightPulmonaryArteries;
244 SELiquidCompartment* m_RightPulmonaryVeins;
245 SELiquidCompartment* m_VenaCava;
246
247 SEGasCompartment* m_LeftPleuralCavity;
248 SEGasCompartment* m_RightPleuralCavity;
249 SEGasCompartment* m_PleuralCavity;
250 SEGasCompartment* m_Ambient;
251
252 std::vector<SEFluidCircuitPath*> m_HeartCompliancePaths;
253 std::vector<SEFluidCircuitPath*> m_AortaCompliancePaths;
254 std::vector<SEFluidCircuitPath*> m_AortaResistancePaths;
255 std::vector<SEFluidCircuitPath*> m_VenaCavaCompliancePaths;
256 std::vector<SEFluidCircuitPath*> m_VenaCavaResistancePaths;
257 std::vector<SEFluidCircuitPath*> m_RespiratoryCompliancePaths;
258 std::vector<SEFluidCircuitPath*> m_PulmonaryResistancePaths;
259 std::vector<SEFluidCircuitPath*> m_SystemicCompliancePaths;
260 std::vector<SEFluidCircuitPath*> m_SystemicResistancePaths;
261 std::vector<SEFluidCircuitPath*> m_MuscleResistancePaths;
262 std::vector<SEFluidCircuitPath*> m_SkinPaths;
263
264 //Needed for expanded pulmonary methodology
265 std::vector<SEFluidCircuitPath*> m_LeftPulmonaryArteriesToVeins;
266 std::vector<SEFluidCircuitPath*> m_LeftPulmonaryArteriesToCapillaries;
267 std::vector<SEFluidCircuitPath*> m_RightPulmonaryArteriesToVeins;
268 std::vector<SEFluidCircuitPath*> m_RightPulmonaryArteriesToCapillaries;
269 };
270END_NAMESPACE
Definition: DataTrack.h:17
Definition: PBPhysiology.h:24
Definition: SECardiovascularMechanicsModifiers.h:9
Definition: SECircuitCalculator.h:24
Definition: SEFluidCircuit.h:12
Definition: SEFluidCircuitNode.h:10
Definition: SEFluidCircuitPath.h:9
Definition: SEGasCompartment.h:14
Definition: SEHemorrhage.h:35
Definition: SELiquidCompartmentGraph.h:16
Definition: SELiquidCompartment.h:11
Definition: SELiquidSubstanceQuantity.h:12
Definition: SEPatient.h:13
Definition: SERunningAverage.h:8
Definition: SESubstanceTransport.h:86
Definition: SETemporalInterpolator.h:8
Definition: Logger.h:14

Distributed under the Apache License, Version 2.0.

See accompanying NOTICE file for details.