Commit b920cccf authored by Aaron Bray's avatar Aaron Bray
Browse files

Merge branch 'fix/warnings-tests' into '3.x'

Fix warnings

See merge request !75
parents 6c6343ab b9feec6b
......@@ -93,3 +93,11 @@ add_library_ex(DataModelBindings
protobuf::libprotobuf
LIB_INSTALL_ONLY
)
if (MSVC)
target_compile_options(DataModelBindings PRIVATE "/wd4100") # 'identifier' : unreferenced formal parameter
target_compile_options(DataModelBindings PRIVATE "/wd4125") # decimal digit terminates octal escape sequence
target_compile_options(DataModelBindings PRIVATE "/wd4127") # conditional expression is constant
target_compile_options(DataModelBindings PRIVATE "/wd4244") # 'conversion' conversion from 'type1' to 'type2', possible loss of data
target_compile_options(DataModelBindings PRIVATE "/wd4267") # 'var' : conversion from 'size_t' to 'type', possible loss of data
endif()
\ No newline at end of file
......@@ -36,6 +36,7 @@
#define PUSH_PROTO_WARNINGS() \
__pragma(pack(push)) \
__pragma(warning(disable:4127)) \
__pragma(warning(disable:4244)) \
__pragma(warning(disable:4267))
#define POP_PROTO_WARNINGS() __pragma(pack(pop))
#else
......
......@@ -2,8 +2,10 @@
See accompanying NOTICE file for details.*/
#include "stdafx.h"
PUSH_PROTO_WARNINGS()
#include "io/protobuf/PBBlackBox.h"
#include "pulse/cdm/bind/BlackBox.pb.h"
POP_PROTO_WARNINGS()
#include "blackbox/SEBlackBox.h"
const std::string& eBlackBox_Property_Type_Name(eBlackBox_Property_Type m)
......
......@@ -323,8 +323,8 @@ void CommonDataModelTest::CombinedCircuitTest(const std::string& sTestDirectory)
SEFluidCircuit* CombinedCircuit = &m_Circuits->CreateFluidCircuit("Combined");
CombinedCircuit->AddCircuit(*MasterCircuit);
CombinedCircuit->AddCircuit(*SlaveCircuit);
SEFluidCircuitPath& GroundPath = CombinedCircuit->CreatePath(MasterNode4, SlaveNode4, "GroundPath");
SEFluidCircuitPath& CombinedPath = CombinedCircuit->CreatePath(MasterNode3, SlaveNode3, "CombinedPath");
CombinedCircuit->CreatePath(MasterNode4, SlaveNode4, "GroundPath");
CombinedCircuit->CreatePath(MasterNode3, SlaveNode3, "CombinedPath");
CombinedCircuit->RemovePath(SlavePath1);
CombinedCircuit->StateChange();
......@@ -379,7 +379,6 @@ void CommonDataModelTest::CircuitErrorTest(const std::string& sTestDirectory)
std::cout << "CircuitErrorTest\n";
//Setup a basic circuit
m_Logger->SetLogFile(sTestDirectory + "/CombinedCircuitTest.log");
double timeStep_s = 1.0 / 165.0;
SEFluidCircuitCalculator fluidCalculator(m_Logger);
SEFluidCircuit* fluidCircuit = &m_Circuits->CreateFluidCircuit("Fluid");
//-----------------------------------------------------------
......@@ -487,9 +486,7 @@ void CommonDataModelTest::DynamicallyChangingCircuitTest(const std::string& sTes
fluidCircuit->GetPath("Path4")->GetResistanceBaseline().SetValue(50, PressureTimePerVolumeUnit::Pa_s_Per_m3);
//Add a new Path
SEFluidCircuitNode* Node2 = fluidCircuit->GetNode("Node2");
SEFluidCircuitNode* Node4 = fluidCircuit->GetNode("Node4");
SEFluidCircuitPath& Path5 = fluidCircuit->CreatePath(*Node2, *Node4, "Path5");
SEFluidCircuitPath& Path5 = fluidCircuit->CreatePath(Node2, Node4, "Path5");
Path5.GetNextResistance().SetValue(25, PressureTimePerVolumeUnit::Pa_s_Per_m3);
//Reset the baselines
fluidCircuit->StateChange();
......@@ -715,7 +712,6 @@ void CommonDataModelTest::PolarizedCapacitorTest(const std::string& sTestDirecto
fluidCircuit->StateChange();
bool serialized = false;
double sample = 0;
while (currentTime_s < 150)
{
if (currentTime_s > 100)
......@@ -871,7 +867,7 @@ void CommonDataModelTest::ComplianceVolumeChange(const std::string& sTestDirecto
SEFluidCircuitPath* groundTonode2 = &fluidCircuit->CreatePath(*ground, *node2, "groundTonode2");
groundTonode2->GetPressureSourceBaseline().SetValue(0.0, PressureUnit::cmH2O);
SEFluidCircuitPath* node2Tonode3 = &fluidCircuit->CreatePath(*node2, *node3, "node2Tonode3");
SEFluidCircuitPath* node3Toground = &fluidCircuit->CreatePath(*node3, *ground, "node3Toground");
fluidCircuit->CreatePath(*node3, *ground, "node3Toground");
node2Tonode3->GetComplianceBaseline().SetValue(1.0, VolumePerPressureUnit::L_Per_cmH2O);
fluidCircuit->SetNextAndCurrentFromBaselines();
fluidCircuit->StateChange();
......@@ -962,7 +958,7 @@ void CommonDataModelTest::CircuitLockingTest(const std::string& sOutputDirectory
flowSource.GetFlowSourceBaseline().SetValue(0.1, VolumePerTimeUnit::m3_Per_s);
SEFluidCircuitPath& potentialSource = fluidCircuit->CreatePath(Node5, Node1, "Potential Source");
potentialSource.GetPotentialSourceBaseline().SetValue(10, PressureUnit::Pa);
SEFluidCircuitPath& dummyPath = fluidCircuit->CreatePath(Node1, Node3, "Short");
fluidCircuit->CreatePath(Node1, Node3, "Short");
fluidCircuit->SetNextAndCurrentFromBaselines();
fluidCircuit->StateChange();
......
......@@ -4138,7 +4138,6 @@ void CommonDataModelTest::TestPreProcess2(double dT, int i)
// Never change "current" values, only next.
// ALL PRESSURE SOURCES MUST EXIST ON PATH 1 UNTIL THIS IS CHANGED TO BE MORE FLEXIBLE
double ONE = 1;
bool FLOWSOURCE = false;
bool SWITCHPRESENT = false;
bool PRESSURESOURCE = false;
......@@ -4384,7 +4383,6 @@ void CommonDataModelTest::TestPreProcess4(double dT, int i)
// Never change "current" values, only next.
// ALL PRESSURE SOURCES MUST EXIST ON PATH 1 UNTIL THIS IS CHANGED TO BE MORE FLEXIBLE
double ONE = 1;
bool FLOWSOURCE = false;
bool SWITCHPRESENT = false;
bool PRESSURESOURCE = false;
......@@ -5252,7 +5250,6 @@ void CommonDataModelTest::RunTest(const std::string& outputDirectory, const std:
fluidCircuit->SetNextAndCurrentFromBaselines();
fluidCircuit->StateChange();
double sample = 0;
bool serialized = false;
double outputTime_s = 0;
while (currentTime_s < 10) // Run for 10 secs
......
......@@ -344,8 +344,6 @@ void CommonDataModelTest::TestGasHierarchy(SETestSuite& testSuite, SESubstanceMa
double L2C3_mL = 12;
double L2C3_mmHg = 12;
double L2C3_H20 = 0.5;
double L2C3_pH = 7.38;
SEGasCompartment* L2C3 = &cmptMgr.CreateGasCompartment("L2C3");
L2C3->GetVolume().SetValue(L2C3_mL, VolumeUnit::mL);
L2C3->GetPressure().SetValue(L2C3_mmHg, PressureUnit::mmHg);
......
......@@ -187,24 +187,24 @@ void CommonDataModelTest::LiquidTransportTest(const std::string& rptDirectory)
SEFluidCircuitPath& groundToNode6 = circuit.CreatePath(Ground,Node6,"GroundToNode6");
groundToNode6.GetFlowSourceBaseline().SetValue(0.5, VolumePerTimeUnit::mL_Per_s);
SEFluidCircuitPath& Node1ToNode7 = circuit.CreatePath(Node1,Node7,"Node1ToNode7");
SEFluidCircuitPath& Node2ToNode7 = circuit.CreatePath(Node2,Node7,"Node2ToNode7");
SEFluidCircuitPath& Node3ToNode8 = circuit.CreatePath(Node3,Node8,"Node3ToNode8");
SEFluidCircuitPath& Node4ToNode8 = circuit.CreatePath(Node4,Node8,"Node4ToNode8");
SEFluidCircuitPath& Node5ToNode9 = circuit.CreatePath(Node5,Node9,"Node5ToNode9");
SEFluidCircuitPath& Node6ToNode9 = circuit.CreatePath(Node6,Node9,"Node6ToNode9");
SEFluidCircuitPath& Node7ToNode10 = circuit.CreatePath(Node7,Node10,"Node7ToNode10");
SEFluidCircuitPath& Node8ToNode10 = circuit.CreatePath(Node8,Node10,"Node8ToNode10");
SEFluidCircuitPath& Node9ToNode10 = circuit.CreatePath(Node9,Node10,"Node9ToNode10");
SEFluidCircuitPath& Node10ToNode11 = circuit.CreatePath(Node10,Node11,"Node10ToNode11");
SEFluidCircuitPath& Node10ToNode12 = circuit.CreatePath(Node10,Node12,"Node10ToNode12");
SEFluidCircuitPath& Node10ToNode13 = circuit.CreatePath(Node10,Node13,"Node10ToNode13");
SEFluidCircuitPath& Node11ToNode14 = circuit.CreatePath(Node11,Node14,"Node11ToNode14");
SEFluidCircuitPath& Node11ToNode15 = circuit.CreatePath(Node11,Node15,"Node11ToNode15");
SEFluidCircuitPath& Node12ToNode16 = circuit.CreatePath(Node12,Node16,"Node12ToNode16");
SEFluidCircuitPath& Node12ToNode17 = circuit.CreatePath(Node12,Node17,"Node12ToNode17");
SEFluidCircuitPath& Node13ToNode18 = circuit.CreatePath(Node13,Node18,"Node13ToNode18");
SEFluidCircuitPath& Node13ToNode19 = circuit.CreatePath(Node13,Node19,"Node13ToNode19");
circuit.CreatePath(Node1,Node7,"Node1ToNode7");
circuit.CreatePath(Node2,Node7,"Node2ToNode7");
circuit.CreatePath(Node3,Node8,"Node3ToNode8");
circuit.CreatePath(Node4,Node8,"Node4ToNode8");
circuit.CreatePath(Node5,Node9,"Node5ToNode9");
circuit.CreatePath(Node6,Node9,"Node6ToNode9");
circuit.CreatePath(Node7,Node10,"Node7ToNode10");
circuit.CreatePath(Node8,Node10,"Node8ToNode10");
circuit.CreatePath(Node9,Node10,"Node9ToNode10");
circuit.CreatePath(Node10,Node11,"Node10ToNode11");
circuit.CreatePath(Node10,Node12,"Node10ToNode12");
circuit.CreatePath(Node10,Node13,"Node10ToNode13");
circuit.CreatePath(Node11,Node14,"Node11ToNode14");
circuit.CreatePath(Node11,Node15,"Node11ToNode15");
circuit.CreatePath(Node12,Node16,"Node12ToNode16");
circuit.CreatePath(Node12,Node17,"Node12ToNode17");
circuit.CreatePath(Node13,Node18,"Node13ToNode18");
circuit.CreatePath(Node13,Node19,"Node13ToNode19");
SEFluidCircuitPath& Node14ToGround = circuit.CreatePath(Node14,Ground,"Node14ToGround");
Node14ToGround.GetFlowSourceBaseline().SetValue(0.5, VolumePerTimeUnit::mL_Per_s);
......@@ -370,24 +370,24 @@ void CommonDataModelTest::GasTransportTest(const std::string& rptDirectory)
SEFluidCircuitPath& groundToNode6 = circuit.CreatePath(Ground,Node6,"GroundToNode6");
groundToNode6.GetFlowSourceBaseline().SetValue(0.5, VolumePerTimeUnit::mL_Per_s);
SEFluidCircuitPath& Node1ToNode7 = circuit.CreatePath(Node1,Node7,"Node1ToNode7");
SEFluidCircuitPath& Node2ToNode7 = circuit.CreatePath(Node2,Node7,"Node2ToNode7");
SEFluidCircuitPath& Node3ToNode8 = circuit.CreatePath(Node3,Node8,"Node3ToNode8");
SEFluidCircuitPath& Node4ToNode8 = circuit.CreatePath(Node4,Node8,"Node4ToNode8");
SEFluidCircuitPath& Node5ToNode9 = circuit.CreatePath(Node5,Node9,"Node5ToNode9");
SEFluidCircuitPath& Node6ToNode9 = circuit.CreatePath(Node6,Node9,"Node6ToNode9");
SEFluidCircuitPath& Node7ToNode10 = circuit.CreatePath(Node7,Node10,"Node7ToNode10");
SEFluidCircuitPath& Node8ToNode10 = circuit.CreatePath(Node8,Node10,"Node8ToNode10");
SEFluidCircuitPath& Node9ToNode10 = circuit.CreatePath(Node9,Node10,"Node9ToNode10");
SEFluidCircuitPath& Node10ToNode11 = circuit.CreatePath(Node10,Node11,"Node10ToNode11");
SEFluidCircuitPath& Node10ToNode12 = circuit.CreatePath(Node10,Node12,"Node10ToNode12");
SEFluidCircuitPath& Node10ToNode13 = circuit.CreatePath(Node10,Node13,"Node10ToNode13");
SEFluidCircuitPath& Node11ToNode14 = circuit.CreatePath(Node11,Node14,"Node11ToNode14");
SEFluidCircuitPath& Node11ToNode15 = circuit.CreatePath(Node11,Node15,"Node11ToNode15");
SEFluidCircuitPath& Node12ToNode16 = circuit.CreatePath(Node12,Node16,"Node12ToNode16");
SEFluidCircuitPath& Node12ToNode17 = circuit.CreatePath(Node12,Node17,"Node12ToNode17");
SEFluidCircuitPath& Node13ToNode18 = circuit.CreatePath(Node13,Node18,"Node13ToNode18");
SEFluidCircuitPath& Node13ToNode19 = circuit.CreatePath(Node13,Node19,"Node13ToNode19");
circuit.CreatePath(Node1,Node7,"Node1ToNode7");
circuit.CreatePath(Node2,Node7,"Node2ToNode7");
circuit.CreatePath(Node3,Node8,"Node3ToNode8");
circuit.CreatePath(Node4,Node8,"Node4ToNode8");
circuit.CreatePath(Node5,Node9,"Node5ToNode9");
circuit.CreatePath(Node6,Node9,"Node6ToNode9");
circuit.CreatePath(Node7,Node10,"Node7ToNode10");
circuit.CreatePath(Node8,Node10,"Node8ToNode10");
circuit.CreatePath(Node9,Node10,"Node9ToNode10");
circuit.CreatePath(Node10,Node11,"Node10ToNode11");
circuit.CreatePath(Node10,Node12,"Node10ToNode12");
circuit.CreatePath(Node10,Node13,"Node10ToNode13");
circuit.CreatePath(Node11,Node14,"Node11ToNode14");
circuit.CreatePath(Node11,Node15,"Node11ToNode15");
circuit.CreatePath(Node12,Node16,"Node12ToNode16");
circuit.CreatePath(Node12,Node17,"Node12ToNode17");
circuit.CreatePath(Node13,Node18,"Node13ToNode18");
circuit.CreatePath(Node13,Node19,"Node13ToNode19");
SEFluidCircuitPath& Node14ToGround = circuit.CreatePath(Node14,Ground,"Node14ToGround");
Node14ToGround.GetFlowSourceBaseline().SetValue(0.5, VolumePerTimeUnit::mL_Per_s);
......
......@@ -294,8 +294,6 @@ void CommonDataModelTest::TestThermalHierarchy(SETestSuite& testSuite, SESubstan
SETestCase& testCase = testSuite.CreateTestCase();
testCase.SetName("HierarchyHeatTemperatureFlows");
SESubstance* N2 = subMgr.GetSubstance("Nitrogen");
SEScalarTemperature partialTemperature;
TimingProfile pTimer;
......
......@@ -52,14 +52,7 @@ void CommonDataModelTest::TissueCompartmentTest(const std::string& rptDirectory)
double TissueToPlasmaAlbuminRatio = 1.0;
double TissueToPlasmaAlphaAcidGlycoproteinRatio = 0.8;
double TissueToPlasmaLipoproteinRatio = 0.54;
//double TotalMass_mg = 333;
double ec_pH = 7.14;
double ec_WaterVolumeFraction = 0.67;
double ic_pH = 7.42;
double ic_WaterVolumeFraction = 0.76;
SECompartmentManager cmptMgr(subMgr);
SETissueCompartment* tissue = &cmptMgr.CreateTissueCompartment("Tissue");
tissue->GetAcidicPhospohlipidConcentration().SetValue(AcidicPhospohlipidConcentration_mg_Per_g, MassPerMassUnit::mg_Per_g);
......
......@@ -105,7 +105,7 @@ public:
// Huge penalty for negative numbers
double negativePenaltyO2 = MIN(0.0, o2_mM);
double negativePenaltyCO2 = (MIN(0.0, bicarb_mM) + MIN(0.0, co2_mM));
double pHpenalty = MAX((pH - 8.0), 0.0);
// unused: double pHpenalty = MAX((pH - 8.0), 0.0);
fvec(0) = f0;
fvec(1) = f1 - negativePenaltyCO2*100.0;
......@@ -352,9 +352,7 @@ void SaturationCalculator::CalculateCarbonMonoxideSpeciesDistribution(SELiquidCo
m_subCOQ->Balance(BalanceLiquidBy::PartialPressure);
m_subHbCOQ->GetMolarity().SetValue(targetBoundCO_mM, AmountPerVolumeUnit::mmol_Per_L);
double check1 = m_subHbCOQ->GetMolarity().GetValue(AmountPerVolumeUnit::mmol_Per_L);
m_subHbCOQ->Balance(BalanceLiquidBy::Molarity);
double check2 = m_subHbCOQ->GetMolarity().GetValue(AmountPerVolumeUnit::mmol_Per_L);
// No need to balance everything. The sat method only uses moles, and it balances at the end. Just need to balance CO
}
......@@ -953,80 +951,80 @@ void SaturationCalculator::CalculateHemoglobinSaturations(double O2PartialPressu
temperature_C += 4.6;
// Currently fixed, but could be expanded to be variable
double DPG = 4.65e-3; // standard 2; 3 - DPG concentration in RBCs; M
const double DPG = 4.65e-3; // standard 2; 3 - DPG concentration in RBCs; M
// Fixed parameters
double Wpl = 0.94; // fractional water space in plasma; unitless
double Wrbc = 0.65; // fractional water space in RBCs; unitless
double Rrbc = 0.69; // Gibbs - Donnan ratio across RBC membrane; unitless
double Hbrbc = 5.18e-3; // hemoglobin concentration in RBCs; M
double K2 = 2.95e-5; // CO2 + HbNH2 equilibrium constant; unitless
double K2dp = 1.0e-6; // HbNHCOOH dissociation constant; M
double K2p = K2 / K2dp; // kf2p / kb2p; 1 / M
double K3 = 2.51e-5; // CO2 + O2HbNH2 equilibrium constant; unitless
double K3dp = 1.0e-6; // O2HbNHCOOH dissociation constant; M
double K3p = K3 / K3dp; // kf3p / kb3p; 1 / M
double K5dp = 2.63e-8; // HbNH3 + dissociation constant; M
double K6dp = 1.91e-8; // O2HbNH3 + dissociation constant; M
double nhill = 2.7 - 1.1*CO_sat; // Hill coefficient; unitless
double n0 = nhill - 1.0 - 0.2*CO_sat; // Deviation term
double pO20 = 100.0; // standard O2 partial pressure in blood; mmHg
double pCO20 = 40.0; // standard CO2 partial pressure in blood; mmHg
double pH0 = 7.24; // standard pH in RBCs; unitless
double DPG0 = 4.65e-3; // standard 2; 3 - DPG concentration in RBCs; M
double Temp0 = 37.0; // standard temperature in blood; degC
double fact = 1.0e-6 / Wpl; // a multiplicative factor; M / mmHg
double alphaO20 = fact*1.37; // solubility of O2 in water at 37 C; M / mmHg
double alphaCO20 = fact*30.7; // solubility of CO2 in water at 37 C; M / mmHg
double O20 = alphaO20*pO20; // standard O2 concentration in RBCs; M
double CO20 = alphaCO20*pCO20; // standard CO2 concentration in RBCs; M
double Hp0 = pow(10, (-pH0)); // standard H + concentration in RBCs; M
double pHpl0 = pH0 - log10(Rrbc); // standard pH in plasma; unitless
double P500 = 26.8 - 20*CO_sat; // standard pO2 at 50% SHbO2; mmHg
double C500 = alphaO20*P500; // standard O2 concentration at 50 % SHbO2; M
double Wbl = (1 - hematocrit)*Wpl + hematocrit*Wrbc;
double pHpl = pH - log10(Rrbc);
double pHpldiff = pHpl - pHpl0;
double pHdiff = pH - pH0;
double pCO2diff = CO2PartialPressureGuess_mmHg - pCO20;
double DPGdiff = DPG - DPG0;
double Tempdiff = temperature_C - Temp0;
double alphaO2 = fact*(1.37 - 0.0137*Tempdiff + 0.00058*Tempdiff*Tempdiff);
double alphaCO2 = fact*(30.7 - 0.57*Tempdiff + 0.02*Tempdiff*Tempdiff);
double pK1 = 6.091 - 0.0434*pHpldiff + 0.0014*Tempdiff*pHpldiff;
double K1 = pow(10, -pK1);
double O2 = alphaO2*O2PartialPressureGuess_mmHg;
double CO2 = alphaCO2*CO2PartialPressureGuess_mmHg;
double Hp = pow(10, -pH);
double Hppl = pow(10, -pHpl);
double Term1 = K2p*(1 + K2dp / Hp);
double Term2 = K3p*(1 + K3dp / Hp);
double Term3 = (1 + Hp / K5dp);
double Term4 = (1 + Hp / K6dp);
double Term10 = K2p*(1 + K2dp / Hp0);
double Term20 = K3p*(1 + K3dp / Hp0);
double Term30 = (1 + Hp0 / K5dp);
double Term40 = (1 + Hp0 / K6dp);
double Kratio10 = (Term10*CO20 + Term30) / (Term20*CO20 + Term40);
double Kratio11 = (Term1*CO20 + Term3) / (Term2*CO20 + Term4);
double Kratio12 = (Term10*alphaCO20*CO2PartialPressureGuess_mmHg + Term30) / (Term20*alphaCO20*CO2PartialPressureGuess_mmHg + Term40);
double K4dp = Kratio10*pow(O20, n0) / pow(C500, nhill);
double K4tp = K4dp / pow(O20, n0);
double Kratio20 = Kratio10 / K4tp; // = C500^nhill
double Kratio21 = Kratio11 / K4tp;
double Kratio22 = Kratio12 / K4tp;
double P501 = 26.765 - 21.279*pHdiff + 8.872*pHdiff*pHdiff;
double P502 = 26.80 + 0.0428*pCO2diff + 3.64e-5*pCO2diff*pCO2diff;
double P503 = 26.78 + 795.633533*DPGdiff - 19660.8947*DPGdiff*DPGdiff;
double P504 = 26.75 + 1.4945*Tempdiff + 0.04335*Tempdiff*Tempdiff + 0.0007*Tempdiff*Tempdiff*Tempdiff;
double C501 = alphaO20*P501;
double C502 = alphaO20*P502;
double C503 = alphaO20*P503;
double C504 = alphaO2*P504;
const double Wpl = 0.94; // fractional water space in plasma; unitless
const double Wrbc = 0.65; // fractional water space in RBCs; unitless
const double Rrbc = 0.69; // Gibbs - Donnan ratio across RBC membrane; unitless
const double Hbrbc = 5.18e-3; // hemoglobin concentration in RBCs; M
const double K2 = 2.95e-5; // CO2 + HbNH2 equilibrium constant; unitless
const double K2dp = 1.0e-6; // HbNHCOOH dissociation constant; M
const double K2p = K2 / K2dp; // kf2p / kb2p; 1 / M
const double K3 = 2.51e-5; // CO2 + O2HbNH2 equilibrium constant; unitless
const double K3dp = 1.0e-6; // O2HbNHCOOH dissociation constant; M
const double K3p = K3 / K3dp; // kf3p / kb3p; 1 / M
const double K5dp = 2.63e-8; // HbNH3 + dissociation constant; M
const double K6dp = 1.91e-8; // O2HbNH3 + dissociation constant; M
const double nhill = 2.7 - 1.1*CO_sat; // Hill coefficient; unitless
const double n0 = nhill - 1.0 - 0.2*CO_sat; // Deviation term
const double pO20 = 100.0; // standard O2 partial pressure in blood; mmHg
const double pCO20 = 40.0; // standard CO2 partial pressure in blood; mmHg
const double pH0 = 7.24; // standard pH in RBCs; unitless
const double DPG0 = 4.65e-3; // standard 2; 3 - DPG concentration in RBCs; M
const double Temp0 = 37.0; // standard temperature in blood; degC
const double fact = 1.0e-6 / Wpl; // a multiplicative factor; M / mmHg
const double alphaO20 = fact*1.37; // solubility of O2 in water at 37 C; M / mmHg
const double alphaCO20 = fact*30.7; // solubility of CO2 in water at 37 C; M / mmHg
const double O20 = alphaO20*pO20; // standard O2 concentration in RBCs; M
const double CO20 = alphaCO20*pCO20; // standard CO2 concentration in RBCs; M
const double Hp0 = pow(10, (-pH0)); // standard H + concentration in RBCs; M
const double pHpl0 = pH0 - log10(Rrbc); // standard pH in plasma; unitless
const double P500 = 26.8 - 20*CO_sat; // standard pO2 at 50% SHbO2; mmHg
const double C500 = alphaO20*P500; // standard O2 concentration at 50 % SHbO2; M
const double Wbl = (1 - hematocrit)*Wpl + hematocrit*Wrbc;
const double pHpl = pH - log10(Rrbc);
const double pHpldiff = pHpl - pHpl0;
const double pHdiff = pH - pH0;
const double pCO2diff = CO2PartialPressureGuess_mmHg - pCO20;
const double DPGdiff = DPG - DPG0;
const double Tempdiff = temperature_C - Temp0;
const double alphaO2 = fact*(1.37 - 0.0137*Tempdiff + 0.00058*Tempdiff*Tempdiff);
const double alphaCO2 = fact*(30.7 - 0.57*Tempdiff + 0.02*Tempdiff*Tempdiff);
const double pK1 = 6.091 - 0.0434*pHpldiff + 0.0014*Tempdiff*pHpldiff;
const double K1 = pow(10, -pK1);
const double O2 = alphaO2*O2PartialPressureGuess_mmHg;
const double CO2 = alphaCO2*CO2PartialPressureGuess_mmHg;
const double Hp = pow(10, -pH);
const double Hppl = pow(10, -pHpl);
const double Term1 = K2p*(1 + K2dp / Hp);
const double Term2 = K3p*(1 + K3dp / Hp);
const double Term3 = (1 + Hp / K5dp);
const double Term4 = (1 + Hp / K6dp);
const double Term10 = K2p*(1 + K2dp / Hp0);
const double Term20 = K3p*(1 + K3dp / Hp0);
const double Term30 = (1 + Hp0 / K5dp);
const double Term40 = (1 + Hp0 / K6dp);
const double Kratio10 = (Term10*CO20 + Term30) / (Term20*CO20 + Term40);
const double Kratio11 = (Term1*CO20 + Term3) / (Term2*CO20 + Term4);
const double Kratio12 = (Term10*alphaCO20*CO2PartialPressureGuess_mmHg + Term30) / (Term20*alphaCO20*CO2PartialPressureGuess_mmHg + Term40);
const double K4dp = Kratio10*pow(O20, n0) / pow(C500, nhill);
const double K4tp = K4dp / pow(O20, n0);
const double Kratio20 = Kratio10 / K4tp; // = C500^nhill
const double Kratio21 = Kratio11 / K4tp;
const double Kratio22 = Kratio12 / K4tp;
const double P501 = 26.765 - 21.279*pHdiff + 8.872*pHdiff*pHdiff;
const double P502 = 26.80 + 0.0428*pCO2diff + 3.64e-5*pCO2diff*pCO2diff;
const double P503 = 26.78 + 795.633533*DPGdiff - 19660.8947*DPGdiff*DPGdiff;
const double P504 = 26.75 + 1.4945*Tempdiff + 0.04335*Tempdiff*Tempdiff + 0.0007*Tempdiff*Tempdiff*Tempdiff;
const double C501 = alphaO20*P501;
const double C502 = alphaO20*P502;
const double C503 = alphaO20*P503;
const double C504 = alphaO2*P504;
double n1 = 1.0;
double n2 = 1.0;
......
......@@ -616,22 +616,22 @@ void Tissue::CalculateMetabolicConsumptionAndProduction(double time_s)
// The following fractions are used to compute the metabolic conversion of substances.
// Stoichiometric ratios can be found in any physiology text, such as \cite guyton2006medical
double FractionOfO2CO2ToGlucose = 0.157894737; // Ratio of o2/co2 required to produce ATP for glucose consumption. = 6.0 / 38.0
double FractionOfO2ToLipid = 0.212239583; // Ratio of o2 required to produce ATP for lipid consumption. = 163.0 / 768.0;
double FractionOfCO2ToLipid = 0.1484375; // ratio of co2 required to produce ATP for lipid consumption. = 114.0 / 768.0;
const double FractionOfO2CO2ToGlucose = 0.157894737; // Ratio of o2/co2 required to produce ATP for glucose consumption. = 6.0 / 38.0
const double FractionOfO2ToLipid = 0.212239583; // Ratio of o2 required to produce ATP for lipid consumption. = 163.0 / 768.0;
const double FractionOfCO2ToLipid = 0.1484375; // ratio of co2 required to produce ATP for lipid consumption. = 114.0 / 768.0;
SEScalarPressure ppO2;
SEScalarMassPerVolume atConc;
ppO2.SetValue(40.0, PressureUnit::mmHg);
GeneralMath::CalculateHenrysLawConcentration(*m_O2, ppO2, atConc, m_Logger);
double anaerobicThresholdConcentration_mM = atConc.GetValue(MassPerVolumeUnit::g_Per_L) / m_O2->GetMolarMass(MassPerAmountUnit::g_Per_mmol);
double FractionOfGlucoseToATP = 0.026315789; // Ratio of glucose required to ATP produced. = 1.0 / 38.0;
double FractionOfLactateToGlucose = 0.5; // Ratio of glucose required to lactate produced during anaerobic metabolism. = 1.0 / 2.0;
double FractionOfAcetoacetateToATP = 0.041666667; // Ratio of acetoacetate required to ATP produced. = 1.0 / 24.0;
double FractionOfLactateToATP = 0.027777778; // Ratio of lactate required to ATP produced. = 1.0 / 36.0;
double FractionOfLipidToATP = 0.002604167; // Ratio of of lipid required to ATP produced. = 2.0 / 768.0;
double FractionLipidsAsTristearin = 0.256; // This is an empirically determined value specific to the Pulse implementation
double exerciseTuningFactor = 1.0; // 2.036237; // A tuning factor to adjust production and consumption during exercise
const double anaerobicThresholdConcentration_mM = atConc.GetValue(MassPerVolumeUnit::g_Per_L) / m_O2->GetMolarMass(MassPerAmountUnit::g_Per_mmol);
const double FractionOfGlucoseToATP = 0.026315789; // Ratio of glucose required to ATP produced. = 1.0 / 38.0;
const double FractionOfLactateToGlucose = 0.5; // Ratio of glucose required to lactate produced during anaerobic metabolism. = 1.0 / 2.0;
const double FractionOfAcetoacetateToATP = 0.041666667; // Ratio of acetoacetate required to ATP produced. = 1.0 / 24.0;
const double FractionOfLactateToATP = 0.027777778; // Ratio of lactate required to ATP produced. = 1.0 / 36.0;
const double FractionOfLipidToATP = 0.002604167; // Ratio of of lipid required to ATP produced. = 2.0 / 768.0;
const double FractionLipidsAsTristearin = 0.256; // This is an empirically determined value specific to the Pulse implementation
const double exerciseTuningFactor = 1.0; // 2.036237; // A tuning factor to adjust production and consumption during exercise
double insulinConc_ug_Per_L = m_data.GetSubstances().GetInsulin().GetBloodConcentration(MassPerVolumeUnit::ug_Per_L);
......
......@@ -76,19 +76,19 @@ void PulseEngineTest::AcidBaseMathTest(const std::string& rptDirectory)
SELiquidSubstanceQuantity* nHCO3 = cmpt.GetSubstanceQuantity(*HCO3);
SELiquidSubstanceQuantity* nHbCO2 = cmpt.GetSubstanceQuantity(*HbCO2);
double cmptVolume_mL = 100.0;
double normalTotalO2_mM = 6.2;
double normalTotalCO2_mM = 28.86;
const double cmptVolume_mL = 100.0;
const double normalTotalO2_mM = 6.2;
const double normalTotalCO2_mM = 28.86;
double currentTotalO2_mM;
double currentTotalCO2_mM;
double normalDissolvedCO2_gPerL = 0.05526; // 0.05526;
double normalDissolvedO2_gPerL = 0.004287; // 0.004287;
double normalBicarbonate_gPerL = 0.026*61.0168;
double normalHgb_mM = 1.55;
double percentNothingBound = 0.01;
double percentO2OnlyBound = 0.73;
double percentO2CO2Bound = 0.25;
double percentCO2Bound = 0.01;
const double normalDissolvedCO2_gPerL = 0.05526; // 0.05526;
const double normalDissolvedO2_gPerL = 0.004287; // 0.004287;
const double normalBicarbonate_gPerL = 0.026*61.0168;
const double normalHgb_mM = 1.55;
const double percentNothingBound = 0.01;
const double percentO2OnlyBound = 0.73;
const double percentO2CO2Bound = 0.25;
const double percentCO2Bound = 0.01;
//double O2ppGuess_mmHg = 100.0;
//double CO2ppGuess_mmHg = 1000.0*normalDissolvedCO2_gPerL/(44.01*0.0314);
//normalDissolvedCO2_gPerL = CO2ppGuess_mmHg*(44.01*0.0314) / 1000.0;
......@@ -572,16 +572,16 @@ void PulseEngineTest::AcidBaseLimitsTest(const std::string& rptDirectory)
c.CalculateBloodGasDistribution(cmpt);
// Get and print results
double finalDissovledCO2_gPerL = nCO2->GetConcentration().GetValue(MassPerVolumeUnit::g_Per_L);
double finalDissovledCO2_mM = finalDissovledCO2_gPerL / CO2->GetMolarMass(MassPerAmountUnit::g_Per_mmol);
double finalBicarb_gPerL = nHCO3->GetConcentration().GetValue(MassPerVolumeUnit::g_Per_L);
double finalBicarbCO2_mM = finalBicarb_gPerL / HCO3->GetMolarMass(MassPerAmountUnit::g_Per_mmol); // Yes this should be m_CO2_g_Per_mmol because 1 mol CO2 per mol bicarb
double finalBicarbCO2_gPerL = finalBicarbCO2_mM * CO2->GetMolarMass(MassPerAmountUnit::g_Per_mmol);
double finalBoundCO2_mM = 4.0 * (nHbCO2->GetMass().GetValue(MassUnit::g) / cmpt.GetVolume(VolumeUnit::L) / HbCO2->GetMolarMass(MassPerAmountUnit::g_Per_mmol) + nHbO2CO2->GetMass().GetValue(MassUnit::g) / cmpt.GetVolume(VolumeUnit::L) / HbO2CO2->GetMolarMass(MassPerAmountUnit::g_Per_mmol)); //4 moles CO2 per mole Hb
double finalBoundCO2_gPerL = finalBoundCO2_mM * CO2->GetMolarMass(MassPerAmountUnit::g_Per_mmol);
double finalTotalCO2_mM = finalDissovledCO2_mM + finalBicarbCO2_mM + finalBoundCO2_mM;
double finalTotalCO2_gPerL = finalDissovledCO2_gPerL + finalBicarbCO2_gPerL + finalBoundCO2_gPerL;
double finalTotalHemoglobin_gPerL = nHb->GetConcentration().GetValue(MassPerVolumeUnit::g_Per_L) +
finalDissovledCO2_gPerL = nCO2->GetConcentration().GetValue(MassPerVolumeUnit::g_Per_L);
finalDissovledCO2_mM = finalDissovledCO2_gPerL / CO2->GetMolarMass(MassPerAmountUnit::g_Per_mmol);
finalBicarb_gPerL = nHCO3->GetConcentration().GetValue(MassPerVolumeUnit::g_Per_L);
finalBicarbCO2_mM = finalBicarb_gPerL / HCO3->GetMolarMass(MassPerAmountUnit::g_Per_mmol); // Yes this should be m_CO2_g_Per_mmol because 1 mol CO2 per mol bicarb
finalBicarbCO2_gPerL = finalBicarbCO2_mM * CO2->GetMolarMass(MassPerAmountUnit::g_Per_mmol);
finalBoundCO2_mM = 4.0 * (nHbCO2->GetMass().GetValue(MassUnit::g) / cmpt.GetVolume(VolumeUnit::L) / HbCO2->GetMolarMass(MassPerAmountUnit::g_Per_mmol) + nHbO2CO2->GetMass().GetValue(MassUnit::g) / cmpt.GetVolume(VolumeUnit::L) / HbO2CO2->GetMolarMass(MassPerAmountUnit::g_Per_mmol)); //4 moles CO2 per mole Hb
finalBoundCO2_gPerL = finalBoundCO2_mM * CO2->GetMolarMass(MassPerAmountUnit::g_Per_mmol);
finalTotalCO2_mM = finalDissovledCO2_mM + finalBicarbCO2_mM + finalBoundCO2_mM;
finalTotalCO2_gPerL = finalDissovledCO2_gPerL + finalBicarbCO2_gPerL + finalBoundCO2_gPerL;
finalTotalHemoglobin_gPerL = nHb->GetConcentration().GetValue(MassPerVolumeUnit::g_Per_L) +
nHbO2->GetConcentration().GetValue(MassPerVolumeUnit::g_Per_L) +
nHbCO2->GetConcentration().GetValue(MassPerVolumeUnit::g_Per_L) +
nHbO2CO2->GetConcentration().GetValue(MassPerVolumeUnit::g_Per_L);
......@@ -896,7 +896,6 @@ void PulseEngineTest::AcidBaseBloodGasTest(PulseController& pc, bloodType bloodC
double CO2sat_max = 0; //Computed using Dash model
double pH_min = 0; //Leeuwen
double pH_max = 0; //Leeuwen
double percentTolerance = .02;
double O2_sat = 0;
double CO2_sat = 0;
......
......@@ -122,7 +122,6 @@ void PulseEngineTest::AnesthesiaMachineCircuitAndTransportTest(RespiratoryConfig
SEFluidCircuitPath* EnvironmentToVentilatorPath = amCircuit->GetPath(pulse::AnesthesiaMachinePath::EnvironmentToVentilator);
SEFluidCircuitPath* EnvironmentToReliefValve = amCircuit->GetPath(pulse::AnesthesiaMachinePath::EnvironmentToReliefValve);
SEFluidCircuitPath* GasSourceToGasInlet = amCircuit->GetPath(pulse::AnesthesiaMachinePath::GasSourceToGasInlet);
SEFluidCircuitPath* EnvironmentToGasSource = amCircuit->GetPath(pulse::AnesthesiaMachinePath::EnvironmentToGasSource);
SEGasTransporter txpt(VolumePerTimeUnit::L_Per_s, VolumeUnit::L, VolumeUnit::L, pc.GetLogger());
SEFluidCircuitCalculator calc(VolumePerPressureUnit::L_Per_cmH2O, VolumePerTimeUnit::L_Per_s, PressureTimeSquaredPerVolumeUnit::cmH2O_s2_Per_L, PressureUnit::cmH2O, VolumeUnit::L, PressureTimePerVolumeUnit::cmH2O_s_Per_L, pc.GetLogger());
......
......@@ -367,11 +367,6 @@ void PulseEngineTest::CardiovascularCircuitAndTransportTest(CardiovascularDriver
SEFluidCircuitNode* VenaCava = cvCircuit.GetNode("VenaCava");
SEFluidCircuitPath *RightCompliance = cvCircuit.GetPath(pulse::CardiovascularPath::RightHeart1ToRightHeart3);
SEFluidCircuitPath *LeftCompliance = cvCircuit.GetPath(pulse::CardiovascularPath::LeftHeart1ToLeftHeart3);
SEFluidCircuitPath *HeartLeft = cvCircuit.GetPath(pulse::CardiovascularPath::LeftHeart1ToAorta2);
SELiquidSubstanceQuantity* venaCavaN2 = cvGraph.GetCompartment(pulse::VascularCompartment::VenaCava)->GetSubstanceQuantity(pc.GetSubstances().GetN2());
SELiquidSubstanceQuantity* leftPulmonaryCapillariesN2 = cvGraph.GetCompartment(pulse::VascularCompartment::LeftPulmonaryCapillaries)->GetSubstanceQuantity(pc.GetSubstances().GetN2());
SELiquidSubstanceQuantity* rightPulmonaryCapillariesN2 = cvGraph.GetCompartment(pulse::VascularCompartment::LeftPulmonaryCapillaries)->GetSubstanceQuantity(pc.GetSubstances().GetN2());
SELiquidTransporter txpt(VolumePerTimeUnit::mL_Per_s, VolumeUnit::mL, MassUnit::ug, MassPerVolumeUnit::ug_Per_mL, pc.GetLogger());
SEFluidCircuitCalculator calc(VolumePerPressureUnit::mL_Per_mmHg, VolumePerTimeUnit::mL_Per_s, PressureTimeSquaredPerVolumeUnit::mmHg_s2_Per_mL, PressureUnit::mmHg, VolumeUnit::mL, PressureTimePerVolumeUnit::mmHg_s_Per_mL, pc.GetLogger());
......@@ -694,7 +689,7 @@ void PulseEngineTest::CardiovascularCircuitScaleTests(const std::string& sTestDi
// Note: You could scale the amplitude/elastance of the driver if want (We didn't at the time I wrote it, but its possible!)
double heartRate_bpm = 72;// Note, you should always pass in a bpm other than <=0 for a well named file
ss << heartRate_bpm;
double comp = 1.0, res = 1.0, vol = 1, sysRes = 1, sysComp = 1, aortaRes = 0.7, aortaComp = 0.7, venaRes = 1, venaComp = 1;
const double comp = 1.0, res = 1.0, vol = 1, sysRes = 1, sysComp = 1, aortaRes = 0.7, aortaComp = 0.7, venaRes = 1, venaComp = 1;
//for (double rFactor = 0.3; rFactor <= 1.7; rFactor += 0.1)
//{
......
......@@ -52,31 +52,31 @@ double TotalHbMols(SELiquidCompartmentGraph& Graph, SESubstance& Hb, SESubstance
return totalHb_g / Hb_g_Per_mol + totalHbO2_g / HbO2_g_Per_mol + totalHbCO2_g / HbCO2_g_Per_mol + totalHBO2CO2_g / HbO2CO2_g_Per_mol;
}
void PulseEngineTest::FourCompartmentTest(bool usingAcidBase, bool usingProductionConsumption, bool usingDiffusion, const std::string& rptDirectory)
void PulseEngineTest::FourCompartmentTest(bool localUsingAcidBase, bool localUsingProductionConsumption, bool localUsingDiffusion, const std::string& rptDirectory)
{
DataTrack trk;
std::string outputName;
if (!usingAcidBase && !usingProductionConsumption && !usingDiffusion)