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

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

Fix a series of warnings in the engine code

See merge request !73
parents ca9715b6 b78cbc88
......@@ -188,16 +188,20 @@ a.qindexHL {
border: 1px double #869DCA;
}
.contents a:visited {
color: #ffffff;
}
.contents a.qindexHL:visited {
color: #ffffff;
}
a.code, a.code:visited, a.line, a.line:visited {
color: #4665A2;
color: #ffffff;
}
a.codeRef, a.codeRef:visited, a.lineRef, a.lineRef:visited {
color: #4665A2;
color: #ffffff;
}
/* @end */
......
......@@ -206,16 +206,20 @@ a.qindexHL {
border: 1px double #869DCA;
}
.contents a:visited {
color: #ffffff;
}
.contents a.qindexHL:visited {
color: #ffffff;
}
a.code, a.code:visited, a.line, a.line:visited {
color: #4665A2;
color: #ffffff;
}
a.codeRef, a.codeRef:visited, a.lineRef, a.lineRef:visited {
color: #4665A2;
color: #ffffff;
}
/* @end */
......
......@@ -254,7 +254,6 @@ void SECircuitCalculator<CIRCUIT_CALCULATOR_TYPES>::ParseIn()
//The b matrix will have all of the right side values (known values) from the KCL equation
//Variables used in the loop
double dStartingCompliance = 0.0;
double dStartingInertance = 0.0;
for (NodeType* n : m_circuit->GetNodes())
{
//Sum of the flows at each node is 0
......
......@@ -101,17 +101,17 @@ SECircuitNode<CIRCUIT_NODE_TYPES>& SECircuitPath<CIRCUIT_PATH_TYPES>::GetTargetN
template<CIRCUIT_PATH_TEMPLATE>
bool SECircuitPath<CIRCUIT_PATH_TYPES>::HasValidElements() const
{
int numRCI = (HasResistance() ? 1 : 0) +
unsigned short numRCI = (HasResistance() ? 1 : 0) +
(HasCapacitance() ? 1 : 0) +
(HasInductance() ? 1 : 0);
int numNextRCI = (HasNextResistance() ? 1 : 0) +
unsigned short numNextRCI = (HasNextResistance() ? 1 : 0) +
(HasNextCapacitance() ? 1 : 0) +
(HasNextInductance() ? 1 : 0);
int numSrcState = (HasSwitch() ? 1 : 0) +
unsigned short numSrcState = (HasSwitch() ? 1 : 0) +
(HasValve() ? 1 : 0) +
(HasFluxSource() ? 1 : 0) +
(HasPotentialSource() ? 1 : 0);
int numNextSrcState = (HasNextSwitch() ? 1 : 0) +
unsigned short numNextSrcState = (HasNextSwitch() ? 1 : 0) +
(HasNextValve() ? 1 : 0) +
(HasNextFluxSource() ? 1 : 0) +
(HasNextPotentialSource() ? 1 : 0);
......
......@@ -77,9 +77,9 @@ inline bool CIEQUAL(std::string strA, std::string strB)
}
std::transform(strA.begin(), strA.end(), strA.begin(),
[](unsigned char c) { return std::tolower(c); });
[](std::string::value_type c) { return static_cast<std::string::value_type>(std::tolower(c)); });
std::transform(strB.begin(), strB.end(), strB.begin(),
[](unsigned char c) { return std::tolower(c); });
[](std::string::value_type c) { return static_cast<std::string::value_type>(std::tolower(c)); });
return strA == strB;
}
......
......@@ -573,10 +573,6 @@ void PulseSubstances::WriteBloodGases()
{
SELiquidSubstanceQuantity* O2 = cmpt->GetSubstanceQuantity(*m_O2);
SELiquidSubstanceQuantity* CO2 = cmpt->GetSubstanceQuantity(*m_CO2);
SELiquidSubstanceQuantity* Hb = cmpt->GetSubstanceQuantity(*m_Hb);
SELiquidSubstanceQuantity* HbO2 = cmpt->GetSubstanceQuantity(*m_HbO2);
SELiquidSubstanceQuantity* HbCO2 = cmpt->GetSubstanceQuantity(*m_HbCO2);
SELiquidSubstanceQuantity* HbO2CO2 = cmpt->GetSubstanceQuantity(*m_HbO2CO2);
SELiquidSubstanceQuantity* HCO3 = cmpt->GetSubstanceQuantity(*m_HCO3);
ss << "InitializeBloodGases(*cmpts.GetLiquidCompartment(pulse::VascularCompartment::" << cmpt->GetName() << "), Hb_total_mM, " << O2->GetSaturation() << ", " << O2->GetMolarity(AmountPerVolumeUnit::mmol_Per_L) << ", " << CO2->GetSaturation() << ", " << CO2->GetMolarity(AmountPerVolumeUnit::mmol_Per_L) << ", " << HCO3->GetMolarity(AmountPerVolumeUnit::mmol_Per_L) << ", " << cmpt->GetPH().GetValue() << ");";
......
......@@ -663,36 +663,36 @@ void Cardiovascular::PostProcess(bool solve_and_transport)
void Cardiovascular::CalculateVitalSigns()
{
// Grab data from the circuit in order to calculate a running mean
double AortaNodePressure_mmHg = m_Aorta->GetPressure(PressureUnit::mmHg);
double AortaNodeCO2PartialPressure_mmHg = m_AortaCO2 == nullptr ? 0 : m_AortaCO2->GetPartialPressure(PressureUnit::mmHg); // This is here so we can Tune circuit w/o substances
double LeftPulmonaryArteryVolume_mL = m_LeftPulmonaryArteries->GetVolume(VolumeUnit::mL);
double RightPulmonaryArteryVolume_mL = m_RightPulmonaryArteries->GetVolume(VolumeUnit::mL);
double TotalPulmonaryArteryVolume_mL = LeftPulmonaryArteryVolume_mL + RightPulmonaryArteryVolume_mL;
double LeftPulmonaryArteryPressure_mmHg = m_LeftPulmonaryArteries->GetPressure(PressureUnit::mmHg);
double RightPulmonaryArteryPressure_mmHg = m_RightPulmonaryArteries->GetPressure(PressureUnit::mmHg);
double LeftPulmonaryVeinVolume_mL = m_LeftPulmonaryVeins->GetVolume(VolumeUnit::mL);
double RightPulmonaryVeinVolume_mL = m_RightPulmonaryVeins->GetVolume(VolumeUnit::mL);
double TotalPulmonaryVeinVolume_mL = LeftPulmonaryVeinVolume_mL + RightPulmonaryVeinVolume_mL;
double LeftPulmonaryVeinPressure_mmHg = m_LeftPulmonaryVeins->GetPressure(PressureUnit::mmHg);
double RightPulmonaryVeinPressure_mmHg = m_RightPulmonaryVeins->GetPressure(PressureUnit::mmHg);
double PulmonaryArteryNodePressure_mmHg = (LeftPulmonaryArteryVolume_mL*LeftPulmonaryArteryPressure_mmHg + RightPulmonaryArteryVolume_mL*RightPulmonaryArteryPressure_mmHg) / TotalPulmonaryArteryVolume_mL;
double PulmVeinNodePressure_mmHg = (LeftPulmonaryVeinVolume_mL*LeftPulmonaryVeinPressure_mmHg + RightPulmonaryVeinVolume_mL*RightPulmonaryVeinPressure_mmHg) / TotalPulmonaryVeinVolume_mL;
double PulmCapFlow_mL_Per_s = m_LeftPulmonaryArteriesToCapillaries->GetNextFlow(VolumePerTimeUnit::mL_Per_s)
+ m_RightPulmonaryArteriesToCapillaries->GetNextFlow(VolumePerTimeUnit::mL_Per_s);
double PulmShuntFlow_mL_Per_s = m_LeftPulmonaryArteriesToVeins->GetNextFlow(VolumePerTimeUnit::mL_Per_s)
+ m_RightPulmonaryArteriesToVeins->GetNextFlow(VolumePerTimeUnit::mL_Per_s);
double VenaCavaPressure_mmHg = m_VenaCava->GetPressure(PressureUnit::mmHg);
double SkinFlow_mL_Per_s = m_pAortaToSkin->GetNextFlow(VolumePerTimeUnit::mL_Per_s);
double LHeartFlow_mL_Per_s = m_LeftHeartToAorta->GetNextFlow(VolumePerTimeUnit::mL_Per_s);
double LHeartVolume_mL = m_LeftHeart->GetVolume(VolumeUnit::mL);
double muscleFlow_mL_Per_s = m_pAortaToMuscle->GetNextFlow(VolumePerTimeUnit::mL_Per_s);
double gutFlow_mL_Per_s = m_pAortaToLargeIntestine->GetNextFlow(VolumePerTimeUnit::mL_Per_s) +
const double AortaNodePressure_mmHg = m_Aorta->GetPressure(PressureUnit::mmHg);
const double AortaNodeCO2PartialPressure_mmHg = m_AortaCO2 == nullptr ? 0 : m_AortaCO2->GetPartialPressure(PressureUnit::mmHg); // This is here so we can Tune circuit w/o substances
const double LeftPulmonaryArteryVolume_mL = m_LeftPulmonaryArteries->GetVolume(VolumeUnit::mL);
const double RightPulmonaryArteryVolume_mL = m_RightPulmonaryArteries->GetVolume(VolumeUnit::mL);
const double TotalPulmonaryArteryVolume_mL = LeftPulmonaryArteryVolume_mL + RightPulmonaryArteryVolume_mL;
const double LeftPulmonaryArteryPressure_mmHg = m_LeftPulmonaryArteries->GetPressure(PressureUnit::mmHg);
const double RightPulmonaryArteryPressure_mmHg = m_RightPulmonaryArteries->GetPressure(PressureUnit::mmHg);
const double LeftPulmonaryVeinVolume_mL = m_LeftPulmonaryVeins->GetVolume(VolumeUnit::mL);
const double RightPulmonaryVeinVolume_mL = m_RightPulmonaryVeins->GetVolume(VolumeUnit::mL);
const double TotalPulmonaryVeinVolume_mL = LeftPulmonaryVeinVolume_mL + RightPulmonaryVeinVolume_mL;
const double LeftPulmonaryVeinPressure_mmHg = m_LeftPulmonaryVeins->GetPressure(PressureUnit::mmHg);
const double RightPulmonaryVeinPressure_mmHg = m_RightPulmonaryVeins->GetPressure(PressureUnit::mmHg);
const double PulmonaryArteryNodePressure_mmHg = (LeftPulmonaryArteryVolume_mL*LeftPulmonaryArteryPressure_mmHg + RightPulmonaryArteryVolume_mL*RightPulmonaryArteryPressure_mmHg) / TotalPulmonaryArteryVolume_mL;
const double PulmVeinNodePressure_mmHg = (LeftPulmonaryVeinVolume_mL*LeftPulmonaryVeinPressure_mmHg + RightPulmonaryVeinVolume_mL*RightPulmonaryVeinPressure_mmHg) / TotalPulmonaryVeinVolume_mL;
const double PulmCapFlow_mL_Per_s = m_LeftPulmonaryArteriesToCapillaries->GetNextFlow(VolumePerTimeUnit::mL_Per_s)
+ m_RightPulmonaryArteriesToCapillaries->GetNextFlow(VolumePerTimeUnit::mL_Per_s);
const double PulmShuntFlow_mL_Per_s = m_LeftPulmonaryArteriesToVeins->GetNextFlow(VolumePerTimeUnit::mL_Per_s)
+ m_RightPulmonaryArteriesToVeins->GetNextFlow(VolumePerTimeUnit::mL_Per_s);
const double VenaCavaPressure_mmHg = m_VenaCava->GetPressure(PressureUnit::mmHg);
const double SkinFlow_mL_Per_s = m_pAortaToSkin->GetNextFlow(VolumePerTimeUnit::mL_Per_s);
const double LHeartFlow_mL_Per_s = m_LeftHeartToAorta->GetNextFlow(VolumePerTimeUnit::mL_Per_s);
const double LHeartVolume_mL = m_LeftHeart->GetVolume(VolumeUnit::mL);
const double muscleFlow_mL_Per_s = m_pAortaToMuscle->GetNextFlow(VolumePerTimeUnit::mL_Per_s);
const double gutFlow_mL_Per_s = m_pAortaToLargeIntestine->GetNextFlow(VolumePerTimeUnit::mL_Per_s) +
m_pAortaToSmallIntestine->GetNextFlow(VolumePerTimeUnit::mL_Per_s) +
m_pAortaToSplanchnic->GetNextFlow(VolumePerTimeUnit::mL_Per_s);
......@@ -995,7 +995,6 @@ void Cardiovascular::Hemorrhage()
SEHemorrhage* h;
bool completeStateChange = false;
double TotalLossRate_mL_Per_s = 0.0;
double internal_rate_mL_Per_s = 0.0;
std::vector<SEHemorrhage*> invalid_hemorrhages;
const std::map <std::string, SEHemorrhage*>& hems = m_data.GetActions().GetPatientActions().GetHemorrhages();
//Loop over all hemorrhages to check for validity
......@@ -1219,7 +1218,7 @@ void Cardiovascular::Hemorrhage()
//Add bleed link for transport
//Find the source compartment (may be a leaf) to make the graph work (i.e., to transport)
SELiquidCompartment* sourceCompartment;
SELiquidCompartment* sourceCompartment = nullptr;
if (std::find(compartment->GetNodeMapping().GetNodes().begin(), compartment->GetNodeMapping().GetNodes().end(), node) != compartment->GetNodeMapping().GetNodes().end())
{
sourceCompartment = compartment;
......@@ -1236,6 +1235,8 @@ void Cardiovascular::Hemorrhage()
}
}
}
if (sourceCompartment == nullptr) Fatal("Unable to find the correct source compartment.");
SELiquidCompartmentLink& newHemorrhageLink = m_data.GetCompartments().CreateLiquidLink(*sourceCompartment, *m_Groundcmpt, compartment->GetName() + "Hemorrhage");
newHemorrhageLink.MapPath(*newHemorrhagePath);
......@@ -1360,7 +1361,6 @@ void Cardiovascular::PericardialEffusion()
double flowCubed_mL3_Per_s3 = 0.0;
double compliance_mL_Per_mmHg = 0.0;
double intrapericardialVolume_mL = m_Pericardium->GetVolume(VolumeUnit::mL);
double intrapericardialPressure_mmHg = m_Pericardium->GetPressure(PressureUnit::mmHg);
double effusionRate_mL_Per_s = m_data.GetActions().GetPatientActions().GetPericardialEffusion()->GetEffusionRate().GetValue(VolumePerTimeUnit::mL_Per_s);
if (effusionRate_mL_Per_s <= 0.1 && effusionRate_mL_Per_s > 0.0)
......@@ -1793,10 +1793,10 @@ void Cardiovascular::MetabolicToneResponse()
double coreTempDelta_degC = MAX(coreTemp_degC - coreTempSet_degC, 0.0);
coreTempDelta_degC = MIN(coreTempDelta_degC, 1.0); //A 1 degree increase in core temperature is the where the cardiovascular response on resistances is capped
//The skin multiplier is used to increase the skin blood flow resistance, effectively reducing the skin blood flow leading to less heat transfered from core to skin.
double skinMultiplier = 1.0 / MAX((coreTemp_degC - 35.0), 0.001);
double coreTempLow_degC = m_data.GetConfiguration().GetCoreTemperatureLow(TemperatureUnit::C); //36.8 degC
//double skinMultiplier = 1.0 / MAX((coreTemp_degC - 35.0), 0.001);
//double coreTempLow_degC = m_data.GetConfiguration().GetCoreTemperatureLow(TemperatureUnit::C); //36.8 degC
/// \cite talebipour2006sauna
double tempMultiplier = 1.0 - 0.4*MIN(coreTempDelta_degC, 1.0); //Approximate 40% reduction in peripheral resistance due to core temperature rise of 1 degree.
// double tempMultiplier = 1.0 - 0.4*MIN(coreTempDelta_degC, 1.0); //Approximate 40% reduction in peripheral resistance due to core temperature rise of 1 degree.
double metabolicModifier = 1.0;
//The metabolic multiplier is used as a tuned response to represent cardiovascular resistance effects during exercise
double sp0 = 1.5;
......@@ -1809,7 +1809,6 @@ void Cardiovascular::MetabolicToneResponse()
//Reducing resistances scaling with metabolic rate increase and changes in core temperature
double resistanceNew__mmHg_s_Per_mL = 0.0;
double complianceNew_mL_Per_mmHg = 0.0;
for (SEFluidCircuitPath* Path : m_systemicResistancePaths)
{
......@@ -1854,8 +1853,7 @@ void Cardiovascular::AdjustVascularTone()
//The baroreceptor response adjusts the systemic resistances and compliances according to the multiplier calculated in Nervous.cpp
double UpdatedResistance_mmHg_s_Per_mL = 0.0;
double UpdatedCompliance_mL_Per_mmHg = 0.0;
double totalResistanceChange_mmHg_s_Per_mL = 0.0;
double totalComplianceChange_mL_Per_mmHg = 0.0;
if (m_data.GetNervous().GetBaroreceptorFeedback() == eSwitch::On)
{
for (SEFluidCircuitPath* Path : m_systemicResistancePaths)
......@@ -2028,7 +2026,7 @@ void Cardiovascular::TuneCircuit()
double systolic_mmHg = 0, tgt_systolic_mmHg = 0;
double diastolic_mmHg = 0, tgt_diastolic_mmHg = 0;
double cardiacOutput_mL_Per_min = 0, tgt_cardiacOutput_mL_Per_min = 0;
double meanCVP_mmHg = 0, tgt_meanCVP_mmHg = 0;
double meanCVP_mmHg = 0;
double blood_mL = 0, tgt_blood_mL = 0;
double time_s = 0;
......@@ -2367,9 +2365,9 @@ void Cardiovascular::TuneTissue(double time_s, DataTrack& circuitTrk, std::ofstr
}
// Tuning variables
double pressuretolerance = 0.01;
double stabPercentTolerance = 0.25;
double stabCheckTime_s = 15.0;
const double pressuretolerance = 0.01;
const double stabPercentTolerance = 0.25;
const double stabCheckTime_s = 15.0;
double currentStableTime_s;
double maxStableTime_s = 20;
......
......@@ -315,7 +315,6 @@ void Drugs::AdministerSubstanceCompoundInfusion()
SESubstanceCompoundInfusion* infusion;
const SESubstanceCompound* compound;
SELiquidSubstanceQuantity* subQ;
double concentration_ug_Per_mL=0;
double rate_mL_Per_s = 0;
double totalRate_mL_Per_s = 0;
double massIncrement_ug=0;
......@@ -351,7 +350,7 @@ void Drugs::AdministerSubstanceCompoundInfusion()
for (const SESubstanceConcentration* component : compound->GetComponents())
{
subQ = m_venaCavaVascular->GetSubstanceQuantity(component->GetSubstance());
double massIncrement_ug = rate_mL_Per_s*component->GetConcentration(MassPerVolumeUnit::ug_Per_mL)*m_dt_s;
massIncrement_ug = rate_mL_Per_s*component->GetConcentration(MassPerVolumeUnit::ug_Per_mL)*m_dt_s;
subQ->GetMass().IncrementValue(massIncrement_ug, MassUnit::ug);
subQ->Balance(BalanceLiquidBy::Mass);
}
......@@ -393,7 +392,6 @@ void Drugs::CalculatePartitionCoefficients()
double IntracellularPHEffects = 0;
double PlasmaPHEffects = 0;
double PHEffectPower = 0;
double PHEffects = 0;
double EquationPartA = 0;
double EquationPartB = 0;
double EquationPartC = 0;
......
......@@ -301,9 +301,8 @@ void Nervous::BaroreceptorFeedback()
//update nu - the slope response of the firing rate
//nu *= (1 - sedationDampeningEffect); TODO: Add this back when I have data for validation
//Backout the pressure associated with the total sympathetic fraction from the last time step
double cumulativeMeanArterialPressure_mmHg = pow(((1.0 / m_TotalSympatheticFraction) - 1.0), (1.0 / nu)) * meanArterialPressureCombinedBaseline_mmHg;
double deltaPressure_mmHg = meanArterialPressure_mmHg - m_LastMeanArterialPressure_mmHg;
double baroreceptorPressure_mmHg = cumulativeMeanArterialPressure_mmHg + deltaPressure_mmHg;
// double cumulativeMeanArterialPressure_mmHg = pow(((1.0 / m_TotalSympatheticFraction) - 1.0), (1.0 / nu)) * meanArterialPressureCombinedBaseline_mmHg;
// double deltaPressure_mmHg = meanArterialPressure_mmHg - m_LastMeanArterialPressure_mmHg;
m_TotalSympatheticFraction = 1.0 / (1.0 + pow( meanArterialPressure_mmHg / meanArterialPressureCombinedBaseline_mmHg, nu));
double parasympatheticFraction = 1.0 - m_TotalSympatheticFraction;
m_LastMeanArterialPressure_mmHg = meanArterialPressure_mmHg;
......
......@@ -515,9 +515,9 @@ void Renal::PostProcess(bool solve_and_transport)
//--------------------------------------------------------------------------------------------------
void Renal::CalculateUltrafiltrationFeedback()
{
//Tuning parameters
double glomerularOsmoticSensitivity = 1.0;
double bowmansOsmoticSensitivity = 1.0;
//Tuning parameters unused
const double glomerularOsmoticSensitivity = 1.0;
const double bowmansOsmoticSensitivity = 1.0;
//Get substances
SEFluidCircuitPath* glomerularOsmoticSourcePath = nullptr;
......@@ -583,9 +583,9 @@ void Renal::CalculateUltrafiltrationFeedback()
//--------------------------------------------------------------------------------------------------
void Renal::CalculateReabsorptionFeedback()
{
//Tuning parameters
double peritubularOsmoticSensitivity = 1.0;
double tubulesOsmoticSensitivity = 1.0;
//Tuning parameters, unused
const double peritubularOsmoticSensitivity = 1.0;
const double tubulesOsmoticSensitivity = 1.0;
//Determine the permeability
//Only allow water to be reabsorbed more easily
......@@ -630,7 +630,7 @@ void Renal::CalculateReabsorptionFeedback()
//Set the filter resistance based on its physical properties
//This is the Capillary Filtration Coefficient
//We'll just assume this linear relationship for now
double filterResistance_mmHg_s_Per_mL = filterResistancePath->GetNextResistance().GetValue(PressureTimePerVolumeUnit::mmHg_s_Per_mL);
filterResistance_mmHg_s_Per_mL = filterResistancePath->GetNextResistance().GetValue(PressureTimePerVolumeUnit::mmHg_s_Per_mL);
if (permeability_mL_Per_s_Per_mmHg_Per_m2 != 0 && surfaceArea_m2 != 0)
filterResistance_mmHg_s_Per_mL = 1 / (permeability_mL_Per_s_Per_mmHg_Per_m2 * surfaceArea_m2);
else
......@@ -661,11 +661,8 @@ void Renal::CalculateReabsorptionFeedback()
void Renal::CalculateGluconeogenesis()
{
//Whatever Lactate shows up in the Ureter (i.e. what's excreted) is converted to Glucose and put in the TubularCapillaries (i.e. reabsorbed)
SEFluidCircuitNode* tubulesNode = nullptr;
SELiquidSubstanceQuantity* peritubularGlucose = nullptr;
SELiquidSubstanceQuantity* ureterLactate = nullptr;
SEFluidCircuitPath* reabsorptionResistancePath = nullptr;
double totalReabsorptionRate_mg_Per_s = 0.0;
double totalLactateExcretionRate_mg_Per_s = 0.0;
......@@ -772,7 +769,6 @@ void Renal::CalculateActiveTransport()
m_SubstanceTransport.leftGlucoseReabsorptionMass_mg = 0.0;
m_SubstanceTransport.rightGlucoseReabsorptionMass_mg = 0.0;
unsigned int i = 0;
for (SESubstance* sub : m_data.GetCompartments().GetLiquidCompartmentSubstances())
{
if (!sub->HasClearance())
......@@ -1835,7 +1831,6 @@ void Renal::CalculateTubuloglomerularFeedback()
//Get substances and appropriate paths and node which will be utilized in this implementation
SEFluidCircuitPath* tubulesPath = nullptr;
SEFluidCircuitPath* afferentResistancePath = nullptr;
SEFluidCircuitNode* renalArteryNode = nullptr;
//set sodium flow to initially be zero
double sodiumFlow_mg_Per_s = 0.0;
......
......@@ -415,18 +415,17 @@ void Tissue::CalculateDiffusion()
// Sodium is special. We need to diffuse for renal function.
// We will not treat sodium any differently once diffusion functionality is fully implemented.
if (sub == m_Sodium)
double moved_ug = MoveMassByInstantDiffusion(*vascular, extracellular, *sub, m_dt_s);
MoveMassByInstantDiffusion(*vascular, extracellular, *sub, m_dt_s);
continue;
}
double moved_ug;
/////////////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////// Vascular to Extravascular-Extracellular /////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// --- First, instant diffusion ---
moved_ug = MoveMassByInstantDiffusion(*vascular, extracellular, *sub, m_dt_s);
MoveMassByInstantDiffusion(*vascular, extracellular, *sub, m_dt_s);
// --- Second, simple diffusion ---
// Compute the vascular to extracellular permeability coefficient
......@@ -444,7 +443,7 @@ void Tissue::CalculateDiffusion()
double vToECpermeabilityCoefficient_mL_Per_s = vToECpermeabilityCoefficient_mL_Per_s_g * tissue->GetTotalMass(MassUnit::g);
// A tuning factor helps tune the dynamics - note that concentrations will ALWAYS equilibrate in steady state given enough time regardless of the permeability
double vToECPermeabilityTuningFactor = 1.0;
moved_ug = MoveMassBySimpleDiffusion(*vascular, extracellular, *sub, vToECPermeabilityTuningFactor*vToECpermeabilityCoefficient_mL_Per_s, m_dt_s);
MoveMassBySimpleDiffusion(*vascular, extracellular, *sub, vToECPermeabilityTuningFactor*vToECpermeabilityCoefficient_mL_Per_s, m_dt_s);
// --- Third facilitated diffusion ---
if (sub->HasMaximumDiffusionFlux())
......@@ -453,13 +452,13 @@ void Tissue::CalculateDiffusion()
double capCoverage_cm2 = massToAreaCoefficient_cm2_Per_g * tissue->GetTotalMass(MassUnit::g);
double maximumMassFlux = sub->GetMaximumDiffusionFlux(MassPerAreaTimeUnit::g_Per_cm2_s);
double combinedCoefficient_g_Per_s = maximumMassFlux*capCoverage_cm2;
moved_ug = MoveMassByFacilitatedDiffusion(*vascular, extracellular, *sub, combinedCoefficient_g_Per_s, m_dt_s);
MoveMassByFacilitatedDiffusion(*vascular, extracellular, *sub, combinedCoefficient_g_Per_s, m_dt_s);
}
// --- Fourth, and final vascular to EV-EC, Active diffusion ---
double pumpRate_g_Per_s = 0.0;
/// \todo Compute the pump rate from an empirically-determined baseline pump rate.
moved_ug = MoveMassByActiveTransport(*vascular, extracellular, *sub, pumpRate_g_Per_s, m_dt_s);
MoveMassByActiveTransport(*vascular, extracellular, *sub, pumpRate_g_Per_s, m_dt_s);
#ifdef PROBE_BLOOD_GASES
if (sub == &m_data.GetSubstances().GetO2() || sub == &m_data.GetSubstances().GetCO2())
......@@ -475,12 +474,12 @@ void Tissue::CalculateDiffusion()
/////////////////////////////////////////////////////////////////////////////////////////////////////////
// --- First, instant diffusion ---
moved_ug = MoveMassByInstantDiffusion(extracellular, intracellular, *sub, m_dt_s);
MoveMassByInstantDiffusion(extracellular, intracellular, *sub, m_dt_s);
// --- Second, simple diffusion ---
// Assuming that the capillary permeability coefficient is proportional to the cellular membrane permeability coefficient for a given tissue and substance
double ECtoICPermeabilityFactor = 1.0; // This is the permeability constant
moved_ug = MoveMassBySimpleDiffusion(extracellular, intracellular, *sub, ECtoICPermeabilityFactor*vToECpermeabilityCoefficient_mL_Per_s, m_dt_s);
MoveMassBySimpleDiffusion(extracellular, intracellular, *sub, ECtoICPermeabilityFactor*vToECpermeabilityCoefficient_mL_Per_s, m_dt_s);
// --- Third facilitated diffusion ---
// In Pulse, only glucose moves by facilitated diffusion, and it is assumed that all glucose that gets to the
......@@ -490,7 +489,7 @@ void Tissue::CalculateDiffusion()
// --- Fourth, and final vascular to EV-EC, Active diffusion ---
pumpRate_g_Per_s = 0.0;
/// \todo Compute the pump rate from an empirically-determined baseline pump rate.
moved_ug = MoveMassByActiveTransport(extracellular, intracellular, *sub, pumpRate_g_Per_s, m_dt_s);
MoveMassByActiveTransport(extracellular, intracellular, *sub, pumpRate_g_Per_s, m_dt_s);
#ifdef PROBE_BLOOD_GASES
if (sub == &m_data.GetSubstances().GetO2() || sub == &m_data.GetSubstances().GetCO2())
......@@ -998,7 +997,7 @@ void Tissue::GlucoseLipidControl(double time_s)
double bloodLipidDelta_mg_Per_mL = (currentBloodLipid_mg_Per_mL - m_RestingBloodLipid_mg_Per_mL);
double insulinFeedback = currentInsulinConcentration_mg_Per_mL / m_RestingBloodInsulin_mg_Per_mL;
double massDelta_mg = 0.0;
double evFlow_mL_Per_s = 0.0;
double vascularVolume = 0.0;
double extravascularVolume = 0.0;
double transferTimeConstant_per_s = 0.1;
......@@ -1163,13 +1162,10 @@ void Tissue::DistributeMassbyVolumeWeighted(SELiquidCompartment& cmpt, const SES
if (mass == 0)
return;
SELiquidSubstanceQuantity* subQ = cmpt.GetSubstanceQuantity(sub);
if (mass < 0.0)
if (mass < 0.0 && -mass > subQ->GetMass(unit))
{
if (-mass > subQ->GetMass(unit))
{
mass = -subQ->GetMass(unit);
Info("The amount of mass decrement to distribute by volume weighted was greater than available. High probability of negative mass. DistributeMassbyMassWeighted is preferred for decrements.");
}
}
if (!cmpt.HasChildren())
......@@ -1186,11 +1182,11 @@ void Tissue::DistributeMassbyVolumeWeighted(SELiquidCompartment& cmpt, const SES
for (SELiquidCompartment* leaf : cmpt.GetLeaves())
{
double leafMass = mass * (leaf->GetVolume(VolumeUnit::mL) / volume_mL);
SELiquidSubstanceQuantity* subQ = leaf->GetSubstanceQuantity(sub);
subQ->GetMass().IncrementValue(leafMass, unit);
if (std::abs(subQ->GetMass(MassUnit::ug)) < ZERO_APPROX)
SELiquidSubstanceQuantity* leafSubQ = leaf->GetSubstanceQuantity(sub);
leafSubQ->GetMass().IncrementValue(leafMass, unit);
if (std::abs(leafSubQ->GetMass(MassUnit::ug)) < ZERO_APPROX)
{
subQ->GetMass().SetValue(0.0, MassUnit::ug);
leafSubQ->GetMass().SetValue(0.0, MassUnit::ug);
}
}
}
......@@ -1231,16 +1227,16 @@ void Tissue::DistributeMassbyMassWeighted(SELiquidCompartment& cmpt, const SESub
double mass_ug = subQ->GetMass(MassUnit::ug);
for (SELiquidCompartment* leaf : cmpt.GetLeaves())
{
SELiquidSubstanceQuantity* subQ = leaf->GetSubstanceQuantity(sub);
SELiquidSubstanceQuantity* leafSubQ = leaf->GetSubstanceQuantity(sub);
double leafMass = 0.0;
if (mass_ug != 0.0)
{
leafMass = mass * (subQ->GetMass(MassUnit::ug) / mass_ug);
leafMass = mass * (leafSubQ->GetMass(MassUnit::ug) / mass_ug);
}
subQ->GetMass().IncrementValue(leafMass, unit);
if (std::abs(subQ->GetMass(MassUnit::ug)) < ZERO_APPROX)
leafSubQ->GetMass().IncrementValue(leafMass, unit);
if (std::abs(leafSubQ->GetMass(MassUnit::ug)) < ZERO_APPROX)
{
subQ->GetMass().SetValue(0.0, MassUnit::ug);
leafSubQ->GetMass().SetValue(0.0, MassUnit::ug);
}
}
}
......@@ -1466,8 +1462,6 @@ double Tissue::MoveMassByInstantDiffusion(SELiquidCompartment& source, SELiquidC
const SELiquidSubstanceQuantity* srcQ = source.GetSubstanceQuantity(sub);
const SELiquidSubstanceQuantity* tgtQ = target.GetSubstanceQuantity(sub);
double sConc_ug = srcQ->GetMass(MassUnit::ug);
double tConc_ug = tgtQ->GetMass(MassUnit::ug);
double sConc_ug_Per_mL = srcQ->GetConcentration(MassPerVolumeUnit::ug_Per_mL);
double tConc_ug_Per_mL = tgtQ->GetConcentration(MassPerVolumeUnit::ug_Per_mL);
double sVol_mL = source.GetVolume(VolumeUnit::mL);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment