Skip to content

Commit

Permalink
Fix naming and types.
Browse files Browse the repository at this point in the history
  • Loading branch information
Phil Ahrenkiel authored and Phil Ahrenkiel committed Feb 10, 2024
1 parent 105d010 commit 2d3dbbe
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 31 deletions.
27 changes: 13 additions & 14 deletions src/HPWH.cc
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ void HPWH::setMinutesPerStep(const double minutesPerStep_in)
{
minutesPerStep = minutesPerStep_in;
secondsPerStep = sec_per_min * minutesPerStep;
hoursPerStep = minutesPerStep / min_per_hr;
hoursPerStep = minutesPerStep / min_per_h;
}

// public HPWH functions
Expand Down Expand Up @@ -3977,13 +3977,13 @@ void HPWH::addExtraHeat(std::vector<double>& extraHeatDist_W)
if (heatDistribution_W[i] != 0)
{
double qAdd_BTUperHr = KWH_TO_BTU(heatDistribution_W[i] / 1000.);
double qAdd_KJ = BTU_TO_KJ(qAdd_BTUperHr * minutesPerStep / min_per_hr);
double qAdd_KJ = BTU_TO_KJ(qAdd_BTUperHr * minutesPerStep / min_per_h);
addExtraHeatAboveNode(qAdd_KJ, i);
tot_qAdded_BTUperHr += qAdd_BTUperHr;
}
}
// Write the input & output energy
extraEnergyInput_kWh = BTU_TO_KWH(tot_qAdded_BTUperHr * minutesPerStep / min_per_hr);
extraEnergyInput_kWh = BTU_TO_KWH(tot_qAdded_BTUperHr * minutesPerStep / min_per_h);
}

///////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -5860,7 +5860,7 @@ bool HPWH::run24hrTest(const FirstHourRating firstHourRating,

bool hasHeated = false;

int endTime_min = 24 * min_per_hr;
int endTime_min = 24 * static_cast<int>(min_per_h);
std::size_t iDraw = 0;
double remainingDrawVolume_L = 0.;
double drawVolume_L = 0.;
Expand All @@ -5885,7 +5885,7 @@ bool HPWH::run24hrTest(const FirstHourRating firstHourRating,
double standbySumTimeTankT_minC = 0.;
double standbySumTimeAmbientT_minC = 0.;

int noDrawTotalTime_min = 0.;
int noDrawTotalTime_min = 0;
double noDrawSumTimeAmbientT_minC = 0.;

bool inLastHour = false;
Expand Down Expand Up @@ -6059,7 +6059,7 @@ bool HPWH::run24hrTest(const FirstHourRating firstHourRating,
standbySumTimeTankT_minC += (1.) * tankT_C;
standbySumTimeAmbientT_minC += (1.) * ambientT_C;

if (runTime_min >= standbyStartTime_min + 8 * min_per_hr)
if (runTime_min >= standbyStartTime_min + 8 * min_per_h)
{
hasStandbyPeriodEnded = true;
standbyEndTankEnergy_kJ = testSummary.usedEnergy_kJ; // Qsu,0
Expand All @@ -6086,9 +6086,9 @@ bool HPWH::run24hrTest(const FirstHourRating firstHourRating,
standbyStartT_C = tankT_C; // Tsu,0

if (isDrawPatternComplete &&
(runTime_min + 8 * min_per_hr > endTime_min))
(runTime_min + 8 * min_per_h > endTime_min))
{
endTime_min = runTime_min + 8 * min_per_hr;
endTime_min = runTime_min + 8 * static_cast<int>(min_per_h);
}
}
}
Expand Down Expand Up @@ -6140,6 +6140,9 @@ bool HPWH::run24hrTest(const FirstHourRating firstHourRating,
double tankContentMass_kg = DENSITYWATER_kgperL * tankVolume_L;
double tankHeatCapacity_kJperC = CPWATER_kJperkgC * tankContentMass_kg;

double removedMass_kg = DENSITYWATER_kgperL * testSummary.removedVolume_L;
double removedHeatCapacity_kJperC = CPWATER_kJperkgC * removedMass_kg;

// require heating during 24-hr test for unit to qualify as consumer water heater
if (hasHeated && !isDrawing)
{
Expand All @@ -6159,7 +6162,7 @@ bool HPWH::run24hrTest(const FirstHourRating firstHourRating,
testSummary.standbyUsedEnergy_kJ = standbyEndTankEnergy_kJ - standbyStartTankEnergy_kJ;

int standbyPeriodTime_min = standbyEndTime_min - standbyStartTime_min - 1;
testSummary.standbyPeriodTime_h = standbyPeriodTime_min / min_per_hr; // tau_stby,1
testSummary.standbyPeriodTime_h = standbyPeriodTime_min / min_per_h; // tau_stby,1
if ((testSummary.standbyPeriodTime_h > 0) && (testSummary.recoveryEfficiency > 0.))
{
double standardTankEnergy_kJ = tankHeatCapacity_kJperC * (standbyEndT_C - standbyStartT_C) /
Expand All @@ -6180,16 +6183,14 @@ bool HPWH::run24hrTest(const FirstHourRating firstHourRating,
}

//
testSummary.noDrawTotalTime_h = noDrawTotalTime_min / min_per_hr; // tau_stby,2
testSummary.noDrawTotalTime_h = noDrawTotalTime_min / min_per_h; // tau_stby,2
if (noDrawTotalTime_min > 0)
{
testSummary.noDrawAverageAmbientT_C =
noDrawSumTimeAmbientT_minC / noDrawTotalTime_min; // <Ta,stby,2>
}

// find the standard delivered daily energy
double removedMass_kg = HPWH::DENSITYWATER_kgperL * testSummary.removedVolume_L;
double removedHeatCapacity_kJperC = HPWH::CPWATER_kJperkgC * removedMass_kg;
double standardDeliveredEnergy_kJ =
removedHeatCapacity_kJperC * (standardSetpointT_C - standardInletT_C);

Expand Down Expand Up @@ -6219,8 +6220,6 @@ bool HPWH::run24hrTest(const FirstHourRating firstHourRating,
testSummary.standardWaterHeatingEnergy_kJ = 0.;
if (testSummary.recoveryEfficiency > 0.)
{
double removedMass_kg = DENSITYWATER_kgperL * testSummary.removedVolume_L;
double removedHeatCapacity_kJperC = CPWATER_kJperkgC * removedMass_kg;
double standardRemovedEnergy_kJ =
removedHeatCapacity_kJperC * (standardSetpointT_C - standardInletT_C);
testSummary.standardWaterHeatingEnergy_kJ =
Expand Down
20 changes: 10 additions & 10 deletions src/HPWH.hh
Original file line number Diff line number Diff line change
Expand Up @@ -1637,24 +1637,24 @@ constexpr double BTUperKWH =
constexpr double FperC = 9. / 5.; // degF / degC
constexpr double offsetF = 32.; // degF offset
constexpr double sec_per_min = 60.; // seconds / min
constexpr double min_per_hr = 60.; // min / hr
constexpr double sec_per_hr = sec_per_min * min_per_hr; // seconds / hr
constexpr double L_per_gal = 3.78541; // liters / gal
constexpr double ft_per_m = 3.2808; // feet / meter
constexpr double ft2_per_m2 = ft_per_m * ft_per_m; // feet / meter
constexpr double min_per_h = 60.; // min / h
constexpr double sec_per_h = sec_per_min * min_per_h; // seconds / hr
constexpr double L_per_gal = 3.78541; // liters / gal
constexpr double ft_per_m = 3.2808; // feet / meter
constexpr double ft2_per_m2 = ft_per_m * ft_per_m; // feet / meter

// a few extra functions for unit conversion
inline double dF_TO_dC(double temperature) { return (temperature / FperC); }
inline double F_TO_C(double temperature) { return ((temperature - offsetF) / FperC); }
inline double C_TO_F(double temperature) { return ((FperC * temperature) + offsetF); }
inline double KWH_TO_BTU(double kwh) { return (BTUperKWH * kwh); }
inline double KWH_TO_KJ(double kwh) { return (kwh * sec_per_hr); }
inline double KWH_TO_KJ(double kwh) { return (kwh * sec_per_h); }
inline double BTU_TO_KWH(double btu) { return (btu / BTUperKWH); }
inline double BTUperH_TO_KW(double btu) { return (btu / BTUperKWH); }
inline double KW_TO_BTUperH(double kw) { return (kw * BTUperKWH); }
inline double W_TO_BTUperH(double w) { return (w * BTUperKWH / 1000.); }
inline double KJ_TO_KWH(double kj) { return (kj / sec_per_hr); }
inline double BTU_TO_KJ(double btu) { return (btu * sec_per_hr / BTUperKWH); }
inline double KJ_TO_KWH(double kj) { return (kj / sec_per_h); }
inline double BTU_TO_KJ(double btu) { return (btu * sec_per_h / BTUperKWH); }
inline double GAL_TO_L(double gallons) { return (gallons * L_per_gal); }
inline double L_TO_GAL(double liters) { return (liters / L_per_gal); }
inline double L_TO_FT3(double liters) { return (liters / 28.31685); }
Expand All @@ -1666,11 +1666,11 @@ inline double FT_TO_M(double feet) { return (feet / ft_per_m); }
inline double FT2_TO_M2(double feet2) { return (feet2 / ft2_per_m2); }

inline double MIN_TO_SEC(double minute) { return minute * sec_per_min; }
inline double MIN_TO_HR(double minute) { return minute / min_per_hr; }
inline double MIN_TO_HR(double minute) { return minute / min_per_h; }

inline double HM_TO_MIN(const double hours, const double minutes)
{
return min_per_hr * hours + minutes;
return min_per_h * hours + minutes;
}

inline HPWH::DRMODES operator|(HPWH::DRMODES a, HPWH::DRMODES b)
Expand Down
14 changes: 7 additions & 7 deletions src/HPWHHeatSources.cc
Original file line number Diff line number Diff line change
Expand Up @@ -498,7 +498,7 @@ void HPWH::HeatSource::addHeat(double externalT_C, double minutesToRun)
if (hpwh->hpwhVerbosity >= VRB_typical)
{
hpwh->msg("capacity_kWh %.2lf \t\t cap_BTUperHr %.2lf \n",
BTU_TO_KWH(cap_BTUperHr) * (minutesToRun) / min_per_hr,
BTU_TO_KWH(cap_BTUperHr) * (minutesToRun) / min_per_h,
cap_BTUperHr);
}

Expand All @@ -512,7 +512,7 @@ void HPWH::HeatSource::addHeat(double externalT_C, double minutesToRun)
{
// for(int i = 0; i < hpwh->numNodes; i++){
double nodeCap_kJ =
BTU_TO_KJ(cap_BTUperHr * minutesToRun / min_per_hr * heatDistribution[i]);
BTU_TO_KJ(cap_BTUperHr * minutesToRun / min_per_h * heatDistribution[i]);
if (nodeCap_kJ != 0.)
{
double heatToAdd_kJ = nodeCap_kJ + leftoverCap_kJ;
Expand All @@ -527,7 +527,7 @@ void HPWH::HeatSource::addHeat(double externalT_C, double minutesToRun)
}

// after you've done everything, any leftover capacity is time that didn't run
double cap_kJ = BTU_TO_KJ(cap_BTUperHr * minutesToRun / min_per_hr);
double cap_kJ = BTU_TO_KJ(cap_BTUperHr * minutesToRun / min_per_h);
runtime_min = (1. - (leftoverCap_kJ / cap_kJ)) * minutesToRun;
#if 1 // error check, 1-22-2017; updated 12-6-2023
if (runtime_min < -TOL_MINVALUE)
Expand All @@ -546,8 +546,8 @@ void HPWH::HeatSource::addHeat(double externalT_C, double minutesToRun)
}

// Write the input & output energy
energyInput_kWh += BTU_TO_KWH(input_BTUperHr * runtime_min / min_per_hr);
energyOutput_kWh += BTU_TO_KWH(cap_BTUperHr * runtime_min / min_per_hr);
energyInput_kWh += BTU_TO_KWH(input_BTUperHr * runtime_min / min_per_h);
energyOutput_kWh += BTU_TO_KWH(cap_BTUperHr * runtime_min / min_per_h);
}

// private HPWH::HeatSource functions
Expand Down Expand Up @@ -960,7 +960,7 @@ double HPWH::HeatSource::addHeatExternal(double externalT_C,
tempInput_BTUperHr,
tempCap_BTUperHr,
temp_cop);
heatingCapacity_kJ = BTU_TO_KJ(tempCap_BTUperHr * (timeRemaining_min / min_per_hr));
heatingCapacity_kJ = BTU_TO_KJ(tempCap_BTUperHr * (timeRemaining_min / min_per_h));
targetT_C = calcMPOutletTemperature(BTUperH_TO_KW(tempCap_BTUperHr));
}
else
Expand All @@ -971,7 +971,7 @@ double HPWH::HeatSource::addHeatExternal(double externalT_C,
tempInput_BTUperHr,
tempCap_BTUperHr,
temp_cop);
heatingCapacity_kJ = BTU_TO_KJ(tempCap_BTUperHr * (minutesToRun / min_per_hr));
heatingCapacity_kJ = BTU_TO_KJ(tempCap_BTUperHr * (minutesToRun / min_per_h));
if (hpwh->hpwhVerbosity >= VRB_emetic)
{
hpwh->msg("\theatingCapacity_kJ stepwise: %.2lf \n", heatingCapacity_kJ);
Expand Down

0 comments on commit 2d3dbbe

Please sign in to comment.