Skip to content

Commit

Permalink
Format.
Browse files Browse the repository at this point in the history
  • Loading branch information
spahrenk committed Jan 10, 2024
1 parent c6e3225 commit a045e8c
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 25 deletions.
42 changes: 24 additions & 18 deletions src/HPWH.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5504,7 +5504,8 @@ bool HPWH::prepForTest(StandardTestSummary& standardTestSummary)
/// @param[in] setpointT_C setpoint temperature (optional)
/// @return true (success), false (failure).
//-----------------------------------------------------------------------------
bool HPWH::findUsageFromFirstHourRating(StandardTestSummary& standardTestSummary, const double setpointT_C /* = 51.7 */)
bool HPWH::findUsageFromFirstHourRating(StandardTestSummary& standardTestSummary,
const double setpointT_C /* = 51.7 */)
{
double flowRate_Lper_min = GAL_TO_L(3.);
if (tankVolume_L < GAL_TO_L(20.))
Expand Down Expand Up @@ -5582,16 +5583,18 @@ bool HPWH::findUsageFromFirstHourRating(StandardTestSummary& standardTestSummary
sumOutletVolumeT_LC += incrementalDrawVolume_L * outletTemp_C;

maxOutletT_C = std::max(outletTemp_C, maxOutletT_C);
if (outletTemp_C < maxOutletT_C - dF_TO_dC(15.)) // outletT has dropped by 15 degF below max T
if (outletTemp_C <
maxOutletT_C - dF_TO_dC(15.)) // outletT has dropped by 15 degF below max T
{
avgOutletT_C = sumOutletVolumeT_LC / sumOutletVolume_L;
minOutletT_C = outletTemp_C;
if(elapsedTime_min >= 60)
if (elapsedTime_min >= 60)
{
double fac = 1;
if (!firstDraw)
{
fac = (avgOutletT_C - prevMinOutletT_C) / (prevAvgOutletT_C - prevMinOutletT_C);
fac = (avgOutletT_C - prevMinOutletT_C) /
(prevAvgOutletT_C - prevMinOutletT_C);
}
totalDrawVolume_L += fac * drawVolume_L;
done = true;
Expand All @@ -5608,8 +5611,7 @@ bool HPWH::findUsageFromFirstHourRating(StandardTestSummary& standardTestSummary
prevMinOutletT_C = minOutletT_C;
++step;
}

}
}
break;
}

Expand All @@ -5624,8 +5626,9 @@ bool HPWH::findUsageFromFirstHourRating(StandardTestSummary& standardTestSummary

case 2: // heating
{
if ((tankT_C > maxTankT_C) &&
isHeating && (elapsedTime_min < 60)) // has not reached maxTankT, heat is on, and has not reached 1 hr
if ((tankT_C > maxTankT_C) && isHeating &&
(elapsedTime_min <
60)) // has not reached maxTankT, heat is on, and has not reached 1 hr
{
maxTankT_C = std::max(tankT_C, maxTankT_C);
}
Expand Down Expand Up @@ -5687,7 +5690,7 @@ bool HPWH::findUsageFromFirstHourRating(StandardTestSummary& standardTestSummary
/// @return true (success), false (failure).
//-----------------------------------------------------------------------------
bool HPWH::run24hrTest(StandardTestSummary& standardTestSummary,
const double setpointT_C /* = 51.7 */)
const double setpointT_C /* = 51.7 */)
{
// select the draw pattern based on usage
DrawPattern* drawPattern = nullptr;
Expand Down Expand Up @@ -5890,7 +5893,8 @@ bool HPWH::run24hrTest(StandardTestSummary& standardTestSummary,
standardTestSummary.recoveryEfficiency = 0.;
if (firstRecoveryUsedEnergy_kJ > 0.)
{
standardTestSummary.recoveryEfficiency = recoveryHeatingEnergy_kJ / firstRecoveryUsedEnergy_kJ;
standardTestSummary.recoveryEfficiency =
recoveryHeatingEnergy_kJ / firstRecoveryUsedEnergy_kJ;
}

// find the standard daily heating energy
Expand All @@ -5908,9 +5912,9 @@ bool HPWH::run24hrTest(StandardTestSummary& standardTestSummary,
double tankContentMass_kg = DENSITYWATER_kgperL * tankVolume_L;
double tankHeatCapacity_kJperC = CPWATER_kJperkgC * tankContentMass_kg;
double finalTankT_C = tankT_C;
standardTestSummary.dailyHeatingEnergyConsumption_kJ -= tankHeatCapacity_kJperC *
(finalTankT_C - initialTankT_C) /
standardTestSummary.recoveryEfficiency;
standardTestSummary.dailyHeatingEnergyConsumption_kJ -=
tankHeatCapacity_kJperC * (finalTankT_C - initialTankT_C) /
standardTestSummary.recoveryEfficiency;
}

// find the "Adjusted Daily Water Heating Energy Consumption (Qda)" (6.3.6a)
Expand Down Expand Up @@ -5939,8 +5943,9 @@ bool HPWH::run24hrTest(StandardTestSummary& standardTestSummary,
}

// add to the adjusted daily water heating energy consumption (p. 40487)
double energyUsedToHeatWaterDifference_kJ = standardTestSummary.standardEnergyUsedToHeatWater_kJ -
standardTestSummary.energyUsedToHeatWater_kJ;
double energyUsedToHeatWaterDifference_kJ =
standardTestSummary.standardEnergyUsedToHeatWater_kJ -
standardTestSummary.energyUsedToHeatWater_kJ;
standardTestSummary.adjustedDailyWaterHeatingEnergyConsumption_kJ +=
energyUsedToHeatWaterDifference_kJ;

Expand All @@ -5955,7 +5960,7 @@ bool HPWH::run24hrTest(StandardTestSummary& standardTestSummary,
if (standardTestSummary.modifiedDailyWaterHeatingEnergyConsumption_kJ > 0.)
{
standardTestSummary.UEF = standardDailyHeatingEnergy_kJ /
standardTestSummary.modifiedDailyWaterHeatingEnergyConsumption_kJ;
standardTestSummary.modifiedDailyWaterHeatingEnergyConsumption_kJ;
}

// find the "Annual Energy Consumption" (6.4.5)
Expand All @@ -5964,8 +5969,9 @@ bool HPWH::run24hrTest(StandardTestSummary& standardTestSummary,
{
constexpr double days_per_year = 365.;
const double nominalDifferenceT_C = F_TO_C(67.);
standardTestSummary.annualEnergyConsumption_kJ =
days_per_year * dailyHeatCapacity_kJperC * nominalDifferenceT_C / standardTestSummary.UEF;
standardTestSummary.annualEnergyConsumption_kJ = days_per_year * dailyHeatCapacity_kJperC *
nominalDifferenceT_C /
standardTestSummary.UEF;
}

// find the "Annual Electrical Energy Consumption" (6.4.6)
Expand Down
9 changes: 5 additions & 4 deletions src/HPWH.hh
Original file line number Diff line number Diff line change
Expand Up @@ -974,11 +974,12 @@ class HPWH
static double consumerHPWH_maxPower_kW;
};

/// perform a draw/heat cycle to prepare for test
bool prepForTest(StandardTestSummary& standardTestSummary);
/// perform a draw/heat cycle to prepare for test
bool prepForTest(StandardTestSummary& standardTestSummary);

/// determine usage using the first-hour rating method
bool findUsageFromFirstHourRating(StandardTestSummary& standardTestSummary,const double setpointT_C = 51.7);
/// determine usage using the first-hour rating method
bool findUsageFromFirstHourRating(StandardTestSummary& standardTestSummary,
const double setpointT_C = 51.7);

/// run 24-hr draw pattern
bool run24hrTest(StandardTestSummary& standardTestSummary, const double setpointT_C = 51.7);
Expand Down
11 changes: 8 additions & 3 deletions test/testCalcUEF.cc
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

/* Measure metrics based on simulations using standard profiles */
static bool testMeasureMetrics(const std::string& sModelName,
HPWH::StandardTestSummary& standardTestSummary)
HPWH::StandardTestSummary& standardTestSummary)
{
HPWH hpwh;

Expand Down Expand Up @@ -56,15 +56,20 @@ int main(int argc, char* argv[])
if (runUnitTests)
{
ASSERTTRUE(testMeasureMetrics("AquaThermAire", standardTestSummary));
ASSERTTRUE(standardTestSummary.qualifies );
ASSERTTRUE(standardTestSummary.qualifies);
ASSERTTRUE(standardTestSummary.usage == HPWH::Usage::Medium);
ASSERTTRUE(cmpd(standardTestSummary.UEF, 2.6326));

ASSERTTRUE(testMeasureMetrics("AOSmithHPTS50", standardTestSummary));
ASSERTTRUE(standardTestSummary.qualifies );
ASSERTTRUE(standardTestSummary.qualifies);
ASSERTTRUE(standardTestSummary.usage == HPWH::Usage::Low);
ASSERTTRUE(cmpd(standardTestSummary.UEF, 4.4914));

ASSERTTRUE(testMeasureMetrics("AOSmithHPTS80", standardTestSummary));
ASSERTTRUE(standardTestSummary.qualifies);
ASSERTTRUE(standardTestSummary.usage == HPWH::Usage::High);
ASSERTTRUE(cmpd(standardTestSummary.UEF, 3.5230));

return 0;
}

Expand Down

0 comments on commit a045e8c

Please sign in to comment.