Skip to content

Commit

Permalink
Improve variable names.
Browse files Browse the repository at this point in the history
  • Loading branch information
Phil Ahrenkiel authored and Phil Ahrenkiel committed Feb 15, 2024
1 parent 997433c commit 90e99ac
Show file tree
Hide file tree
Showing 5 changed files with 158 additions and 158 deletions.
66 changes: 33 additions & 33 deletions src/HPWH.cc
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,8 @@ void HPWH::setAllDefaults()
mixBelowFractionOnDraw = 1. / 3.;
doInversionMixing = true;
doConduction = true;
inletHeight = 0;
inlet2Height = 0;
inletIndex = 0;
inlet2Index = 0;
fittingsUA_kJperHrC = 0.;
prevDRstatus = DR_ALLOW;
timerLimitTOT = 60.;
Expand Down Expand Up @@ -414,8 +414,8 @@ HPWH& HPWH::operator=(const HPWH& hpwh)
tankT_C = hpwh.tankT_C;
nextTankT_C = hpwh.nextTankT_C;

inletHeight = hpwh.inletHeight;
inlet2Height = hpwh.inlet2Height;
inletIndex = hpwh.inletIndex;
inlet2Index = hpwh.inlet2Index;

outletT_C = hpwh.outletT_C;
condenserInletT_C = hpwh.condenserInletT_C;
Expand Down Expand Up @@ -514,7 +514,7 @@ int HPWH::runOneStep(double drawVolume_L,
heatSources[i].energyOutput_kJ = 0.;
heatSources[i].energyRemovedFromEnvironment_kJ = 0.;
}
extraEnergyInput_kWh = 0.;
extraEnergyInput_kJ = 0.;

