EngineTest.h
1/* Distributed under the Apache License, Version 2.0.
2 See accompanying NOTICE file for details.*/
3
4#include "cdm/utils/testing/SETestManager.h"
5#include "engine/human_adult/whole_body/Engine.h"
6#include "engine/human_adult/whole_body/controller/Controller.h"
7
8class SESubstance;
9class SETestSuite;
10class HowToTracker;
11
12namespace pulse { namespace human_adult_whole_body
13{
14 class EngineTest : public SETestManager
15 {
16 public:
17 EngineTest(Logger* logger = nullptr);
18 virtual ~EngineTest();
19
20 virtual bool RunTest(const std::string& testName, const std::string& sOutputDirectory) override;
21
22 protected:
23 virtual void FillFunctionMap() override;
24 typedef void(EngineTest::* testFunction)(const std::string&);
25 std::map<std::string, testFunction> testMap;
26 std::stringstream m_ss;
27
28
30 // Circuit Hemodynamics and Compartment Transport Tests //
31 // System Specific Functions Tests as well //
33 public:
35 // Cardiovascular //
37 void CardiovascularCircuitAndTransportTest(const std::string& sTestDirectory);
38 void CardiovascularAndRenalCircuitAndTransportTest(const std::string& sTestDirectory);
39 void CardiovascularAndTissueCircuitAndTransportTest(const std::string& sTestDirectory);
40 void CardiovascularAndCerebrospinalFluidCircuitAndTransportTest(const std::string& sTestDirectory);
41 void FullCardiovascularCircuitAndTransportTest(const std::string& sTestDirectory);
42 void CardiovascularBloodGasesTest(const std::string& sTestDirectory);// Characterize the cv circuit
43 void TuneCardiovascularCircuitTest(const std::string& sTestDirectory);
44 // Cardiovascular Utilities //
45 void CardiovascularCircuitScaleTests(const std::string& sTestDirectory);
46 protected:
47 enum CardiovascularDriver { Sinusoid = 0, Heart };
48 void SinusoidHeartDriver(double time_s, double heartRate_s, double& lHeartElastance, double& rHeartElastance);
49 void CardiovascularCircuitAndTransportTest(CardiovascularDriver driverType, double complianceScale, double resistanceScale, double volumeScale, double heartRate_bpm,
50 double sysRes, double sysComp, double aortaRes, double aortaComp, double rightHeartRes, double venaCavaComp, bool connectTissue, bool connectRenal, bool connectCSF,
51 bool balanceBloodgases, const std::string& sTestDirectory, const std::string& sTestName, bool breakOutResults);
52 void TuneCardiovascularCircuitTest(SETestSuite& testSuite, const std::string& sTestDirectory, const std::string& sTestName, SEPatient& patient);
53
54 double m_MeanAortaPressure;
55 double m_MeanCVPressure;
56 double m_Systolic;
57 double m_Diastolic;
58 double m_Pulse;
59 double m_CardiacOutput;
60
61 public:
63 // Renal //
65 void RenalCircuitAndTransportTest(const std::string& sTestDirectory);
66 void RenalTGFFeedbackTest(const std::string& sTestDirectory);
67 void RenalTGFandUPRFeedbackTest(const std::string& sTestDirectory);
68 void RenalSecretionTest(const std::string& sTestDirectory);
69 void RenalUrinateTest(const std::string& sTestDirectory);
70 protected:
71 enum RenalFeedback { TGF, TGFandUPR };
72 void RenalFeedbackTest(RenalFeedback feedback, const std::string& sTestDirectory, const std::string& sTestName);
73 enum RenalSystems { Secretion, Urinating};
74 void RenalSystemTest(RenalSystems systemtest, const std::string& sTestDirectory, const std::string& sTestName);
75
76 public:
78 // Respiratory //
80 void RespiratoryCircuitAndTransportTest(const std::string& sTestDirectory);
81 void RespiratoryDriverTest(const std::string& sTestDirectory);
82 protected:
83 enum RespiratoryConfiguration { RespiratorySolo, AnesthesiaMachineSolo, RespiratoryWithAnesthesiaMachine, RespiratoryWithInhaler, RespiratoryWithMechanicalVentilation, MechanicalVentilatorSolo, RespiratoryWithMechanicalVentilator
84 };
85 void RespiratoryCircuitAndTransportTest(RespiratoryConfiguration config, const std::string& sTestDirectory);
86
87 public:
89 // Anesthesia Machine //
91 void AnesthesiaMachineCircuitAndTransportTest(const std::string& sTestDirectory);
92 void RespiratoryWithAnesthesiaMachineCircuitAndTransportTest(const std::string& sTestDirectory);
93 protected:
94 void AnesthesiaMachineCircuitAndTransportTest(RespiratoryConfiguration config, const std::string& sTestDirectory);
95
96 public:
98 // Mechanical Ventilator //
100 void MechanicalVentilatorCircuitAndTransportTest(const std::string& sTestDirectory);
101 void RespiratoryWithMechanicalVentilatorCircuitAndTransportTest(const std::string& sTestDirectory);
102 protected:
103 void MechanicalVentilatorCircuitAndTransportTest(RespiratoryConfiguration config, const std::string& sTestDirectory);
104
105 public:
107 // Inhaler //
109 void RespiratoryWithInhalerCircuitAndTransportTest(const std::string& sTestDirectory);
110 protected:
111
112 public:
114 // Mechanical Ventilation //
116 void RespiratoryWithMechanicalVentilationCircuitAndTransportTest(const std::string& sTestDirectory);
117 protected:
118
119 public:
121 // Environment and Energy //
122 void InternalTemperatureVariableBMRCircuitTest(const std::string& sTestDirectory);
123 void InternalTemperatureVariableSkinCircuitTest(const std::string& sTestDirectory);
124 void InternalTemperatureVariableCoreCircuitTest(const std::string& sTestDirectory);
125 void EnvironmentVariableTemperatureCircuitTest(const std::string& sTestDirectory);
126 void CombinedInternalAndEnvironmentVariableBMRandTemperatureCircuitTest(const std::string& sTestDirectory);
127 void CombinedInternalAndEnvironmentSkinTempDropCircuitTest(const std::string& sTestDirectory);
128 void EnvironmentISO7730ComparisonTest(const std::string& sTestDirectory);
129 protected:
130
131 public:
133 // Tissue Tests //
135 void DiffusionClearanceExcretionTests(const std::string& rptDirectory);
136 void AlveolarCarbonDioxideDiffusionTest(const std::string& rptDirectory);
137 void AlveolarOxygenDiffusionTest(const std::string& rptDirectory);
138 void InstantPlusSimpleDiffusionTest(const std::string& rptDirectory);
139 void SimpleDiffusionTwoCompartmentTest(const std::string& rptDirectory);
140 void SimpleDiffusionFourCompartmentTest(const std::string& rptDirectory);
141 void SimpleDiffusionHierarchyTest(const std::string& rptDirectory);
142 void FacilitatedDiffusionTest(const std::string& rptDirectory);
143 protected:
144 void DistributeMass(SETestSuite& testSuite);
145 void PerfusionLimitedDiffusionTest(SETestSuite& testSuite);
146 void InstantDiffusionTest(SETestSuite& testSuite);
147 void ActiveTransportTest(SETestSuite& testSuite);
148 void GenericClearanceTest(SETestSuite& testSuite);
149 void GenericExcretionTest(SETestSuite& testSuite);
150
151 public:
153 // Nervous Tests //
155 void BrainInjuryTest(const std::string& rptDirectory);
156 protected:
157
158 public:
160 // Acid Base Engine Tests //
162 void FourCompartmentTestSimple(const std::string& sOutputDirectory);
163 void AcidBaseFourCompartmentTest(const std::string& sOutputDirectory);
164 void FiveCompartmentTestWithDiffusion(const std::string& sOutputDirectory);
165 void AcidBaseFourCompartmentTestWithProductionConsumption(const std::string& sOutputDirectory);
166 void AcidBaseFiveCompartmentTestWithDiffusion(const std::string& sOutputDirectory);
167 void AcidBaseFiveCompartmentTestWithProductionConsumptionAndDiffusion(const std::string& sOutputDirectory);
168 protected:
169 void FourCompartmentTest(bool usingAcidBase, bool usingProductionConsumption, bool usingDiffusion, const std::string& sOutputDirectory);
170 bool usingAcidBase;
171 bool usingProductionConsumption;
172 bool usingDiffusion;
173
174 public:
176 // Acid Base Tests //
178 void AcidBaseMathTest(const std::string& sOutputDirectory);
179 void AcidBaseFeedbackTest(const std::string& sOutputDirectory);
180 void AcidBaseLimitsTest(const std::string& sOutputDirectory);
181 void AcidBaseExtremeTest(const std::string & rptDirectory);
182 void AcidBaseBloodGasTests(const std::string& sOutputDirectory);
183 protected:
184 enum bloodType { ARTERIAL, VENOUS, CAPILLARY, RESPIRATORY_ACIDOSIS, METABOLIC_ALKALOSIS, METABOLIC_ACIDOSIS, RESPIRATORY_ALKALOSIS, CUSTOM };
185 void AcidBaseBloodGasTest(Controller& bg, bloodType compartment, SETestSuite& testSuite);
186
187 public:
189 // Aerosol Tests //
191 void AerosolTest(const std::string& sOutputDirectory);
192 protected:
193 void SizeIndependentDepositionEfficencyCoefficientsTest(SETestSuite& suite, SESubstance& substance, double expectedMouthCoeff, double expectedCarinaCoeff, double expectedDeadSpaceCoeff, double expectedAlveoliCoeff);
194 void DepositionFractionTest(SETestSuite& suite, SESubstance& substance, double expectedMouthDepFrac, double expectedCarinaDepFrac,
195 double expectedLeftDeadSpaceDepFrac, double expectedLeftAlveoliDepFrac, double expectedRightDeadSpaceDepFrac, double expectedRightAlveoliDepFrac);
196
197 public:
199 // General Engine Tests //
201 void ReadScenarios(const std::string& sOutputDirectory);
202 void ReuseEngine(const std::string& sOutputDirectory);
203 void SerializationTest(const std::string& sTestDirectory);
204 void SetupPatientTest(const std::string& sTestDirectory);
205
206 void ConditionCombinations(const std::string& rptDirectory);
207 void SolverSpeedTest(const std::string& sTestDirectory);
208
209 protected:
210 void InhalerState(PhysiologyEngine* bg, HowToTracker& tracker);
211 void InjectSuccsState(PhysiologyEngine* bg, HowToTracker& tracker, const SESubstance& succs);
212
213 void SetupPatient(SETestSuite& testSuite, const std::string& sTestDirectory, const std::string& sTestName, SEPatient* patient, SEPatient* expectedPatient, bool expectedPass);
214 bool CheckSetupPatient(SEPatient& setupPatient, SEPatient& expectedPatient, std::vector<std::string>& errs);
215 public:
217 // Black Box Tests //
219 void EmptyBlackBoxTest(const std::string& sOutputDirectory);
220 void ImposeFlowBlackBoxTest(const std::string& sOutputDirectory);
221 void ImposePressureAndFlowBlackBoxTest(const std::string& sOutputDirectory);
222 protected:
223
224 };
225END_NAMESPACE_EX
Definition: SerializationTest.cpp:46
Definition: Logger.h:71
Definition: PhysiologyEngine.h:68
Definition: SEPatient.h:13
Definition: SESubstance.h:15
Definition: SETestManager.h:8
Definition: SETestSuite.h:10
Definition: Logger.h:14

Distributed under the Apache License, Version 2.0.

See accompanying NOTICE file for details.