TissueModel.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
9class SESubstance;
16
17namespace pulse
18{
19 class PBPhysiology;
20 class EngineTest;
28 class PULSE_DECL TissueModel : public TissueSystem, public Model
29 {
30 friend PBPhysiology;//friend the serialization class
31 friend EngineTest;
32 public:
33 TissueModel(Data& data);
34 virtual ~TissueModel();
35
36 void Clear() override;
37
38 // Set members to a stable homeostatic state
39 void Initialize() override;
40 // Set pointers and other member variables common to both homeostatic initialization and loading a state
41 void SetUp() override;
42
43 void AtSteadyState() override;
44 void PreProcess() override;
45 void Process(bool solve_and_transport = true) override;
46 void PostProcess(bool solve_and_transport = true) override;
47
48 protected:
49 void ComputeExposedModelParameters() override;
50
51 // Preprocess Methods
52 void ProduceAlbumin(double duration_s);
53 void Dehydration();
54
55 /*Tissue System*/
56 void CalculateMetabolicConsumptionAndProduction(double time);
57 void GlucoseLipidControl(double time);
58
59 /*Process Methods*/
60 void CalculateDiffusion();
61 void CalculatePulmonaryCapillarySubstanceTransfer();
62 void CalculateVitals();
63
64 /*Postprocess Methods*/
65
66 /*Diffusion Utilities*/
67 void DistributeMassbyVolumeWeighted(SELiquidCompartment& cmpt, const SESubstance& sub, double mass, const MassUnit& unit);
68 void DistributeMassbyMassWeighted(SELiquidCompartment& cmpt, const SESubstance& sub, double mass, const MassUnit& unit);
69
70 double PerfusionLimitedDiffusion(SETissueCompartment& tissue, SELiquidCompartment& vascular, const SESubstance& sub, double partitionCoeff, double timestep_s);
71 void AlveolarPartialPressureGradientDiffusion(SEGasCompartment& pulmonary, SELiquidCompartment& vascular, SESubstance& sub, double DiffusingCapacityO2_mL_Per_s_mmHg, double timestep_s);
72
73 double MoveMassByInstantDiffusion(SELiquidCompartment& source, SELiquidCompartment& target, const SESubstance& sub);
74 double MoveMassBySimpleDiffusion(SELiquidCompartment& source, SELiquidCompartment& target, const SESubstance& sub, double permeabilityCofficient_mL_Per_s, double timestep_s);
75 double MoveMassByFacilitatedDiffusion(SELiquidCompartment& source, SELiquidCompartment& target, const SESubstance& sub, double combinedCoefficient_g_Per_s, double timestep_s);
76 double MoveMassByActiveTransport(SELiquidCompartment& source, SELiquidCompartment& target, const SESubstance& sub, double DiffusingCapacityO2_mL_Per_s_mmHg, double timestep_s);
77
78 // Serializable member variables (Set in Initialize and in schema)
79 double m_RestingTissueGlucose_g;
80 double m_RestingBloodGlucose_mg_Per_mL;
81 double m_RestingBloodLipid_mg_Per_mL;
82 double m_RestingBloodInsulin_mg_Per_mL;
83 double m_RestingFluidMass_kg;
84 double m_PreviousFluidMass_kg;
85 // Cache of flows to use to calculate consumption/production during cardiac arrest
86 std::map<SELiquidCompartment*, double> m_CardiacArrestVascularFlows_ml_per_min;
87
88 // Stateless member variable (Set in SetUp())
89 double m_AlbuminProdutionRate_g_Per_s;
90 SESubstance* m_Albumin;
91 SESubstance* m_Glucose;
92 SESubstance* m_Tristearin;
93 SESubstance* m_O2;
94 SESubstance* m_CO2;
95 SESubstance* m_CO;
96 SESubstance* m_Lactate;
97 SESubstance* m_Acetoacetate;
98 SESubstance* m_Creatinine;
99 SESubstance* m_Sodium;
100 SESubstance* m_Calcium;
101 SESubstance* m_Insulin;
102 SESubstanceCompound* m_Sweat;
103
104 SEFluidCircuitNode* m_GutT1;
105 SEFluidCircuitPath* m_GutT1ToGutT3;
106
107 SELiquidSubstanceQuantity* m_LiverAcetoacetate;
108 SELiquidSubstanceQuantity* m_LiverTissueAlbumin;
109 SETissueCompartment* m_LeftLungTissue;
110 SETissueCompartment* m_RightLungTissue;
111 SETissueCompartment* m_MuscleTissue;
112 SELiquidCompartment* m_MuscleIntracellular;
113 SETissueCompartment* m_LiverTissue;
114 SELiquidCompartment* m_LiverIntracellular;
115 SETissueCompartment* m_FatTissue;
116 SELiquidCompartment* m_FatIntracellular;
117
118 SELiquidCompartment* m_FatVascular;
119 SELiquidSubstanceQuantity* m_FatVascularLipid;
120 SELiquidSubstanceQuantity* m_LiverVascularGlucose;
121 SELiquidCompartment* m_MuscleVascular;
122 SELiquidSubstanceQuantity* m_MuscleVascularGlucose;
123
124 SEGasCompartment* m_LeftAlveoli;
125 SEGasCompartment* m_RightAlveoli;
126 SELiquidCompartment* m_LeftPulmonaryCapillaries;
127 SELiquidCompartment* m_RightPulmonaryCapillaries;
128
129 std::vector<SEFluidCircuitPath*> m_VascularResistances;
130 std::map<SETissueCompartment*, SELiquidCompartment*> m_TissueToVascular;
131 std::vector<SETissueCompartment*> m_ConsumptionProdutionTissues;
132 };
133END_NAMESPACE
Definition: SEScalarMass.h:8
Definition: PBPhysiology.h:24
Definition: SEFluidCircuitNode.h:10
Definition: SEFluidCircuitPath.h:9
Definition: SEGasCompartment.h:14
Definition: SELiquidCompartment.h:11
Definition: SELiquidSubstanceQuantity.h:12
Definition: SESubstanceCompound.h:10
Definition: SESubstance.h:15
Definition: SETissueCompartment.h:9
Definition: Logger.h:14

Distributed under the Apache License, Version 2.0.

See accompanying NOTICE file for details.