// if you are doing temp. depression, set tank and heatSource ambient temps
// to the tracked locationTemperature
Expand Down Expand Up @@ -1332,7 +1332,7 @@ bool HPWH::isNewSetpointPossible(double newSetpoint,

maxAllowedSetpoint_C =
heatSources[compressorIndex].maxSetpointT_C -
heatSources[compressorIndex].secondaryHeatExchanger.hotSideTemperatureOffset_dC;
heatSources[compressorIndex].secondaryHeatExchanger.hotSideOffsetT_C;

if (newSetpoint_C > maxAllowedSetpoint_C && lowestElementIndex == -1)
{
Expand Down Expand Up @@ -1797,11 +1797,11 @@ int HPWH::getFittingsUA(double& UA, UNITS units /*=UNITS_kJperHrC*/) const

int HPWH::setInletByFraction(double fractionalHeight)
{
return setNodeNumFromFractionalHeight(fractionalHeight, inletHeight);
return setNodeNumFromFractionalHeight(fractionalHeight, inletIndex);
}
int HPWH::setInlet2ByFraction(double fractionalHeight)
{
return setNodeNumFromFractionalHeight(fractionalHeight, inlet2Height);
return setNodeNumFromFractionalHeight(fractionalHeight, inlet2Index);
}

int HPWH::setExternalInletHeightByFraction(double fractionalHeight)
Expand Down Expand Up @@ -1832,12 +1832,12 @@ int HPWH::setExternalPortHeightByFraction(double fractionalHeight, int whichExte
if (whichExternalPort == 1)
{
returnVal = setNodeNumFromFractionalHeight(fractionalHeight,
heatSources[i].externalInletHeight);
heatSources[i].externalInletNodeIndex);
}
else
{
returnVal = setNodeNumFromFractionalHeight(fractionalHeight,
heatSources[i].externalOutletHeight);
heatSources[i].externalOutletNodeIndex);
}

if (returnVal == HPWH_ABORT)
Expand Down Expand Up @@ -1880,8 +1880,8 @@ int HPWH::getExternalInletHeight() const
{
if (heatSources[i].configuration == HeatSource::CONFIG_EXTERNAL)
{
return heatSources[i].externalInletHeight; // Return the first one since all
// external sources have some ports
return heatSources[i].externalInletNodeIndex; // Return the first one since all
// external sources have some ports
}
}
return HPWH_ABORT;
Expand All @@ -1900,8 +1900,8 @@ int HPWH::getExternalOutletHeight() const
{
if (heatSources[i].configuration == HeatSource::CONFIG_EXTERNAL)
{
return heatSources[i].externalOutletHeight; // Return the first one since all
// external sources have some ports
return heatSources[i].externalOutletNodeIndex; // Return the first one since all
// external sources have some ports
}
}
return HPWH_ABORT;
Expand Down Expand Up @@ -1929,11 +1929,11 @@ int HPWH::getInletHeight(int whichInlet) const
{
if (whichInlet == 1)
{
return inletHeight;
return inletIndex;
}
else if (whichInlet == 2)
{
return inlet2Height;
return inlet2Index;
}
else
{
Expand Down Expand Up @@ -2570,7 +2570,7 @@ double HPWH::getCompressorCapacity(double airTemp /*=19.722*/,

double maxAllowedSetpoint_C =
heatSources[compressorIndex].maxSetpointT_C -
heatSources[compressorIndex].secondaryHeatExchanger.hotSideTemperatureOffset_dC;
heatSources[compressorIndex].secondaryHeatExchanger.hotSideOffsetT_C;
if (outTemp_C > maxAllowedSetpoint_C)
{
if (hpwhVerbosity >= VRB_reluctant)
Expand Down Expand Up @@ -3304,21 +3304,21 @@ void HPWH::updateTankTemps(double drawVolume_L,
double lowInletT_C;
double lowInletFraction; // fraction of draw from low inlet

if (inletHeight > inlet2Height)
if (inletIndex > inlet2Index)
{
highInletNodeIndex = inletHeight;
highInletNodeIndex = inletIndex;
highInletFraction = 1. - inletVol2_L / drawVolume_L;
highInletT_C = inletT_C;
lowInletNodeIndex = inlet2Height;
lowInletNodeIndex = inlet2Index;
lowInletT_C = inletT2_C;
lowInletFraction = inletVol2_L / drawVolume_L;
}
else
{
highInletNodeIndex = inlet2Height;
highInletNodeIndex = inlet2Index;
highInletFraction = inletVol2_L / drawVolume_L;
highInletT_C = inletT2_C;
lowInletNodeIndex = inletHeight;
lowInletNodeIndex = inletIndex;
lowInletT_C = inletT_C;
lowInletFraction = 1. - inletVol2_L / drawVolume_L;
}
Expand Down Expand Up @@ -3746,7 +3746,7 @@ void HPWH::addExtraHeat(std::vector<double>& extraHeatDist_W)
}
}
// Write the input & output energy
extraEnergyInput_kWh = BTU_TO_KWH(tot_qAdded_BTUperHr * minutesPerStep / min_per_hr);
extraEnergyInput_kJ = BTU_TO_KJ(tot_qAdded_BTUperHr * minutesPerStep / min_per_hr);
}

///////////////////////////////////////////////////////////////////////////////////
Expand Down Expand Up @@ -3876,12 +3876,12 @@ void HPWH::calcDerivedHeatingValues()
// find condentropy/shrinkage
for (int i = 0; i < getNumHeatSources(); ++i)
{
heatSources[i].Tshrinkage_C = findShrinkageT_C(heatSources[i].condensity);
heatSources[i].shrinkageT_C = findShrinkageT_C(heatSources[i].condensity);

if (hpwhVerbosity >= VRB_emetic)
{
msg(outputString, "Heat Source %d \n", i);
msg(outputString, "shrinkage %.2lf \n\n", heatSources[i].Tshrinkage_C);
msg(outputString, "shrinkage %.2lf \n\n", heatSources[i].shrinkageT_C);
}
}

Expand Down Expand Up @@ -4116,8 +4116,8 @@ int HPWH::checkInputs()
}
returnVal = HPWH_ABORT;
}
if (0 > heatSources[i].externalOutletHeight ||
heatSources[i].externalOutletHeight > getNumNodes() - 1)
if (0 > heatSources[i].externalOutletNodeIndex ||
heatSources[i].externalOutletNodeIndex > getNumNodes() - 1)
{
if (hpwhVerbosity >= VRB_reluctant)
{
Expand All @@ -4127,8 +4127,8 @@ int HPWH::checkInputs()
}
returnVal = HPWH_ABORT;
}
if (0 > heatSources[i].externalInletHeight ||
heatSources[i].externalInletHeight > getNumNodes() - 1)
if (0 > heatSources[i].externalInletNodeIndex ||
heatSources[i].externalInletNodeIndex > getNumNodes() - 1)
{
if (hpwhVerbosity >= VRB_reluctant)
{
Expand Down Expand Up @@ -4302,7 +4302,7 @@ bool HPWH::isEnergyBalanced(const double drawVol_L,
{
// Check energy balancing.
double qInElectrical_kJ = getInputEnergy_kJ();
double qInExtra_kJ = KWH_TO_KJ(extraEnergyInput_kWh);
double qInExtra_kJ = extraEnergyInput_kJ;
double qInHeatSourceEnviron_kJ = getEnergyRemovedFromEnvironment_kJ();
double qOutStandbyLosses_kJ = standbyLosses_kJ;
double qOutWater_kJ = drawVol_L * (outletT_C - member_inletT_C) * DENSITYWATER_kgperL *
Expand Down Expand Up @@ -5027,7 +5027,7 @@ int HPWH::HPWHinit_file(string configFile)
line_ss >> tempInt;
if (tempInt < num_nodes)
{
heatSources[heatsource].externalInletHeight = static_cast<int>(tempInt);
heatSources[heatsource].externalInletNodeIndex = static_cast<int>(tempInt);
}
else
{
Expand All @@ -5043,7 +5043,7 @@ int HPWH::HPWHinit_file(string configFile)
line_ss >> tempInt;
if (tempInt < num_nodes)
{
heatSources[heatsource].externalOutletHeight = static_cast<int>(tempInt);
heatSources[heatsource].externalOutletNodeIndex = static_cast<int>(tempInt);
}
else
{
Expand Down Expand Up @@ -5217,7 +5217,7 @@ int HPWH::HPWHinit_file(string configFile)
}
return HPWH_ABORT;
}
heatSources[heatsource].hysteresis_dC = tempDouble;
heatSources[heatsource].hysteresisOffsetT_C = tempDouble;
}
else if (token == "backupSource")
{
Expand Down
20 changes: 10 additions & 10 deletions src/HPWH.hh
Original file line number Diff line number Diff line change
Expand Up @@ -1006,7 +1006,7 @@ class HPWH
void addExtraHeat(std::vector<double>& extraHeatDist_W);

/// "extra" heat added during a simulation step
double extraEnergyInput_kWh;
double extraEnergyInput_kJ;

double tankAvg_C(const std::vector<NodeWeight> nodeWeights) const;
/**< functions to calculate what the temperature in a portion of the tank is */
Expand Down Expand Up @@ -1086,11 +1086,11 @@ class HPWH

/// index of the tank node where the inlet water enters
/// must be between 0 and numNodes-1
int inletHeight;
int inletIndex;

/// index of the tank node where the water from a 2nd inlet enters
/// must be between 0 and numNodes-1
int inlet2Height;
int inlet2Index;

/// the volume (L) of the tank
double tankVolume_L;
Expand Down Expand Up @@ -1366,11 +1366,11 @@ class HPWH::HeatSource
/// by specifying the entire condensity in one node.
std::vector<double> condensity;

/// Tshrinkage_C is a derived from the condentropy (conditional entropy),
/// shrinkageT_C is a derived from the condentropy (conditional entropy),
/// using the condensity and fixed parameters Talpha_C and Tbeta_C.
/// Talpha_C and Tbeta_C are not intended to be settable
/// see the hpwh_init functions for calculation of shrinkage.
double Tshrinkage_C;
double shrinkageT_C;

struct perfPoint
{
Expand Down Expand Up @@ -1437,8 +1437,8 @@ class HPWH::HeatSource
/// incoming waater temperature to the heatpump
struct SecondaryHeatExchanger
{
double coldSideTemperatureOffest_dC;
double hotSideTemperatureOffset_dC;
double coldSideOffsetT_C;
double hotSideOffsetT_C;
double extraPumpPower_W;
} secondaryHeatExchanger;

Expand Down Expand Up @@ -1473,7 +1473,7 @@ class HPWH::HeatSource
/// a hysteresis term that prevents short cycling due to heat pump self-interaction
/// when the heat source is engaged, it is subtracted from lowT cutoffs and
/// added to lowTreheat cutoffs
double hysteresis_dC;
double hysteresisOffsetT_C;

/// heat pumps can depress the temperature of their space in certain instances -
/// whether or not this occurs is a bool in HPWH, but a heat source must
Expand All @@ -1488,11 +1488,11 @@ class HPWH::HeatSource

/// The node height at which the external HPWH adds heated water to the storage tank.
/// Defaults to top for single pass.
int externalInletHeight;
int externalInletNodeIndex;

/// The node height at which the external HPWH takes cold water out of the storage tank.
/// Defaults to bottom for single pass.
int externalOutletHeight;
int externalOutletNodeIndex;

/// number of the first non-zero condensity entry
int lowestNode;
Expand Down
Loading

0 comments on commit 90e99ac

Please sign in to comment.