Skip to content

Commit dc68d3a

Browse files
ntatum94StevenAWhite
authored andcommitted
More tuning and cleaning up some code. Ready for VandV run
1 parent 309bc45 commit dc68d3a

File tree

4 files changed

+26
-51
lines changed

4 files changed

+26
-51
lines changed

projects/biogears/libBiogears/include/biogears/engine/Systems/Energy.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,12 +101,6 @@ class BIOGEARS_API Energy : public SEEnergySystem, public BioGearsSystem {
101101
bool m_packOn;
102102
double m_previousWeightPack_kg;
103103

104-
double m_test;
105-
double m_test1;
106-
double m_test2;
107-
double m_test3;
108-
double m_test4;
109-
110104
// Stateless member variable (Set in SetUp())
111105
double m_dT_s;
112106
SEPatient* m_Patient;

projects/biogears/libBiogears/src/engine/Controller/BioGears.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5614,25 +5614,25 @@ void BioGears::SetupInternalTemperature()
56145614
SEThermalCircuitNode& LeftArmSkin = cIntemperature.CreateNode(BGE::InternalTemperatureNode::InternalLeftArmSkin);
56155615
LeftArmSkin.GetTemperature().SetValue(33.0, TemperatureUnit::C);
56165616
SEThermalCircuitPath& LeftArmSkinToTemperatureGround = cIntemperature.CreatePath(LeftArmSkin, Ground, BGE::InternalTemperaturePath::InternalLeftArmSkinToTemperatureGround);
5617-
LeftArmSkinToTemperatureGround.GetCapacitanceBaseline().SetValue(1.3 * 5.46, HeatCapacitanceUnit::kcal_Per_C);
5617+
LeftArmSkinToTemperatureGround.GetCapacitanceBaseline().SetValue(1.3 * 2.73, HeatCapacitanceUnit::kcal_Per_C);
56185618
LeftArmSkin.GetHeatBaseline().SetValue(LeftArmSkinToTemperatureGround.GetCapacitanceBaseline().GetValue(HeatCapacitanceUnit::J_Per_K) * LeftArmSkin.GetTemperature().GetValue(TemperatureUnit::K), EnergyUnit::J);
56195619

56205620
SEThermalCircuitNode& RightArmSkin = cIntemperature.CreateNode(BGE::InternalTemperatureNode::InternalRightArmSkin);
56215621
RightArmSkin.GetTemperature().SetValue(33.0, TemperatureUnit::C);
56225622
SEThermalCircuitPath& RightArmSkinToTemperatureGround = cIntemperature.CreatePath(RightArmSkin, Ground, BGE::InternalTemperaturePath::InternalRightArmSkinToTemperatureGround);
5623-
RightArmSkinToTemperatureGround.GetCapacitanceBaseline().SetValue(1.3 * 5.46, HeatCapacitanceUnit::kcal_Per_C);
5623+
RightArmSkinToTemperatureGround.GetCapacitanceBaseline().SetValue(1.3 * 2.73, HeatCapacitanceUnit::kcal_Per_C);
56245624
RightArmSkin.GetHeatBaseline().SetValue(RightArmSkinToTemperatureGround.GetCapacitanceBaseline().GetValue(HeatCapacitanceUnit::J_Per_K) * RightArmSkin.GetTemperature().GetValue(TemperatureUnit::K), EnergyUnit::J);
56255625

56265626
SEThermalCircuitNode& LeftLegSkin = cIntemperature.CreateNode(BGE::InternalTemperatureNode::InternalLeftLegSkin);
56275627
LeftLegSkin.GetTemperature().SetValue(33.0, TemperatureUnit::C);
56285628
SEThermalCircuitPath& LeftLegSkinToTemperatureGround = cIntemperature.CreatePath(LeftLegSkin, Ground, BGE::InternalTemperaturePath::InternalLeftLegSkinToTemperatureGround);
5629-
LeftLegSkinToTemperatureGround.GetCapacitanceBaseline().SetValue(1.3 * 15.92, HeatCapacitanceUnit::kcal_Per_C);
5629+
LeftLegSkinToTemperatureGround.GetCapacitanceBaseline().SetValue(1.3 * 7.96, HeatCapacitanceUnit::kcal_Per_C);
56305630
LeftLegSkin.GetHeatBaseline().SetValue(LeftLegSkinToTemperatureGround.GetCapacitanceBaseline().GetValue(HeatCapacitanceUnit::J_Per_K) * LeftLegSkin.GetTemperature().GetValue(TemperatureUnit::K), EnergyUnit::J);
56315631

56325632
SEThermalCircuitNode& RightLegSkin = cIntemperature.CreateNode(BGE::InternalTemperatureNode::InternalRightLegSkin);
56335633
RightLegSkin.GetTemperature().SetValue(33.0, TemperatureUnit::C);
56345634
SEThermalCircuitPath& RightLegSkinToTemperatureGround = cIntemperature.CreatePath(RightLegSkin, Ground, BGE::InternalTemperaturePath::InternalRightLegSkinToTemperatureGround);
5635-
RightLegSkinToTemperatureGround.GetCapacitanceBaseline().SetValue(1.3 * 15.92, HeatCapacitanceUnit::kcal_Per_C);
5635+
RightLegSkinToTemperatureGround.GetCapacitanceBaseline().SetValue(1.3 * 7.96, HeatCapacitanceUnit::kcal_Per_C);
56365636
RightLegSkin.GetHeatBaseline().SetValue(RightLegSkinToTemperatureGround.GetCapacitanceBaseline().GetValue(HeatCapacitanceUnit::J_Per_K) * RightLegSkin.GetTemperature().GetValue(TemperatureUnit::K), EnergyUnit::J);
56375637

56385638
// Only using basal values for now - See if this is worth it
@@ -5641,29 +5641,29 @@ void BioGears::SetupInternalTemperature()
56415641
SEThermalCircuitPath& TemperatureGroundToSkinHead = cIntemperature.CreatePath(Ground, HeadSkin, BGE::InternalTemperaturePath::GroundToInternalHeadSkin);
56425642
TemperatureGroundToSkinHead.GetHeatSourceBaseline().SetValue(0.29, PowerUnit::kcal_Per_hr);
56435643
SEThermalCircuitPath& TemperatureGroundToSkinLeftArm = cIntemperature.CreatePath(Ground, LeftArmSkin, BGE::InternalTemperaturePath::GroundToInternalLeftArmSkin);
5644-
TemperatureGroundToSkinLeftArm.GetHeatSourceBaseline().SetValue(1.25, PowerUnit::kcal_Per_hr);
5644+
TemperatureGroundToSkinLeftArm.GetHeatSourceBaseline().SetValue(0.625, PowerUnit::kcal_Per_hr);
56455645
SEThermalCircuitPath& TemperatureGroundToSkinRightArm = cIntemperature.CreatePath(Ground, RightArmSkin, BGE::InternalTemperaturePath::GroundToInternalRightArmSkin);
5646-
TemperatureGroundToSkinRightArm.GetHeatSourceBaseline().SetValue(1.25, PowerUnit::kcal_Per_hr);
5646+
TemperatureGroundToSkinRightArm.GetHeatSourceBaseline().SetValue(0.625, PowerUnit::kcal_Per_hr);
56475647
SEThermalCircuitPath& TemperatureGroundToSkinLeftLeg = cIntemperature.CreatePath(Ground, LeftLegSkin, BGE::InternalTemperaturePath::GroundToInternalLeftLegSkin);
5648-
TemperatureGroundToSkinLeftLeg.GetHeatSourceBaseline().SetValue(3.61, PowerUnit::kcal_Per_hr);
5648+
TemperatureGroundToSkinLeftLeg.GetHeatSourceBaseline().SetValue(1.805, PowerUnit::kcal_Per_hr);
56495649
SEThermalCircuitPath& TemperatureGroundToSkinRightLeg = cIntemperature.CreatePath(Ground, RightLegSkin, BGE::InternalTemperaturePath::GroundToInternalRightLegSkin);
5650-
TemperatureGroundToSkinRightLeg.GetHeatSourceBaseline().SetValue(3.61, PowerUnit::kcal_Per_hr);
5650+
TemperatureGroundToSkinRightLeg.GetHeatSourceBaseline().SetValue(1.805, PowerUnit::kcal_Per_hr);
56515651

56525652
SEThermalCircuitPath& CoreToTemperatureGround = cIntemperature.CreatePath(Core, Ground, BGE::InternalTemperaturePath::InternalCoreToGround);
56535653
CoreToTemperatureGround.GetCapacitanceBaseline().SetValue((1.0 - skinMassFraction) * m_Patient->GetWeight(MassUnit::kg) * GetConfiguration().GetBodySpecificHeat(HeatCapacitancePerMassUnit::J_Per_K_kg), HeatCapacitanceUnit::J_Per_K);
56545654
Core.GetHeatBaseline().SetValue(CoreToTemperatureGround.GetCapacitanceBaseline().GetValue(HeatCapacitanceUnit::J_Per_K) * Core.GetTemperature().GetValue(TemperatureUnit::K), EnergyUnit::J);
56555655
SEThermalCircuitPath& CoreToTorsoSkin = cIntemperature.CreatePath(Core, TorsoSkin, BGE::InternalTemperaturePath::InternalCoreToInternalTorsoSkin);
5656-
CoreToTorsoSkin.GetResistanceBaseline().SetValue(4.19 * 2.315, HeatResistanceUnit::C_s_Per_kcal);
5656+
CoreToTorsoSkin.GetResistanceBaseline().SetValue(1.0 * 2.315, HeatResistanceUnit::C_s_Per_kcal);
56575657
SEThermalCircuitPath& CoreToHeadSkin = cIntemperature.CreatePath(Core, HeadSkin, BGE::InternalTemperaturePath::InternalCoreToInternalHeadSkin);
5658-
CoreToHeadSkin.GetResistanceBaseline().SetValue(4.19 * 2.257, HeatResistanceUnit::C_s_Per_kcal);
5658+
CoreToHeadSkin.GetResistanceBaseline().SetValue(1.0 * 2.257, HeatResistanceUnit::C_s_Per_kcal);
56595659
SEThermalCircuitPath& CoreToLeftArmSkin = cIntemperature.CreatePath(Core, LeftArmSkin, BGE::InternalTemperaturePath::InternalCoreToInternalLeftArmSkin);
5660-
CoreToLeftArmSkin.GetResistanceBaseline().SetValue(4.19 * 1.653, HeatResistanceUnit::C_s_Per_kcal);
5660+
CoreToLeftArmSkin.GetResistanceBaseline().SetValue(1.0 * 0.826, HeatResistanceUnit::C_s_Per_kcal);
56615661
SEThermalCircuitPath& CoreToRightArmSkin = cIntemperature.CreatePath(Core, RightArmSkin, BGE::InternalTemperaturePath::InternalCoreToInternalRightArmSkin);
5662-
CoreToRightArmSkin.GetResistanceBaseline().SetValue(4.19 * 1.653, HeatResistanceUnit::C_s_Per_kcal);
5662+
CoreToRightArmSkin.GetResistanceBaseline().SetValue(1.0 * 0.826, HeatResistanceUnit::C_s_Per_kcal);
56635663
SEThermalCircuitPath& CoreToLeftLegSkin = cIntemperature.CreatePath(Core, LeftLegSkin, BGE::InternalTemperaturePath::InternalCoreToInternalLeftLegSkin);
5664-
CoreToLeftLegSkin.GetResistanceBaseline().SetValue(4.19 * 0.703, HeatResistanceUnit::C_s_Per_kcal);
5664+
CoreToLeftLegSkin.GetResistanceBaseline().SetValue(1.0 * 0.351, HeatResistanceUnit::C_s_Per_kcal);
56655665
SEThermalCircuitPath& CoreToRightLegSkin = cIntemperature.CreatePath(Core, RightLegSkin, BGE::InternalTemperaturePath::InternalCoreToInternalRightLegSkin);
5666-
CoreToRightLegSkin.GetResistanceBaseline().SetValue(4.19 * 0.703, HeatResistanceUnit::C_s_Per_kcal);
5666+
CoreToRightLegSkin.GetResistanceBaseline().SetValue(1.0 * 0.351, HeatResistanceUnit::C_s_Per_kcal);
56675667

56685668
cIntemperature.SetNextAndCurrentFromBaselines();
56695669
cIntemperature.StateChange();

projects/biogears/libBiogears/src/engine/Systems/Energy.cpp

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -89,12 +89,6 @@ void Energy::Clear()
8989
m_BicarbonateMolarity_mmol_Per_L.Reset();
9090
m_previousWeightPack_kg = 0.0;
9191

92-
m_test = 0.0;
93-
m_test1 = 0.0;
94-
m_test2 = 0.0;
95-
m_test3 = 0.0;
96-
m_test4 = 0.0;
97-
9892
m_packOn = false;
9993
}
10094

