Cardiovascular.h 9.16 KB
Newer Older
Aaron Bray's avatar
Aaron Bray committed
1
2
/* Distributed under the Apache License, Version 2.0.
   See accompanying NOTICE file for details.*/
Aaron Bray's avatar
Aaron Bray committed
3
4

#pragma once
5
#include "PulsePhysiologySystems.h"
Aaron Bray's avatar
Aaron Bray committed
6
#include "system/physiology/SECardiovascularSystem.h"
7
#include "substance/SESubstanceTransport.h"
8
9
class SEPatient;
class SELiquidCompartment;
10
class SEGasCompartment;
11
class SELiquidSubstanceQuantity;
Aaron Bray's avatar
Aaron Bray committed
12
class SELiquidCompartmentGraph;
13
class SELiquidCompartmentLink;
14
15
16
class SEFluidCircuit;
class SEFluidCircuitNode;
class SEFluidCircuitPath;
Aaron Bray's avatar
Aaron Bray committed
17
18
19
20
21
22
23
24
25
26
27
28
29
30
class SEFluidCircuitCalculator;

/**
* @brief 
* The %Cardiovascular system utilizes circuit methodology to characterize the intravascular fluid dynamics throughout the body.
* @copydoc Physiology_CardiovascularSystemData
* @details
* The %Cardiovascular system utilizes circuit methodology to evaluate the hemodynamics throughout the human body.
* The cardiovascular system consists of a representation of the human vasculature. The heart model is the driving force that creates blood flow
* through the cardiovascular system. The resulting blood flow is utilized by other physiologic systems as a means of transporting the oxygen, carbon dioxide
* and other substances throughout the human body. The system may be modified to mimic real world insults and interventions. Due to its interconnectedness
* with other systems, if alterations are made to the cardiovascular system then the feedback will be felt in the other physiologic systems.
*
*/
31
class PULSE_DECL Cardiovascular : public PulseCardiovascularSystem
Aaron Bray's avatar
Aaron Bray committed
32
{
33
  friend class PulseData;
34
  friend class PBPulsePhysiology;//friend the serialization class
35
  friend class PulseEngineTest;
Aaron Bray's avatar
Aaron Bray committed
36
protected:
37
38
  Cardiovascular(PulseData& data);
  PulseData& m_data;
Aaron Bray's avatar
Aaron Bray committed
39
40
41
42
43
44

public:
  virtual ~Cardiovascular();

  void Clear();

45
46
  // Set members to a stable homeostatic state
  void Initialize();
Aaron Bray's avatar
Aaron Bray committed
47
48
49
50
51
  // Set pointers and other member varialbes common to both homeostatic initialization and loading a state
  void SetUp();

  void AtSteadyState();
  void PreProcess();
52
  void Process(bool solve_and_transport=true);
Aaron Bray's avatar
Aaron Bray committed
53
  void PostProcess(bool solve_and_transport=true);
Aaron Bray's avatar
Aaron Bray committed
54

55
protected:
56
57
  void ComputeExposedModelParameters() override;

Aaron Bray's avatar
Aaron Bray committed
58
59
60
61
62
63
64
65
66
67
68
  //Condition Methods
  void ChronicRenalStenosis();
  void ChronicAnemia();
  void ChronicHeartFailure();
  void ChronicPericardialEffusion();

  // PreProcess:
  void HeartDriver();
  /**/void AdjustVascularTone();
  /**/void BeginCardiacCycle();
  /**/void CalculateHeartElastance();
69
  /**/void UpdateHeartRhythm();
Aaron Bray's avatar
Aaron Bray committed
70
71
72
73
74
75
76
77
78
79
  // IF STABILIZING
  void TuneCircuit();
  /**/void TunePaths(double systemicResistanceScale, double systemicComplianceScale, double aortaResistanceScale, double aortaComplianceScale, double rightHeartResistanceScale, double venaCavaComplianceScale);
  // ELSE
  void MetabolicToneResponse(); 
  void ProcessActions();
  //Action methods
  /**/void CPR();
  /****/void CalculateAndSetCPRcompressionForce();
  /**/void Hemorrhage();
80
  /**/void InternalHemorrhagePressureApplication();
Aaron Bray's avatar
Aaron Bray committed
81
82
83
84
  /**/void PericardialEffusion();
  /**/void PericardialEffusionPressureApplication();
  /**/void CardiacArrest();
  /**/void TraumaticBrainInjury();
85
86
  //Respiratory effects
  void CalculatePleuralCavityVenousEffects();
Aaron Bray's avatar
Aaron Bray committed
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110

  // Process:
  void CalculateVitalSigns();
  /**/void CalculateHeartRate();
  /**/void RecordAndResetCardiacCycle();

  // Serializable member variables (Set in Initialize and in schema)
  //Driver
  bool   m_StartSystole;
  bool   m_HeartFlowDetected;
  bool   m_EnterCardiacArrest;// Can't go into cardiac arrest during the middle of a cycle
  double m_CardiacCyclePeriod_s;
  double m_CurrentCardiacCycleDuration_s; // How long have we been in this heart beat
  double m_LeftHeartElastanceModifier;// from Heart Failure and such
  double m_LeftHeartElastance_mmHg_Per_mL;
  double m_LeftHeartElastanceMax_mmHg_Per_mL;
  double m_LeftHeartElastanceMin_mmHg_Per_mL;
  double m_RightHeartElastance_mmHg_Per_mL;
  double m_RightHeartElastanceMax_mmHg_Per_mL;
  double m_RightHeartElastanceMin_mmHg_Per_mL;
  //CPR
  double m_CompressionTime_s;
  double m_CompressionRatio;
  double m_CompressionPeriod_s;
111
  //Hemorrhage
112
  std::vector<SEFluidCircuitPath*> m_HemorrhagePaths;
113
  std::vector<SEFluidCircuitPath*> m_InternalHemorrhagePaths;
114
  std::vector<SELiquidCompartmentLink*> m_HemorrhageLinks;
115
  std::vector<SELiquidCompartmentLink*> m_InternalHemorrhageLinks;
Aaron Bray's avatar
Aaron Bray committed
116
117
118
119
120
121
  // Vitals and Averages
  double m_CurrentCardiacCycleTime_s;
  double m_CardiacCycleDiastolicVolume_mL; // Maximum left heart volume for the current cardiac cycle
  double m_CardiacCycleAortaPressureLow_mmHg; // The current low for this cycle - Reset at the start of systole
  double m_CardiacCycleAortaPressureHigh_mmHg; // The current high for this cycle - Reset at the start of systole
  double m_CardiacCyclePulmonaryArteryPressureLow_mmHg;
122
  double m_CardiacCyclePulmonaryArteryPressureHigh_mmHg;
Aaron Bray's avatar
Aaron Bray committed
123
124
  double m_LastCardiacCycleMeanArterialCO2PartialPressure_mmHg;
  double m_CardiacCycleStrokeVolume_mL; // Total volume of the left heart flow for the current cardiac cycle
125
126
127
128
129
130
131
132
  SERunningAverage* m_CardiacCycleArterialPressure_mmHg;
  SERunningAverage* m_CardiacCycleArterialCO2PartialPressure_mmHg;
  SERunningAverage* m_CardiacCyclePulmonaryCapillariesWedgePressure_mmHg;
  SERunningAverage* m_CardiacCyclePulmonaryCapillariesFlow_mL_Per_s;
  SERunningAverage* m_CardiacCyclePulmonaryShuntFlow_mL_Per_s;
  SERunningAverage* m_CardiacCyclePulmonaryArteryPressure_mmHg;
  SERunningAverage* m_CardiacCycleCentralVenousPressure_mmHg;
  SERunningAverage* m_CardiacCycleSkinFlow_mL_Per_s;
Aaron Bray's avatar
Aaron Bray committed
133
134
135
136
137
138
139
140
  
  // Stateless member variable (Set in SetUp())
  double                           m_dT_s;
  bool                             m_TuneCircuit = true;
  std::string                      m_TuningFile;

  double                           m_minIndividialSystemicResistance__mmHg_s_Per_mL;
  
141
142
  SEFluidCircuitCalculator*        m_circuitCalculator;
  SELiquidTransporter*             m_transporter;
Aaron Bray's avatar
Aaron Bray committed
143

144
  SEFluidCircuit*                  m_CirculatoryCircuit;
Aaron Bray's avatar
Aaron Bray committed
145
146
147
148
  SELiquidCompartmentGraph*        m_CirculatoryGraph;

  SEFluidCircuitNode*              m_MainPulmonaryArteries;
  SEFluidCircuitNode*              m_LeftHeart2;
149
  SEFluidCircuitNode*              m_Ground;
Aaron Bray's avatar
Aaron Bray committed
150
151
152
153
154
155
156
157
158
159
160

  SEFluidCircuitPath*              m_AortaCompliance;
  SEFluidCircuitPath*              m_AortaResistance;
  SEFluidCircuitPath*              m_VenaCavaCompliance;
  SEFluidCircuitPath*              m_RightHeartResistance;

  SEFluidCircuitPath*              m_LeftPulmonaryArteriesToVeins;
  SEFluidCircuitPath*              m_LeftPulmonaryArteriesToCapillaries;
  SEFluidCircuitPath*              m_RightPulmonaryArteriesToVeins;
  SEFluidCircuitPath*              m_RightPulmonaryArteriesToCapillaries;

161
  SEFluidCircuitPath*              m_InternalHemorrhageToAorta;
Aaron Bray's avatar
Aaron Bray committed
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
  SEFluidCircuitPath*              m_pAortaToBone;
  SEFluidCircuitPath*              m_pAortaToBrain;
  SEFluidCircuitPath*              m_pBrainToVenaCava;
  SEFluidCircuitPath*              m_pAortaToLiver;
  SEFluidCircuitPath*              m_pAortaToLeftKidney;
  SEFluidCircuitPath*              m_pAortaToLargeIntestine;
  SEFluidCircuitPath*              m_pAortaToMuscle;
  SEFluidCircuitPath*              m_pMuscleToVenaCava;
  SEFluidCircuitPath*              m_pAortaToMyocardium;
  SEFluidCircuitPath*              m_pMyocardiumToVenaCava;
  SEFluidCircuitPath*              m_pAortaToRightKidney;
  SEFluidCircuitPath*              m_pAortaToSkin;
  SEFluidCircuitPath*              m_pAortaToSmallIntestine;
  SEFluidCircuitPath*              m_pAortaToSplanchnic;
  SEFluidCircuitPath*              m_pAortaToSpleen;

  SEFluidCircuitPath*              m_pGndToPericardium;
  SEFluidCircuitPath*              m_pPericardiumToGnd;
  SEFluidCircuitPath*              m_pRightHeartToGnd;
  SEFluidCircuitPath*              m_pRightHeart;
  SEFluidCircuitPath*              m_pLeftHeartToGnd;
  SEFluidCircuitPath*              m_pLeftHeart;
  SEFluidCircuitPath*              m_LeftHeartToAorta;

  SEFluidCircuitPath*              m_pBrainResistanceUpstream;
  SEFluidCircuitPath*              m_pBrainResistanceDownstream;

189
190
  SEFluidCircuitPath*              m_leftRenalArteryPath;
  SEFluidCircuitPath*              m_rightRenalArteryPath;
191
192
193

  SEFluidCircuitPath*              m_pGndToAbdominalCavity;
  SEFluidCircuitPath*              m_pAbdominalCavityToGnd;
Aaron Bray's avatar
Aaron Bray committed
194
  
195
  SELiquidCompartment*             m_AbdominalCavity;
Aaron Bray's avatar
Aaron Bray committed
196
197
198
  SELiquidCompartment*             m_Aorta;
  SELiquidSubstanceQuantity*       m_AortaCO2;
  SELiquidCompartment*             m_Brain;
199
  SELiquidCompartment*             m_Groundcmpt;
Aaron Bray's avatar
Aaron Bray committed
200
201
202
203
204
205
206
207
208
209
210
  SELiquidCompartment*             m_LeftHeart;
  SELiquidCompartment*             m_LeftPulmonaryCapillaries;
  SELiquidCompartment*             m_LeftPulmonaryArteries;
  SELiquidCompartment*             m_LeftPulmonaryVeins;
  SELiquidCompartment*             m_Pericardium;
  SELiquidCompartment*             m_RightHeart;
  SELiquidCompartment*             m_RightPulmonaryCapillaries;
  SELiquidCompartment*             m_RightPulmonaryArteries;
  SELiquidCompartment*             m_RightPulmonaryVeins;
  SELiquidCompartment*             m_VenaCava;

211
212
213
  SEGasCompartment*                m_leftPleuralCavity;
  SEGasCompartment*                m_rightPleuralCavity;

Aaron Bray's avatar
Aaron Bray committed
214
215
216
217
218
219
220
  std::vector<SEFluidCircuitPath*> m_systemicResistancePaths;
  std::vector<SEFluidCircuitPath*> m_systemicCompliancePaths;
};