CommonDataModelTest.h
1// The following tests will be exported and runnable
2
3#include "CommonDefs.h"
4#include "utils/testing/SETestManager.h"
14class SETestSuite;
15class SETestCase;
16
17
18#define CDM_TEST_DECL
19#ifdef SHARED_CDM_TEST
20 #if defined (__clang__)
21 #define CDM_TEST_DECL
22 #elif defined(__gnu_linux__)
23 #define CDM_TEST_DECL __attribute__ ((visibility ("default")))
24 #else
25 #ifdef SHARED_CDM_TEST
26 #define CDM_TEST_DECL __declspec(dllexport)
27 #else
28 #define CDM_TEST_DECL __declspec(dllimport)
29 #endif
30 #endif
31#endif
32
33enum enumCDMTestSourceType
34{
35 DC,
36 SIN,
37 PULSE,
38 ZEROCENTEREDSIN
39};
40
41class CDM_TEST_DECL CommonDataModelTest : public SETestManager
42{
43public:
44 CommonDataModelTest(Logger* logger=nullptr);
45 virtual ~CommonDataModelTest();
46
47 virtual bool RunTest(const std::string& testName, const std::string& sOutputDirectory) override;
48
49protected:
50 virtual void FillFunctionMap() override;
52 std::string m_OutDirectory;
53
54 typedef void(CommonDataModelTest::*testFunction)(const std::string&);
55 typedef std::map<std::string, testFunction> testMap;
57
58
60 // Circuits //
62public:
63 //Basic Circuit Tests
64 void BasicCircuitTest(const std::string& sOutputDirectory);
65 void MultiphysicsElectricalCircuitTest(const std::string& sOutputDirectory);
66 void MultiphysicsFluidCircuitTest(const std::string& sOutputDirectory);
67 void MultiphysicsThermalCircuitTest(const std::string& sOutputDirectory);
68
69 void SeriesRCDCTest(const std::string& sOutputDirectory);
70 void SeriesRCSINTest(const std::string& sOutputDirectory);
71 void SeriesRCPULSETest(const std::string& sOutputDirectory);
72
73 void SeriesRDCTest(const std::string& sOutputDirectory);
74 void SeriesRSINTest(const std::string& sOutputDirectory);
75 void SeriesRPULSETest(const std::string& sOutputDirectory);
76
77 void SeriesRLDCTest(const std::string& sOutputDirectory);
78 void SeriesRLSINTest(const std::string& sOutputDirectory);
79 void SeriesRLPULSETest(const std::string& sOutputDirectory);
80
81 void ParallelRDCTest(const std::string& sOutputDirectory);
82 void ParallelRSINTest(const std::string& sOutputDirectory);
83 void ParallelRPULSETest(const std::string& sOutputDirectory);
84
85 void ParallelRCDCTest(const std::string& sOutputDirectory);
86 void ParallelRCSINTest(const std::string& sOutputDirectory);
87 void ParallelRCPULSETest(const std::string& sOutputDirectory);
88
89 void ParallelRLDCTest(const std::string& sOutputDirectory);
90 void ParallelRLSINTest(const std::string& sOutputDirectory);
91 void ParallelRLPULSETest(const std::string& sOutputDirectory);
92 void ParallelRLSINCenteredTest(const std::string& sOutputDirectory);
93
94 void SeriesRLCDCTest(const std::string& sOutputDirectory);
95 void SeriesRLCSINTest(const std::string& sOutputDirectory);
96 void SeriesRLCPULSETest(const std::string& sOutputDirectory);
97
98 void ParallelRLCDCTest(const std::string& sOutputDirectory);
99 void ParallelRLCSINTest(const std::string& sOutputDirectory);
100 void ParallelRLCPULSETest(const std::string& sOutputDirectory);
101
102 void SwitchRCDCTest(const std::string& sOutputDirectory);
103 void SwitchRCSINTest(const std::string& sOutputDirectory);
104 void SwitchRCPULSETest(const std::string& sOutputDirectory);
105
106 void Comprehensive1DCTest(const std::string& sOutputDirectory);
107 void Comprehensive1SINTest(const std::string& sOutputDirectory);
108 void Comprehensive1PULSETest(const std::string& sOutputDirectory);
109
110 void SimpleDiodeDCTest(const std::string& sOutputDirectory);
111 void SimpleDiodeSINTest(const std::string& sOutputDirectory);
112 void SimpleDiodePULSETest(const std::string& sOutputDirectory);
113
114 void SeriesRCDCCurrentTest(const std::string& sOutputDirectory);
115 void SeriesRCSINCurrentTest(const std::string& sOutputDirectory);
116 void SeriesRCPULSECurrentTest(const std::string& sOutputDirectory);
117
118 void ParallelRCDCCurrentTest(const std::string& sOutputDirectory);
119 void ParallelRCSINCurrentTest(const std::string& sOutputDirectory);
120 void ParallelRCPULSECurrentTest(const std::string& sOutputDirectory);
121
122 void SeriesCapDCTest(const std::string& sOutputDirectory);
123 void SeriesCapSINTest(const std::string& sOutputDirectory);
124 void SeriesCapPULSETest(const std::string& sOutputDirectory);
125
126 void ParallelRDCCurrentTest(const std::string& sOutputDirectory);
127 void ParallelRSINCurrentTest(const std::string& sOutputDirectory);
128 void ParallelRPULSECurrentTest(const std::string& sOutputDirectory);
129
130 void CurrentCompDCTest(const std::string& sOutputDirectory);
131 void CurrentCompSINTest(const std::string& sOutputDirectory);
132 void CurrentCompPULSETest(const std::string& sOutputDirectory);
133
134 void SeriesRLDCCurrentTest(const std::string& sOutputDirectory);
135 void SeriesRLSINCurrentTest(const std::string& sOutputDirectory);
136 void SeriesRLPULSECurrentTest(const std::string& sOutputDirectory);
137
138 void ParallelRLDCCurrentTest(const std::string& sOutputDirectory);
139 void ParallelRLSINCurrentTest(const std::string& sOutputDirectory);
140 void ParallelRLPULSECurrentTest(const std::string& sOutputDirectory);
141
142 void BasicDiodeDCCurrentTest(const std::string& sOutputDirectory);
143 void BasicDiodeSINCurrentTest(const std::string& sOutputDirectory);
144 void BasicDiodePULSECurrentTest(const std::string& sOutputDirectory);
145
146 //NOTE: These next three tests seem to give errors while running, but they produce output...
147 void SwitchRCDCCurrentTest(const std::string& sOutputDirectory);
148 void SwitchRCSINCurrentTest(const std::string& sOutputDirectory);
149 void SwitchRCPULSECurrentTest(const std::string& sOutputDirectory);
150
151 void SeriesRLCDCCurrentTest(const std::string& sOutputDirectory);
152 void SeriesRLCSINCurrentTest(const std::string& sOutputDirectory);
153 void SeriesRLCPULSECurrentTest(const std::string& sOutputDirectory);
154
155 void ParallelRLCDCCurrentTest(const std::string& sOutputDirectory);
156 void ParallelRLCSINCurrentTest(const std::string& sOutputDirectory);
157 void ParallelRLCPULSECurrentTest(const std::string& sOutputDirectory);
158
159 void SeriesPressureSourceAdditionDCTest(const std::string& sOutputDirectory);
160 void SeriesPressureSourceAdditionSINTest(const std::string& sOutputDirectory);
161 void SeriesPressureSourceAdditionPULSETest(const std::string& sOutputDirectory);
162
163 //NOTE: These next six tests seem to give errors while running, but it's intentional
164 void SeriesCurrentSourceAdditionDCTest(const std::string& sOutputDirectory);
165 void SeriesCurrentSourceAdditionSINTest(const std::string& sOutputDirectory);
166 void SeriesCurrentSourceAdditionPULSETest(const std::string& sOutputDirectory);
167
168 void ParallelPressureSourceAdditionDCTest(const std::string& sOutputDirectory);
169 void ParallelPressureSourceAdditionSINTest(const std::string& sOutputDirectory);
170 void ParallelPressureSourceAdditionPULSETest(const std::string& sOutputDirectory);
171
172 void ParallelCurrentSourceAdditionDCTest(const std::string& sOutputDirectory);
173 void ParallelCurrentSourceAdditionSINTest(const std::string& sOutputDirectory);
174 void ParallelCurrentSourceAdditionPULSETest(const std::string& sOutputDirectory);
175
176 void SeriesCapDCCurrentTest(const std::string& sOutputDirectory);
177 void SeriesCapSINCurrentTest(const std::string& sOutputDirectory);
178 void SeriesCapPULSECurrentTest(const std::string& sOutputDirectory);
179
180 void ParallelCapDCTest(const std::string& sOutputDirectory);
181 void ParallelCapSINTest(const std::string& sOutputDirectory);
182 void ParallelCapPULSETest(const std::string& sOutputDirectory);
183
184 void ParallelCapDCCurrentTest(const std::string& sOutputDirectory);
185 void ParallelCapSINCurrentTest(const std::string& sOutputDirectory);
186 void ParallelCapPULSECurrentTest(const std::string& sOutputDirectory);
187
188 void SeriesIndDCTest(const std::string& sOutputDirectory);
189 void SeriesIndSINTest(const std::string& sOutputDirectory);
190 void SeriesIndPULSETest(const std::string& sOutputDirectory);
191
192 void SeriesIndDCCurrentTest(const std::string& sOutputDirectory);
193 void SeriesIndSINCurrentTest(const std::string& sOutputDirectory);
194 void SeriesIndPULSECurrentTest(const std::string& sOutputDirectory);
195
196 void ParallelIndDCTest(const std::string& sOutputDirectory);
197 void ParallelIndSINTest(const std::string& sOutputDirectory);
198 void ParallelIndPULSETest(const std::string& sOutputDirectory);
199
200 void ParallelIndDCCurrentTest(const std::string& sOutputDirectory);
201 void ParallelIndSINCurrentTest(const std::string& sOutputDirectory);
202 void ParallelIndPULSECurrentTest(const std::string& sOutputDirectory);
203
204 //These next three tests intentionally fail
205 void BadDiodeDCTest(const std::string& sOutputDirectory);
206 void BadDiodeSINTest(const std::string& sOutputDirectory);
207 void BadDiodePULSETest(const std::string& sOutputDirectory);
208
209 void ValidationComprehensive1DCTest(const std::string& sOutputDirectory);
210 void ValidationComprehensive1SINTest(const std::string& sOutputDirectory);
211 void ValidationComprehensive1PULSETest(const std::string& sOutputDirectory);
212 void ValidationComprehensive1SINCenteredTest(const std::string& sOutputDirectory);
213
214 void ValidationComprehensive2DCTest(const std::string& sOutputDirectory);
215 void ValidationComprehensive2SINTest(const std::string& sOutputDirectory);
216 void ValidationComprehensive2PULSETest(const std::string& sOutputDirectory);
217 void ValidationComprehensive2SINCenteredTest(const std::string& sOutputDirectory);
218
219 //Advanced Circuit Tests
220 void ElectricalCircuitTest(const std::string& sOutputDirectory);
221 void FluidCircuitTest(const std::string& sOutputDirectory);
222 void ThermalCircuitTest(const std::string& sOutputDirectory);
223 void CombinedCircuitTest(const std::string& sOutputDirectory);
224 void CircuitErrorTest(const std::string& sOutputDirectory); //This one doesn't output anything right now
225 void DynamicallyChangingCircuitTest(const std::string& sOutputDirectory); //This one has some really strange output (-1.$)
226 void NonZeroReferencePositive(const std::string& sOutputDirectory);
227 void NonZeroReferenceNegative(const std::string& sOutputDirectory);
228 void PolarizedCapacitorTest(const std::string& sOutputDirectory);
229 void PreChargeComplianceZeroVolume(const std::string& sOutputDirectory);
230 void PreChargeComplianceNonZeroVolume(const std::string& sOutputDirectory);
231 void ComplianceVolumeChange(const std::string& sOutputDirectory);
232 void CircuitLockingTest(const std::string& sOutputDirectory);
233
234protected:
235 //Used to generalize Basic Tests
236 void RunTest(const std::string& sOutputDirectory, const std::string& testName, enumCDMTestSourceType sourceType, int testIndex);
237
238 //Setup and preprocess methods for Basic Tests
239 void TestSetup7SeriesRCDC();
240 void TestSetup7SeriesRCSIN();
241 void TestSetup7SeriesRCPULSE();
242 void TestSetup8SeriesRDC();
243 void TestSetup8SeriesRSIN();
244 void TestSetup8SeriesRPULSE();
245 void TestSetup9SeriesRLDC();
246 void TestSetup9SeriesRLSIN();
247 void TestSetup9SeriesRLPULSE();
248 void TestSetup10ParallelRDC();
249 void TestSetup10ParallelRSIN();
250 void TestSetup10ParallelRPULSE();
251 void TestSetup11ParallelRCDC();
252 void TestSetup11ParallelRCSIN();
253 void TestSetup11ParallelRCPULSE();
254 void TestSetup12ParallelRLDC();
255 void TestSetup12ParallelRLSIN();
256 void TestSetup12ParallelRLPULSE();
257 void TestSetup12ParallelRLSINCentered();
258 void TestSetup13SeriesRLCDC();
259 void TestSetup13SeriesRLCSIN();
260 void TestSetup13SeriesRLCPULSE();
261 void TestSetup14ParallelRLCDC();
262 void TestSetup14ParallelRLCSIN();
263 void TestSetup14ParallelRLCPULSE();
264 void TestSetup15SwitchRCDC();
265 void TestSetup15SwitchRCSIN();
266 void TestSetup15SwitchRCPULSE();
267 void TestSetup16Comprehensive1DC();
268 void TestSetup16Comprehensive1SIN();
269 void TestSetup16Comprehensive1PULSE();
270 void TestSetup17BasicDiodeDC();
271 void TestSetup17BasicDiodeSIN();
272 void TestSetup17BasicDiodePULSE();
273 void TestSetup18RCSeriesDCCurrent();
274 void TestSetup18RCSeriesSINCurrent();
275 void TestSetup18RCSeriesPulseCurrent();
276 void TestSetup19RCParallelDCCurrent();
277 void TestSetup19RCParallelSINCurrent();
278 void TestSetup19RCParallelPulseCurrent();
279 void TestSetup20SeriesCapDC();
280 void TestSetup20SeriesCapSIN();
281 void TestSetup20SeriesCapPulse();
282 void TestSetup21ParallelRDCCurrent();
283 void TestSetup21ParallelRSINCurrent();
284 void TestSetup21ParallelRPulseCurrent();
285 void TestSetup22CurrentCompDC();
286 void TestSetup22CurrentCompSIN();
287 void TestSetup22CurrentCompPulse();
288 void TestSetup23SeriesRLDCCurrent();
289 void TestSetup23SeriesRLSINCurrent();
290 void TestSetup23SeriesRLPULSECurrent();
291 void TestSetup24ParallelRLDCCurrent();
292 void TestSetup24ParallelRLSINCurrent();
293 void TestSetup24ParallelRLPULSECurrent();
294 void TestSetup25BasicDiodeDCCurrent();
295 void TestSetup25BasicDiodeSINCurrent();
296 void TestSetup25BasicDiodePULSECurrent();
297 void TestSetup26SwitchRCDCCurrent();
298 void TestSetup26SwitchRCSINCurrent();
299 void TestSetup26SwitchRCPULSECurrent();
300 void TestSetup27SeriesRLCDCCurrent();
301 void TestSetup27SeriesRLCSINCurrent();
302 void TestSetup27SeriesRLCPULSECurrent();
303 void TestSetup28ParallelRLCDCCurrent();
304 void TestSetup28ParallelRLCSINCurrent();
305 void TestSetup28ParallelRLCPULSECurrent();
306 void TestSetup29SeriesPressureSourceAdditionDC();
307 void TestSetup29SeriesPressureSourceAdditionSIN();
308 void TestSetup29SeriesPressureSourceAdditionPULSE();
309 void TestSetup30SeriesCurrentSourceAdditionDC();
310 void TestSetup30SeriesCurrentSourceAdditionSIN();
311 void TestSetup30SeriesCurrentSourceAdditionPULSE();
312 void TestSetup31ParallelPressureSourceAdditionDC();
313 void TestSetup31ParallelPressureSourceAdditionSIN();
314 void TestSetup31ParallelPressureSourceAdditionPULSE();
315 void TestSetup32ParallelCurrentSourceAdditionDC();
316 void TestSetup32ParallelCurrentSourceAdditionSIN();
317 void TestSetup32ParallelCurrrentSourceAdditionPULSE();
318 void TestSetup33SeriesCapDCCurrent();
319 void TestSetup33SeriesCapSINCurrent();
320 void TestSetup33SeriesCapPulseCurrent();
321 void TestSetup34ParallelCapDC();
322 void TestSetup34ParallelCapSIN();
323 void TestSetup34ParallelCapPulse();
324 void TestSetup35ParallelCapDCCurrent();
325 void TestSetup35ParallelCapSINCurrent();
326 void TestSetup35ParallelCapPulseCurrent();
327 void TestSetup36SeriesIndDC();
328 void TestSetup36SeriesIndSIN();
329 void TestSetup36SeriesIndPulse();
330 void TestSetup37SeriesIndDCCurrent();
331 void TestSetup37SeriesIndSINCurrent();
332 void TestSetup37SeriesIndPulseCurrent();
333 void TestSetup38ParallelIndDC();
334 void TestSetup38ParallelIndSIN();
335 void TestSetup38ParallelIndPulse();
336 void TestSetup39ParallelIndDCCurrent();
337 void TestSetup39ParallelIndSINCurrent();
338 void TestSetup39ParallelIndPulseCurrent();
339 void TestSetup40BadDiodeDC();
340 void TestSetup40BadDiodeSIN();
341 void TestSetup40BadDiodePulse();
342 void TestSetup41ValidationComprehensive1DC();
343 void TestSetup41ValidationComprehensive1SIN();
344 void TestSetup41ValidationComprehensive1Pulse();
345 void TestSetup41ValidationComprehensive1SINCentered();
346 void TestSetup42ValidationComprehensive2DC();
347 void TestSetup42ValidationComprehensive2SIN();
348 void TestSetup42ValidationComprehensive2Pulse();
349 void TestSetup42ValidationComprehensive2SINCentered();
350
351 void TestPreProcess1(double dT, int i);
352 void TestPreProcess2(double dT, int i);
353 void TestPreProcess3(double dT, int i);
354 void TestPreProcess4(double dT, int i);
355 void BasicCircuitPreProcess(double dT);
356 //Advanced pre-process
357 void FluidPreProcess(SEFluidCircuit& c, double dT);
358 void TestCircuitSerialization(const std::string& fileName);
359
361
362
364 // Compartments //
366public:
367 void GasCompartmentTest(const std::string& sOutputDirectory);
368 void LiquidCompartmentTest(const std::string& sOutputDirectory);
369 void ThermalCompartmentTest(const std::string& sOutputDirectory);
370 void TissueCompartmentTest(const std::string& sOutputDirectory); //there is nothing being tested here
371
372protected:
373 void TestCompartmentSerialization(SECompartmentManager& mgr, const std::string& fileName);
374 //Gas Compartments
375 void TestGasFlows(SETestSuite& testSuite, SESubstanceManager& subMgr);
376 void TestGasHierarchyFlows(SETestSuite& testSuite, SESubstanceManager& subMgr);
377 void TestFlow(SETestCase& testCase, SEGasCompartment& cmpt, double inflow_mL_Per_s, double outflow_mL_Per_s);
378 void TestGasHierarchy(SETestSuite& testSuite, SESubstanceManager& subMgr);
379 void TestGasCircuitVolumesPressuresAndFlows(SETestSuite& testSuite, SESubstanceManager& subMgr);
380 void CheckGasPressureAndVolume(SETestCase& testCase, SEGasCompartment& cmpt);
381 void TestGasSubstanceQuantity(SETestCase& testCase, SEGasCompartment& cmpt, SEGasSubstanceQuantity& subQ, double totalSubVolume_mL, double totalVolume_mL);
382 void TestUpdateGasLinks(SETestSuite& testSuite, SESubstanceManager& subMgr);
383 //Liquid Compartments
384 void TestLiquidFlows(SETestSuite& testSuite, SESubstanceManager& subMgr);
385 void TestLiquidHierarchyFlows(SETestSuite& testSuite, SESubstanceManager& subMgr);
386 void TestFlow(SETestCase& testCase, SELiquidCompartment& cmpt, double inflow_mL_Per_s, double outflow_mL_Per_s);
387 void TestLiquidHierarchy(SETestSuite& testSuite, SESubstanceManager& subMgr);
388 void TestLiquidCircuitVolumesPressuresAndFlows(SETestSuite& testSuite, SESubstanceManager& subMgr);
389 void TestLiquidHierarchySaturation(SETestSuite& testSuite, SESubstanceManager& subMgr);
390 void CheckLiquidPressureAndVolume(SETestCase& testCase, SELiquidCompartment& cmpt);
391 void TestLiquidSubstanceQuantity(SETestCase& testCase, SELiquidCompartment& cmpt, SELiquidSubstanceQuantity& subQ, double totalMass_mg, double totalVolume_mL);
392 void TestUpdateLiquidLinks(SETestSuite& testSuite, SESubstanceManager& subMgr);
393 //Thermal Compartments
394 void TestThermalFlows(SETestSuite& testSuite, SESubstanceManager& subMgr);
395 void TestThermalFlowHierarchy(SETestSuite& testSuite, SESubstanceManager& subMgr);
396 void TestFlow(SETestCase& testCase, SEThermalCompartment& cmpt, double inflow_kcal_Per_s, double outflow_kcal_Per_s);
397 void TestThermalHierarchy(SETestSuite& testSuite, SESubstanceManager& subMgr);
398 void TestCircuitHeatTemperatureAndFlows(SETestSuite& testSuite, SESubstanceManager& subMgr);
399 void CheckTemperatureAndHeat(SETestCase& testCase, SEThermalCompartment& cmpt);
400
402 // Transport //
404public:
405 void LargeFlowTransportTest(const std::string& sOutputDirectory);
406 void LiquidTransportTest(const std::string& sOutputDirectory);
407 void GasTransportTest(const std::string& sOutputDirectory);
408
410 // Black Box //
412
413public:
414 void BasicBlackBoxComparisonTest(const std::string& sOutputDirectory);
415 void BasicBlackBoxTest(const std::string& sOutputDirectory);
416 void WindkesselBlackBoxTest(const std::string& sOutputDirectory);
417 void BlackBoxComplianceTest(const std::string& sOutputDirectory);
418 void BlackBoxSourcesTest(const std::string& sOutputDirectory);
419
421 // I/O Tests //
423public:
424 void ActionTest(const std::string& sOutputDirectory);
425 void ReadPatientDirectory(const std::string& sOutputDirectory);
426 void ReadSubstanceDirectory(const std::string& sOutputDirectory);
427 void ConvertScenarioLogs(const std::string& sOutputDirectory);
428
430 // Properties Tests //
432public:
433 void ScalarTest(const std::string& sOutputDirectory);
434 void UnitsTest(const std::string& sOutputDirectory);
435 void WaveformInterpolatorTest(const std::string& sOutputDirectory);
436protected:
437 void ConvertList(std::vector<std::string> stringList);
438 // These property tests are not outputting any reports or anything, kind of just a sandbox at this point
439 // Maybe one day I will set something up, but these are generally not a problem (no jinx!)
440
441};
Definition: CommonDataModelTest.h:42
SECircuitManager * m_Circuits
Definition: CommonDataModelTest.h:360
std::map< std::string, testFunction > testMap
Definition: CommonDataModelTest.h:55
std::string m_OutDirectory
Definition: CommonDataModelTest.h:52
testMap cdmMap
Definition: CommonDataModelTest.h:56
double m_PercentTolerance
Definition: CommonDataModelTest.h:51
Definition: Logger.h:71
Definition: SECircuitManager.h:38
Definition: SECompartmentManager.h:25
Definition: SEFluidCircuit.h:12
Definition: SEGasCompartment.h:14
Definition: SEGasSubstanceQuantity.h:10
Definition: SELiquidCompartment.h:12
Definition: SELiquidSubstanceQuantity.h:12
Definition: SESubstanceManager.h:9
Definition: SETestCase.h:9
Definition: SETestManager.h:23
virtual bool RunTest(const std::string &testName, const std::string &sOutputDirectory)=0
virtual void FillFunctionMap()=0
Definition: SETestSuite.h:10
Definition: SEThermalCompartment.h:12

Distributed under the Apache License, Version 2.0.

See accompanying NOTICE file for details.