@@ -368,7 +362,7 @@ void Energy::Exercise()
368362
// The MetabolicRateGain is used to ramp the metabolic rate to the value specified by the user's exercise intensity.
369363
const double MetabolicRateGain = m_dT_s;
370364
const double workRateDesired_W = exerciseIntensity * maxWorkRate_W;
371-
const double TotalMetabolicRateSetPoint_kcal_Per_day = basalMetabolicRate_kcal_Per_day + workRateDesired_W * kcal_Per_day_Per_Watt;
365+
const double TotalMetabolicRateSetPoint_kcal_Per_day = basalMetabolicRate_kcal_Per_day + (workRateDesired_W * kcal_Per_day_Per_Watt);
372366
const double exerciseEnergyIncrement_kcal_Per_day = MetabolicRateGain * (TotalMetabolicRateSetPoint_kcal_Per_day - currentMetabolicRate_kcal_Per_day);
373367

374368
GetExerciseEnergyDemand().IncrementValue(exerciseEnergyIncrement_kcal_Per_day, PowerUnit::kcal_Per_day);
@@ -389,12 +383,6 @@ void Energy::Process()
389383
{
390384
m_circuitCalculator.Process(*m_TemperatureCircuit, m_dT_s);
391385
CalculateVitalSigns();
392-
393-
m_data.GetDataTrack().Probe("Empty ", m_test);
394-
m_data.GetDataTrack().Probe("Empty1 ", m_test1);
395-
m_data.GetDataTrack().Probe("Empty2 ", m_test2);
396-
m_data.GetDataTrack().Probe("Empty3 ", m_test3);
397-
m_data.GetDataTrack().Probe("Empty4 ", m_test4);
398386
}
399387

