Substances.h
1 /* Distributed under the Apache License, Version 2.0.
2  See accompanying NOTICE file for details.*/
3 
4 #pragma once
5 #include "substance/SESubstanceManager.h"
8 
10 {
11  friend class PulseSubstances;
12  public:
15 
16  double GetMouth() const { return m_mouth; }
17  double GetCarina() const { return m_carina; }
18  double GetDeadSpace() const { return m_deadSpace; }
19  double GetAlveoli() const { return m_alveoli; }
20 
21 protected:
22  double m_mouth=0;
23  double m_carina=0;
24  double m_deadSpace=0;
25  double m_alveoli=0;
26 };
27 
31 class PULSE_DECL PulseSubstances : public SESubstanceManager
32 {
33  friend class PulseEngineTest;
34 public:
36  virtual ~PulseSubstances() = default;
37 
38  virtual void Clear();
39  virtual bool LoadSubstanceDirectory(const std::string& data_dir=".");
40 
41  virtual void InitializeSubstances();
42 
43  virtual void AddActiveSubstance(SESubstance& substance);
44  virtual bool IsActive(const SESubstance& sub) const;
45 
46  inline SESubstance& GetO2() { return *m_O2; }
47  inline SESubstance& GetCO() { return *m_CO; }
48  inline SESubstance& GetCO2() { return *m_CO2; }
49  inline SESubstance& GetN2() { return *m_N2; }
50  inline SESubstance& GetHb() { return *m_Hb; }
51  inline SESubstance& GetHbO2() { return *m_HbO2; }
52  inline SESubstance& GetHbCO2() { return *m_HbCO2; }
53  inline SESubstance& GetHbCO() { return *m_HbCO; }
54  inline SESubstance& GetHbO2CO2() { return *m_HbO2CO2; }
55  inline SESubstance& GetHCO3() { return *m_HCO3; }
56  inline SESubstance& GetEpi() { return *m_epi; }
57 
58  inline SESubstance& GetAcetoacetate(){ return *m_acetoacetate; }
59  inline SESubstance& GetAlbumin() { return *m_albumin; }
60  inline SESubstance& GetBicarbonate() { return *m_HCO3; }
61  inline SESubstance& GetCalcium() { return *m_calcium; }
62  inline SESubstance& GetChloride() { return *m_chloride; }
63  inline SESubstance& GetCreatinine() { return *m_creatinine; }
64  inline SESubstance& GetGlobulin() { return *m_globulin; }
65  inline SESubstance& GetGlucose() { return *m_glucose; }
66  inline SESubstance& GetInsulin() { return *m_insulin; }
67  inline SESubstance& GetLactate() { return *m_lactate; }
68  inline SESubstance& GetPotassium() { return *m_potassium; }
69  inline SESubstance& GetTristearin() { return *m_tristearin; }
70  inline SESubstance& GetSodium() { return *m_sodium; }
71  inline SESubstance& GetUrea() { return *m_urea; }
72 
73  void CalculateGenericClearance(double volumeCleared_mL, SELiquidCompartment& cmpt, SESubstance& sub, SEScalarMass* cleared = nullptr);
74  void CalculateGenericClearance(double volumeCleared_mL, SETissueCompartment& cmpt, SESubstance& sub, SEScalarMass* cleared = nullptr);
75  void CalculateGenericExcretion(double VascularFlow_mL_Per_s, SETissueCompartment& cmpt, SESubstance& sub, double FractionExcreted, double timestep_s, SEScalarMass* excreted = nullptr);
76 
77  const SizeIndependentDepositionEfficencyCoefficient& GetSizeIndependentDepositionEfficencyCoefficient(SESubstance& substance);
78 
79  double GetSubstanceMass(SESubstance&, const std::vector<SELiquidCompartment*>&, const MassUnit& unit);
80  double GetSubstanceMass(SESubstance&, const std::vector<SETissueCompartment*>&, const MassUnit& unit);
81 
82  void WriteBloodGases();
83  void WritePulmonaryGases();
84  void ProbeBloodGases(SELiquidCompartment& cmpt, const std::string& prefix="");
85 protected:
86 
87  virtual void InitializeGasCompartments();
88  virtual void InitializeLiquidCompartmentGases();
89  virtual void InitializeLiquidCompartmentNonGases();
90 
91  virtual void InitializeBloodGases(SETissueCompartment& tissue, SELiquidCompartment& vascular);
92  virtual void InitializeBloodGases(SELiquidCompartment& cmpt, double Hb_total_mM, double O2_sat, double O2_mmol_Per_L, double CO2_sat, double CO2_mmol_Per_L, double HCO3_mmol_Per_L, double pH, bool distribute = true);
93 
94  void SetSubstanceMolarity(SESubstance&, const std::vector<SELiquidCompartment*>&, const SEScalarAmountPerVolume& molarity);
95  void SetSubstanceMolarity(SESubstance&, const std::vector<SETissueCompartment*>&, const SEScalarAmountPerVolume& molarity);
96  void SetSubstanceMolarity(SESubstance&, const std::vector<SETissueCompartment*>&, const SEScalarAmountPerVolume& extracellular, const SEScalarAmountPerVolume& intracellular);
97 
98  void SetSubstanceConcentration(SESubstance&, const std::vector<SELiquidCompartment*>&, const SEScalarMassPerVolume& concentration);
99  void SetSubstanceConcentration(SESubstance&, const std::vector<SETissueCompartment*>&, const SEScalarMassPerVolume& concentration);
100  void SetSubstanceConcentration(SESubstance&, const std::vector<SETissueCompartment*>&, const SEScalarMassPerVolume& extracellular, const SEScalarMassPerVolume& intracellular);
101 
102  // Common Substances
103  //Substances
115 
129 
131 
132  std::map<SESubstance*, SizeIndependentDepositionEfficencyCoefficient*> m_SIDECoefficients;
133 
135 };
136 
SESubstance * m_creatinine
Definition: Substances.h:120
Definition: SESubstanceManager.h:8
SESubstance & GetBicarbonate()
Definition: Substances.h:60
SESubstance * m_HbCO2
Definition: Substances.h:110
SESubstance * m_HbCO
Definition: Substances.h:111
SESubstance & GetTristearin()
Definition: Substances.h:69
Definition: SEScalarMass.h:23
SESubstance & GetAlbumin()
Definition: Substances.h:59
SESubstance * m_sodium
Definition: Substances.h:127
double GetCarina() const
Definition: Substances.h:17
SESubstance & GetHbCO2()
Definition: Substances.h:52
SESubstance * m_chloride
Definition: Substances.h:119
SESubstance & GetGlucose()
Definition: Substances.h:65
SESubstance * m_glucose
Definition: Substances.h:122
SESubstance & GetCreatinine()
Definition: Substances.h:63
Definition: SEScalarMassPerVolume.h:32
Manages and controls execution of all data/systems in Pulse.
Definition: Controller.h:50
SESubstance * m_acetoacetate
Definition: Substances.h:116
SESubstance * m_albumin
Definition: Substances.h:117
SESubstance * m_lactate
Definition: Substances.h:124
SESubstance & GetO2()
Definition: Substances.h:46
std::map< SESubstance *, SizeIndependentDepositionEfficencyCoefficient * > m_SIDECoefficients
Definition: Substances.h:132
SESubstance & GetAcetoacetate()
Definition: Substances.h:58
SESubstance & GetCalcium()
Definition: Substances.h:61
SESubstance & GetSodium()
Definition: Substances.h:70
double GetAlveoli() const
Definition: Substances.h:19
double GetDeadSpace() const
Definition: Substances.h:18
SESubstance * m_insulin
Definition: Substances.h:123
SESubstance & GetGlobulin()
Definition: Substances.h:64
SESubstance * m_HCO3
Definition: Substances.h:113
double GetMouth() const
Definition: Substances.h:16
SESubstance * m_tristearin
Definition: Substances.h:125
SESubstance * m_epi
Definition: Substances.h:114
SESubstance * m_N2
Definition: Substances.h:107
Definition: SELiquidCompartment.h:10
virtual void Clear()
Definition: SESubstanceManager.cpp:23
virtual bool LoadSubstanceDirectory(const std::string &data_dir=".")
Definition: SESubstanceManager.cpp:241
Definition: SETissueCompartment.h:8
SESubstance & GetEpi()
Definition: Substances.h:56
virtual void AddActiveSubstance(SESubstance &substance)
Definition: SESubstanceManager.cpp:96
SESubstance & GetN2()
Definition: Substances.h:49
SESubstance & GetHb()
Definition: Substances.h:50
SESubstance & GetLactate()
Definition: Substances.h:67
SESubstance * m_HbO2CO2
Definition: Substances.h:112
PulseController & m_data
Definition: Substances.h:134
SESubstance & GetCO2()
Definition: Substances.h:48
SESubstance * m_globulin
Definition: Substances.h:121
SESubstance & GetPotassium()
Definition: Substances.h:68
SESubstance & GetCO()
Definition: Substances.h:47
SESubstance * m_potassium
Definition: Substances.h:126
SESubstance & GetHCO3()
Definition: Substances.h:55
SizeIndependentDepositionEfficencyCoefficient()
Definition: Substances.h:13
virtual bool IsActive(const SESubstance &substance) const
Definition: SESubstanceManager.cpp:79
SESubstance * m_calcium
Definition: Substances.h:118
SESubstance * m_HbO2
Definition: Substances.h:109
SESubstance * m_CO
Definition: Substances.h:105
SESubstance & GetHbO2CO2()
Definition: Substances.h:54
SESubstance & GetHbCO()
Definition: Substances.h:53
SESubstance & GetChloride()
Definition: Substances.h:62
Definition: SEScalarAmountPerVolume.h:24
SESubstance * m_Hb
Definition: Substances.h:108
~SizeIndependentDepositionEfficencyCoefficient()
Definition: Substances.h:14
Manages and initializes all systems with substances needed by Pulse.
Definition: Substances.h:31
Definition: SEScalarMass.h:7
SESubstance * m_O2
Definition: Substances.h:104
SESubstance * m_urea
Definition: Substances.h:128
SESubstance & GetUrea()
Definition: Substances.h:71
SESubstance & GetHbO2()
Definition: Substances.h:51
Definition: SESubstance.h:14
bool m_isCOActive
Definition: Substances.h:130
SESubstance & GetInsulin()
Definition: Substances.h:66
SESubstance * m_CO2
Definition: Substances.h:106