@@ -88,6 +88,13 @@ void Energy::Clear()
8888 m_BloodpH.Reset ();
8989 m_BicarbonateMolarity_mmol_Per_L.Reset ();
9090 m_previousWeightPack_kg = 0.0 ;
91+
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+
9198 m_packOn = false ;
9299}
93100
@@ -382,6 +389,12 @@ void Energy::Process()
382389{
383390 m_circuitCalculator.Process (*m_TemperatureCircuit, m_dT_s);
384391 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);
385398}
386399
387400// --------------------------------------------------------------------------------------------------
@@ -604,59 +617,62 @@ void Energy::CalculateSweatRate()
604617 double dAirTemperature_C = m_data.GetEnvironment ().GetConditions ().GetAmbientTemperature (TemperatureUnit::C);
605618 double dWaterVaporPressureInAmbientAir_mmHg = GeneralMath::AntoineEquation (dAirTemperature_C);
606619 double m_dWaterVaporPressureInAmbientAir_Pa = Convert (dWaterVaporPressureInAmbientAir_mmHg, PressureUnit::mmHg, PressureUnit::Pa);
620+ LLIM (m_dWaterVaporPressureInAmbientAir_Pa, 0.0 );
607621 // double ambientAtmosphericPressure_Pa = m_data.GetEnvironment().GetConditions().GetAtmosphericPressure().GetValue(PressureUnit::Pa);
622+ 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));
608630 double vaporizationEnergy_J_Per_kg = m_data.GetConfiguration ().GetVaporizationEnergy (EnergyPerMassUnit::J_Per_kg);
609631 double sweatSodiumConcentration_mM = 51.0 ; // / \cite shirreffs1997whole
610632 double sweatPotassiumConcentration_mM = 6.0 ; // / \cite shirreffs1997whole
611633 double sweatChlorideConcentration_mM = 48.0 ; // / \cite shirreffs1997whole
612- // static double totalSweatLost_mL = 0; --Used to figure out total sweat loss during exercise scenario during debugging
634+ // static double totalSweatLost_mL = 0; --Used to figure out total sweat loss during exercise scenario during debugging
613635
614- double overallSweatRate_kg_Per_s = 0.0 ;
615- SEScalarMassPerVolume sweatDensity;
616- for (SEThermalCircuitNode* skinNode : m_skinNodes) {
617- 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 + (skinNode->GetTemperature (TemperatureUnit::C))))))) - ((m_dWaterVaporPressureInAmbientAir_Pa))); // Still needs effective clothing evaporation
618- double currentEvaporativeCapacity_W = sweatHeatTranferCoefficient_W_Per_K * (skinNode->GetTemperature (TemperatureUnit::K));
619- if (currentEvaporativeCapacity_W > maximumEvaporativeCapacity_W) {
620-
621- sweatHeatTranferCoefficient_W_Per_K = maximumEvaporativeCapacity_W / (skinNode->GetTemperature (TemperatureUnit::K));
622- }
636+ double currentEvaporativeCapacity_W = sweatHeatTranferCoefficient_W_Per_K * (m_skinNodes[0 ]->GetTemperature (TemperatureUnit::K));
637+ if (currentEvaporativeCapacity_W > maximumEvaporativeCapacity_W) {
623638
624- double dehydrationFraction = m_data.GetTissue ().GetDehydrationFraction ().GetValue ();
625-
626- // Calculate sweat rate (in kg/s) from core temperature feedback.
627- // The sweat rate heat transfer is determined from a control equation that attempts to keep the core temperature in line
628- // / \cite herman2008physics
629- // Sweat rate decreases as dehydration becomes more severe, with max reduction seen at 10% dehydration
630- double dehydrationScalingFactor = GeneralMath::LinearInterpolator (0 , .1 , 1 , 0 , dehydrationFraction);
631- BLIM (dehydrationScalingFactor, 0 , 1 );
632- double sweatRate_kg_Per_s = dehydrationScalingFactor * (0.25 * sweatHeatTranferCoefficient_W_Per_K / vaporizationEnergy_J_Per_kg) * (coreTemperature_degC - coreTemperatureHigh_degC);
633-
634- // The Sweat Scaling Factor is caused by changes in the Hyperhidrosis patient parameter to invoke either hyperhidrosis or hypohidrosis
635- // / \cite shih1983autonomic
636- double sweatScalingFactor = 0.0 ;
637- if (m_Patient->HasHyperhidrosis ()) {
638- sweatScalingFactor = m_Patient->GetHyperhidrosis ().GetValue ();
639- sweatRate_kg_Per_s = (1 + sweatScalingFactor) * sweatRate_kg_Per_s;
640- }
641- overallSweatRate_kg_Per_s += sweatRate_kg_Per_s;
639+ sweatHeatTranferCoefficient_W_Per_K = maximumEvaporativeCapacity_W / (m_skinNodes[0 ]->GetTemperature (TemperatureUnit::K));
642640 }
641+
643642 // / \todo Convert to sweat density once specific gravity calculation is in
644- GeneralMath::CalculateWaterDensity (m_skinNodes[0 ]->GetTemperature (), sweatDensity); // using trunk as representation due to it having the largest surface area. This will likely be vectorized out later
643+ SEScalarMassPerVolume sweatDensity;
644+ GeneralMath::CalculateWaterDensity (m_skinNodes[0 ]->GetTemperature (), sweatDensity);
645+ double dehydrationFraction = m_data.GetTissue ().GetDehydrationFraction ().GetValue ();
646+ // Calculate sweat rate (in kg/s) from core temperature feedback.
647+ // The sweat rate heat transfer is determined from a control equation that attempts to keep the core temperature in line
648+ // / \cite herman2008physics
649+ // Sweat rate decreases as dehydration becomes more severe, with max reduction seen at 10% dehydration
650+ double dehydrationScalingFactor = GeneralMath::LinearInterpolator (0 , .1 , 1 , 0 , dehydrationFraction);
651+ BLIM (dehydrationScalingFactor, 0 , 1 );
652+ double sweatRate_kg_Per_s = dehydrationScalingFactor * (0.25 * sweatHeatTranferCoefficient_W_Per_K / vaporizationEnergy_J_Per_kg) * (coreTemperature_degC - coreTemperatureHigh_degC);
653+
654+ // The Sweat Scaling Factor is caused by changes in the Hyperhidrosis patient parameter to invoke either hyperhidrosis or hypohidrosis
655+ // / \cite shih1983autonomic
656+ double sweatScalingFactor = 0.0 ;
657+ if (m_Patient->HasHyperhidrosis ()) {
658+ sweatScalingFactor = m_Patient->GetHyperhidrosis ().GetValue ();
659+ sweatRate_kg_Per_s = (1 + sweatScalingFactor) * sweatRate_kg_Per_s;
660+ }
645661
646- double maxSweatRate_kg_Per_s = 12.5 * m_Patient->GetSkinSurfaceArea ().GetValue (AreaUnit::m2) / 60.0 / 1000.0 ; // 10 - 15 g/min/m2
647- BLIM (overallSweatRate_kg_Per_s , 0.0 , maxSweatRate_kg_Per_s);
662+ double maxSweatRate_kg_Per_s = 12.5 * m_Patient->GetSkinSurfaceArea ().GetValue (AreaUnit::m2) / 60.0 / 1000.0 ; // 10 - 15 g/min/m2
663+ BLIM (sweatRate_kg_Per_s , 0.0 , maxSweatRate_kg_Per_s);
648664
649- // Account for mass lost by subtracting from the current patient mass
650- double massLost_kg = overallSweatRate_kg_Per_s * m_dT_s;
665+ // Account for mass lost by subtracting from the current patient mass
666+ double massLost_kg = sweatRate_kg_Per_s * m_dT_s;
651667 m_Patient->GetWeight ().IncrementValue (-massLost_kg, MassUnit::kg);
652- GetSweatRate ().SetValue (overallSweatRate_kg_Per_s , MassPerTimeUnit::kg_Per_s);
668+ GetSweatRate ().SetValue (sweatRate_kg_Per_s , MassPerTimeUnit::kg_Per_s);
653669
654- // Calculate mass of ions lost in sweat (sodium, potassium, and chloride): Converts kg sweat lost -> L sweat lost -> mmol ion lost -> mg ion lost
670+ // Calculate mass of ions lost in sweat (sodium, potassium, and chloride): Converts kg sweat lost -> L sweat lost -> mmol ion lost -> mg ion lost
655671 double sodiumLost_mg = massLost_kg / sweatDensity.GetValue (MassPerVolumeUnit::kg_Per_L) * sweatSodiumConcentration_mM * m_data.GetSubstances ().GetSodium ().GetMolarMass (MassPerAmountUnit::mg_Per_mmol);
656672 double potassiumLost_mg = massLost_kg / sweatDensity.GetValue (MassPerVolumeUnit::kg_Per_L) * sweatPotassiumConcentration_mM * m_data.GetSubstances ().GetPotassium ().GetMolarMass (MassPerAmountUnit::mg_Per_mmol);
657673 double chlorideLost_mg = massLost_kg / sweatDensity.GetValue (MassPerVolumeUnit::kg_Per_L) * sweatChlorideConcentration_mM * m_data.GetSubstances ().GetChloride ().GetMolarMass (MassPerAmountUnit::mg_Per_mmol);
658674
659- // Decrement amount of each ion in the skin extracellular compartment, track the cumulative amount removed for output, and balance (i.e. update concentration) remaining levels
675+ // Decrement amount of each ion in the skin extracellular compartment, track the cumulative amount removed for output, and balance (i.e. update concentration) remaining levels
660676 m_SkinSodium->GetMass ().IncrementValue (-sodiumLost_mg, MassUnit::mg);
661677 GetSodiumLostToSweat ().IncrementValue (sodiumLost_mg, MassUnit::mg);
662678 m_SkinPotassium->GetMass ().IncrementValue (-potassiumLost_mg, MassUnit::mg);
@@ -667,8 +683,8 @@ void Energy::CalculateSweatRate()
667683 m_SkinPotassium->Balance (BalanceLiquidBy::Mass);
668684 m_SkinChloride->Balance (BalanceLiquidBy::Mass);
669685
670- // Set the flow source on the extravascular circuit to begin removing the fluid that is excreted
671- double sweatRate_mL_Per_s = overallSweatRate_kg_Per_s / sweatDensity.GetValue (MassPerVolumeUnit::kg_Per_mL);
686+ // Set the flow source on the extravascular circuit to begin removing the fluid that is excreted
687+ double sweatRate_mL_Per_s = sweatRate_kg_Per_s / sweatDensity.GetValue (MassPerVolumeUnit::kg_Per_mL);
672688 m_skinExtravascularToSweatingGroundPath->GetNextFlowSource ().SetValue (sweatRate_mL_Per_s, VolumePerTimeUnit::mL_Per_s );
673689}
674690
0 commit comments