Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Resolve warnings/errors for unreasonable DHW temperatures in Example Files #9078

Merged
merged 9 commits into from
Dec 9, 2021
140 changes: 83 additions & 57 deletions src/EnergyPlus/WaterUse.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1057,6 +1057,7 @@ namespace WaterUse {
// PURPOSE OF THIS SUBROUTINE:
// Calculate desired hot and cold water flow rates

Real64 TempDiff;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can declare and define all three diffs separately here, that way you don't have to calculate them once for the if statements and again within them.

Real64 constexpr EPSILON(1.e-3);

if (this->setupMyOutputVars) {
Expand Down Expand Up @@ -1116,49 +1117,65 @@ namespace WaterUse {
// There is no hot water
this->HotMassFlowRate = 0.0;

} else if ((this->ColdTemp - this->HotTemp) > EPSILON) {
// Special case for HotTemp < ColdTemp, due to bad user input (could happen in a plant loop accidentally)
} else if (this->ColdTemp > (this->HotTemp + EPSILON)) { //(HWCWTempDiff > EPSILON) {
// Cold temp is hotter than the hot water temp; bad user input
TempDiff = this->ColdTemp - this->HotTemp;
this->HotMassFlowRate = 0;
// print error for variables of hot water temperature
++this->HWTempErrorCount;
if (this->HWTempErrorCount < 2) {
ShowWarningError(state, "CalcEquipmentFlowRates: Hot water temperature is less than the cold water temperature");
ShowContinueErrorTimeStamp(state, "");
ShowContinueError(state, format("...hot water temperature = {:.3R} C", this->HotTemp));
ShowContinueError(state, format("...cold water temperature = {:.3R} C", this->ColdTemp));
ShowContinueError(state, "...Note: hot water temperature should be greater than or equal to the cold water temperature");
ShowContinueError(state,
"...Hot water temperature should be greater than or equal to the cold water temperature. "
"Verify temperature setpoints and schedules.");
} else {
ShowRecurringWarningErrorAtEnd(
state,
this->Name + "\" - Hot water temperature should be greater than or equal to the cold water temperature error continues...",
this->HWTempErrIndex,
this->HotTemp,
this->HotTemp);
if (!state.dataGlobal->WarmupFlag) {
// print error for variables of hot water temperature
++this->CWHWTempErrorCount;
if (this->CWHWTempErrorCount < 2) {
ShowWarningError(
state,
format("CalcEquipmentFlowRates: \"{}\" - Hot water temperature is less than the cold water temperature ({:.2R} C)",
this->Name,
TempDiff));
ShowContinueErrorTimeStamp(state, "");
ShowContinueError(state, format("...hot water temperature = {:.2R} C", this->HotTemp));
ShowContinueError(state, format("...cold water temperature = {:.2R} C", this->ColdTemp));
ShowContinueError(state, "...Note: hot water temperature should be greater than or equal to the cold water temperature");
ShowContinueError(state,
"...Hot water temperature should be greater than or equal to the cold water temperature. "
"Verify temperature setpoints and schedules.");
} else {
ShowRecurringWarningErrorAtEnd(
state,
format("\"{}\" - Hot water temperature should be greater than or equal to the cold water temperature error continues...",
this->Name),
this->CWHWTempErrIndex,
TempDiff,
TempDiff);
}
}
} else if ((this->TargetTemp - this->HotTemp) > EPSILON) {
} else if (this->TargetTemp > (this->HotTemp + EPSILON)) {
// Target temp is hotter than the hot water temp; can't meet target temperature
this->HotMassFlowRate = this->TotalMassFlowRate;
// print error for variables of target water temperature
++this->TargetTempErrorCount;
if (this->TargetTempErrorCount < 2) {
ShowWarningError(state, "CalcEquipmentFlowRates: Target water temperature is greater than the hot water temperature");
ShowContinueErrorTimeStamp(state, "");
ShowContinueError(state, format("...target water temperature = {:.3R} C", this->TargetTemp));
ShowContinueError(state, format("...hot water temperature = {:.3R} C", this->HotTemp));
ShowContinueError(state, "...Note: target water temperature should be less than or equal to the hot water temperature");
ShowContinueError(state,
"...Target water temperature should be less than or equal to the hot water temperature. "
"Verify temperature setpoints and schedules.");
} else {
ShowRecurringWarningErrorAtEnd(
state,
this->Name + "\" - Target water temperature should be less than or equal to the hot water temperature error continues...",
this->TargetTempErrIndex,
this->HotTemp,
this->ColdTemp);
TempDiff = this->TargetTemp - this->HotTemp;
if (!state.dataGlobal->WarmupFlag) {
// print error for variables of target water temperature
++this->TargetHWTempErrorCount;
if (this->TargetHWTempErrorCount < 2) {
ShowWarningError(
state,
format("CalcEquipmentFlowRates: \"{}\" - Target water temperature is greater than the hot water temperature ({:.2R} C)",
this->Name,
TempDiff));
ShowContinueErrorTimeStamp(state, "");
ShowContinueError(state, format("...target water temperature = {:.2R} C", this->TargetTemp));
ShowContinueError(state, format("...hot water temperature = {:.2R} C", this->HotTemp));
ShowContinueError(state, "...Note: target water temperature should be less than or equal to the hot water temperature");
ShowContinueError(state,
"...Target water temperature should be less than or equal to the hot water temperature. "
"Verify temperature setpoints and schedules.");
} else {
ShowRecurringWarningErrorAtEnd(
state,
format("\"{}\" - Target water temperature should be less than or equal to the hot water temperature error continues...",
this->Name),
this->TargetHWTempErrIndex,
TempDiff,
TempDiff);
}
}
} else {
this->HotMassFlowRate = this->TotalMassFlowRate * (this->TargetTemp - this->ColdTemp) / (this->HotTemp - this->ColdTemp);
Expand All @@ -1167,24 +1184,33 @@ namespace WaterUse {
if (this->HotMassFlowRate < 0.0) {
// Target temp is colder than the cold water temp; don't allow colder
this->HotMassFlowRate = 0.0;
// print error for variables of target water temperature
++this->TargetTempErrorCount;
if (this->TargetTempErrorCount < 2) {
ShowWarningError(state, "CalcEquipmentFlowRates: Target water temperature is less than the cold water temperature");
ShowContinueErrorTimeStamp(state, "");
ShowContinueError(state, format("...target water temperature = {:.3R} C", this->TargetTemp));
ShowContinueError(state, format("...cold water temperature = {:.3R} C", this->ColdTemp));
ShowContinueError(state, "...Note: target water temperature should be greater than or equal to the cold water temperature");
ShowContinueError(state,
"...Target water temperature should be greater than or equal to the cold water temperature. "
"Verify temperature setpoints and schedules.");
} else {
ShowRecurringWarningErrorAtEnd(
state,
this->Name + "\" - Target water temperature should be greater than or equal to the cold water temperature error continues...",
this->TargetTempErrIndex,
this->HotTemp,
this->ColdTemp);
TempDiff = this->ColdTemp - this->TargetTemp;
if (!state.dataGlobal->WarmupFlag) {
// print error for variables of target water temperature
++this->TargetCWTempErrorCount;
if (this->TargetCWTempErrorCount < 2) {
ShowWarningError(
state,
format("CalcEquipmentFlowRates: \"{}\" - Target water temperature is less than the cold water temperature ({:.2R} C)",
this->Name,
TempDiff));
ShowContinueErrorTimeStamp(state, "");
ShowContinueError(state, format("...target water temperature = {:.2R} C", this->TargetTemp));
ShowContinueError(state, format("...cold water temperature = {:.2R} C", this->ColdTemp));
ShowContinueError(state, "...Note: target water temperature should be greater than or equal to the cold water temperature");
ShowContinueError(state,
"...Target water temperature should be greater than or equal to the cold water temperature. "
"Verify temperature setpoints and schedules.");
} else {
ShowRecurringWarningErrorAtEnd(
state,
format(
"\"{}\" - Target water temperature should be greater than or equal to the cold water temperature error continues...",
this->Name),
this->TargetCWTempErrIndex,
TempDiff,
TempDiff);
}
}
}

Expand Down
24 changes: 13 additions & 11 deletions src/EnergyPlus/WaterUse.hh
Original file line number Diff line number Diff line change
Expand Up @@ -100,12 +100,14 @@ namespace WaterUse {
Real64 TargetTemp; // Target (mixed) water temperature (C)
Real64 MixedTemp; // Actual outlet (mixed) water temperature (C)
Real64 DrainTemp;
int HWTempErrorCount; // - counter if hot water temp is less than cold water temp
int HWTempErrIndex; // - index to recurring error structure for hot water temp
int TargetTempErrorCount; // - counter for target water temp error
int TargetTempErrIndex; // - index to recurring error structure for target water temp
int Zone; // Index for zone object
int SensibleFracSchedule; // Pointer to schedule object
int CWHWTempErrorCount; // - counter if hot water temp is less than cold water temp
int CWHWTempErrIndex; // - index to recurring error structure for hot water temp
int TargetHWTempErrorCount; // - counter for target water temp error
int TargetHWTempErrIndex; // - index to recurring error structure for target water temp
int TargetCWTempErrorCount; // - counter for target water temp error
int TargetCWTempErrIndex; // - index to recurring error structure for target water temp
int Zone; // Index for zone object
int SensibleFracSchedule; // Pointer to schedule object
Real64 SensibleRate;
Real64 SensibleEnergy;
Real64 SensibleRateNoMultiplier;
Expand All @@ -125,11 +127,11 @@ namespace WaterUse {
WaterEquipmentType()
: Connections(0), PeakVolFlowRate(0.0), FlowRateFracSchedule(0), ColdVolFlowRate(0.0), HotVolFlowRate(0.0), TotalVolFlowRate(0.0),
ColdMassFlowRate(0.0), HotMassFlowRate(0.0), TotalMassFlowRate(0.0), DrainMassFlowRate(0.0), ColdTempSchedule(0), HotTempSchedule(0),
TargetTempSchedule(0), ColdTemp(0.0), HotTemp(0.0), TargetTemp(0.0), MixedTemp(0.0), DrainTemp(0.0), HWTempErrorCount(0.0),
HWTempErrIndex(0.0), TargetTempErrorCount(0.0), TargetTempErrIndex(0.0), Zone(0), SensibleFracSchedule(0), SensibleRate(0.0),
SensibleEnergy(0.0), SensibleRateNoMultiplier(0.0), LatentFracSchedule(0), LatentRate(0.0), LatentEnergy(0.0),
LatentRateNoMultiplier(0.0), MoistureRate(0.0), MoistureMass(0.0), ColdVolume(0.0), HotVolume(0.0), TotalVolume(0.0), Power(0.0),
Energy(0.0), setupMyOutputVars(true)
TargetTempSchedule(0), ColdTemp(0.0), HotTemp(0.0), TargetTemp(0.0), MixedTemp(0.0), DrainTemp(0.0), CWHWTempErrorCount(0.0),
CWHWTempErrIndex(0.0), TargetHWTempErrorCount(0.0), TargetHWTempErrIndex(0.0), TargetCWTempErrorCount(0.0), TargetCWTempErrIndex(0.0),
Zone(0), SensibleFracSchedule(0), SensibleRate(0.0), SensibleEnergy(0.0), SensibleRateNoMultiplier(0.0), LatentFracSchedule(0),
LatentRate(0.0), LatentEnergy(0.0), LatentRateNoMultiplier(0.0), MoistureRate(0.0), MoistureMass(0.0), ColdVolume(0.0), HotVolume(0.0),
TotalVolume(0.0), Power(0.0), Energy(0.0), setupMyOutputVars(true)
{
}

Expand Down
Loading