400388
//--------------------------------------------------------------------------------------------------
@@ -571,14 +559,14 @@ void Energy::CalculateMetabolicHeatGeneration()
571559
{
572560
totalMetabolicRateNew_W = summitMetabolism_W * std::pow(0.94, 34.0 - coreTemperature_degC); //The metabolic heat generated will drop by 6% for every degree below 34 C
573561
GetTotalMetabolicRate().SetValue(totalMetabolicRateNew_W, PowerUnit::W); /// \cite mallet2002hypothermia
574-
} else if (coreTemperature_degC >= 34.0 && coreTemperature_degC < 36.8) //Patient is increasing heat generation via shivering. This caps out at the summit metabolism
562+
} else if (coreTemperature_degC >= 34.0 && coreTemperature_degC < 35.8) //Patient is increasing heat generation via shivering. This caps out at the summit metabolism
575563
{
576564
//Todo: Add an event for shivering
577565
double basalMetabolicRate_W = m_Patient->GetBasalMetabolicRate(PowerUnit::W);
578566
totalMetabolicRateNew_W = basalMetabolicRate_W + (summitMetabolism_W - basalMetabolicRate_W) * (coreTemperatureLow_degC - coreTemperature_degC) / coreTemperatureLowDelta_degC;
579567
totalMetabolicRateNew_W = std::min(totalMetabolicRateNew_W, summitMetabolism_W); //Bounded at the summit metabolism so further heat generation doesn't continue for continue drops below 34 C.
580568
GetTotalMetabolicRate().SetValue(totalMetabolicRateNew_W, PowerUnit::W);
581-
} else if (coreTemperature_degC >= 36.8 && coreTemperature_degC < 40 && !m_PatientActions->HasExercise()) //Basic Metabolic rate
569+
} else if (coreTemperature_degC >= 35.8 && coreTemperature_degC < 40 && !m_PatientActions->HasExercise()) //Basic Metabolic rate
582570
{
583571
double TotalMetabolicRateSetPoint_kcal_Per_day = basalMetabolicRate_kcal_Per_day;
584572
double MetabolicRateGain = 0.0001; //Used to ramp the metabolic rate from its current value to the basal value if the patient meets the basal criteria
@@ -617,16 +605,9 @@ void Energy::CalculateSweatRate()
617605
double dAirTemperature_C = m_data.GetEnvironment().GetConditions().GetAmbientTemperature(TemperatureUnit::C);
618606
double dWaterVaporPressureInAmbientAir_mmHg = GeneralMath::AntoineEquation(dAirTemperature_C);
619607
double m_dWaterVaporPressureInAmbientAir_Pa = Convert(dWaterVaporPressureInAmbientAir_mmHg, PressureUnit::mmHg, PressureUnit::Pa);
620-
LLIM(m_dWaterVaporPressureInAmbientAir_Pa, 0.0);
621608
// double ambientAtmosphericPressure_Pa = m_data.GetEnvironment().GetConditions().GetAtmosphericPressure().GetValue(PressureUnit::Pa);
622609
double maximumEvaporativeCapacity_W = 14.21 * (m_Patient->GetSkinSurfaceArea().GetValue(AreaUnit::m2)) * effectiveClothingEvaporation_im_Per_clo * (133.322 * (std::pow(10, (8.1076 - (1750.286 / (235.0 + (m_skinNodes[0]->GetTemperature(TemperatureUnit::C))))))) - (m_dWaterVaporPressureInAmbientAir_Pa)); // Still needs effective clothing evaporation
623-
m_test = (m_skinNodes[0]->GetTemperature(TemperatureUnit::C));
624-
m_test1 = std::pow(10, (8.1076 - (1750.286 / (235.0 + (m_skinNodes[0]->GetTemperature(TemperatureUnit::C))))));
625-
m_test2 = m_dWaterVaporPressureInAmbientAir_Pa;
626-
/////////////////////////////////////////////////////////////////////////////////////////////////////
627-
// WHY IS M_TEST2 SO MUCH GREATER THAN M_TEST1...IT IS CAUSING A HUGE NEGATIVE VALUE. IS THIS RIGHT?
628-
/////////////////////////////////////////////////////////////////////////////////////////////////////
629-
m_test3 = (133.322 * (std::pow(10, (8.1076 - (1750.286 / (235.0 + (m_skinNodes[0]->GetTemperature(TemperatureUnit::C))))))) - (m_dWaterVaporPressureInAmbientAir_Pa));
610+
630611
double vaporizationEnergy_J_Per_kg = m_data.GetConfiguration().GetVaporizationEnergy(EnergyPerMassUnit::J_Per_kg);
631612
double sweatSodiumConcentration_mM = 51.0; /// \cite shirreffs1997whole
632613
double sweatPotassiumConcentration_mM = 6.0; /// \cite shirreffs1997whole

projects/biogears/libBiogears/src/engine/Systems/Environment.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -270,12 +270,12 @@ void Environment::PreProcess()
270270
// 1 is head, gets no clo (0.01, assume not hat/hair for now)
271271
// arms each get 5 percent of clo
272272
// legs each get 25 percent of clo
273-
m_SkinToClothingPaths[0]->GetNextResistance().SetValue(m_cloSegmentation[0] * skinToClothingResistance, HeatResistanceUnit::K_Per_W);
274-
m_SkinToClothingPaths[1]->GetNextResistance().SetValue(m_cloSegmentation[1] * skinToClothingResistance, HeatResistanceUnit::K_Per_W);
275-
m_SkinToClothingPaths[2]->GetNextResistance().SetValue(m_cloSegmentation[2] * skinToClothingResistance, HeatResistanceUnit::K_Per_W);
276-
m_SkinToClothingPaths[3]->GetNextResistance().SetValue(m_cloSegmentation[3] * skinToClothingResistance, HeatResistanceUnit::K_Per_W);
277-
m_SkinToClothingPaths[4]->GetNextResistance().SetValue(m_cloSegmentation[4] * skinToClothingResistance, HeatResistanceUnit::K_Per_W);
278-
m_SkinToClothingPaths[5]->GetNextResistance().SetValue(m_cloSegmentation[5] * skinToClothingResistance, HeatResistanceUnit::K_Per_W);
273+
m_SkinToClothingPaths[0]->GetNextResistance().SetValue(skinToClothingResistance / m_cloSegmentation[0], HeatResistanceUnit::K_Per_W);
274+
m_SkinToClothingPaths[1]->GetNextResistance().SetValue(skinToClothingResistance / m_cloSegmentation[1], HeatResistanceUnit::K_Per_W);
275+
m_SkinToClothingPaths[2]->GetNextResistance().SetValue(skinToClothingResistance / m_cloSegmentation[2], HeatResistanceUnit::K_Per_W);
276+
m_SkinToClothingPaths[3]->GetNextResistance().SetValue(skinToClothingResistance / m_cloSegmentation[3], HeatResistanceUnit::K_Per_W);
277+
m_SkinToClothingPaths[4]->GetNextResistance().SetValue(skinToClothingResistance / m_cloSegmentation[4], HeatResistanceUnit::K_Per_W);
278+
m_SkinToClothingPaths[5]->GetNextResistance().SetValue(skinToClothingResistance / m_cloSegmentation[5], HeatResistanceUnit::K_Per_W);
279279

280280
//Set the skin heat loss
281281
double dSkinHeatLoss_W = 0.0;
@@ -707,7 +707,7 @@ void Environment::CalculateEvaporation()
707707
} else // Air
708708
{
709709
// Calculate the coefficient
710-
std::vector<double> segmentedSkinSurfaceAreaPercents; //Using male values for testing
710+
std::vector<double> segmentedSkinSurfaceAreaPercents; //Default is for males. Minimal difference but could be expanded by gender in the future.
711711
segmentedSkinSurfaceAreaPercents.push_back(0.36); // Trunk
712712
segmentedSkinSurfaceAreaPercents.push_back(0.07); // Head
713713
segmentedSkinSurfaceAreaPercents.push_back(0.092); // LArm
@@ -719,7 +719,7 @@ void Environment::CalculateEvaporation()
719719
double dConvectiveTransferCoefficient_W_Per_m2_K = GetConvectiveHeatTranferCoefficient(HeatConductancePerAreaUnit::W_Per_m2_K);
720720
const double dLewisRelation_K_Per_kPa = 16.5;
721721
const double dEvaporativeHeatTransferCoefficient_W_Per_m2_kPa = dConvectiveTransferCoefficient_W_Per_m2_K * dLewisRelation_K_Per_kPa;
722-
const double dClothingResistance_clo = GetConditions().GetClothingResistance(HeatResistanceAreaUnit::clo) * m_cloSegmentation[index];
722+
const double dClothingResistance_clo = GetConditions().GetClothingResistance(HeatResistanceAreaUnit::clo) / m_cloSegmentation[index];
723723
const double clo_To_m2_K_Per_W = 0.155;
724724
const double iCl = 0.35;
725725
double dClothingResistance_m2_kPa_Per_W = clo_To_m2_K_Per_W * dClothingResistance_clo / (iCl * dLewisRelation_K_Per_kPa);

0 commit comments

Comments
 (0)