Skip to content

Commit

Permalink
Merge pull request #7717 from NREL/7711_WaterThermalTanks_Crash
Browse files Browse the repository at this point in the history
#7711 - Fix crash when using both WaterHeat:HeatPump:PumpedCondenser and WaterHeater:HeatPump:WrappedCondenser
  • Loading branch information
mitchute authored Feb 12, 2020
2 parents e9decd1 + feaedff commit 10696ef
Show file tree
Hide file tree
Showing 2 changed files with 748 additions and 15 deletions.
18 changes: 13 additions & 5 deletions src/EnergyPlus/WaterThermalTanks.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1035,6 +1035,9 @@ namespace WaterThermalTanks {
int nNumPossibleNumericArgs; // the number of possible numeric arguments in the idd
int nNumPossibleAlphaArgs; // the number of possible numeric arguments in the idd

// For looking up in IDF/epJSON, you need the index that corresponds to the actual object type (Pumped or Wrapped)
int HPWaterHeaterNumOfSpecificType;

for (int HPWaterHeaterNum = 1; HPWaterHeaterNum <= numHeatPumpWaterHeater; ++HPWaterHeaterNum) {

// Create reference to current HPWH object in array.
Expand All @@ -1043,25 +1046,30 @@ namespace WaterThermalTanks {
// Initialize the offsets to zero
nAlphaOffset = 0;
nNumericOffset = 0;

if (HPWaterHeaterNum <= NumPumpedCondenser) {
// Pumped Condenser
DataIPShortCuts::cCurrentModuleObject = cHPWHPumpedCondenser;
HPWH.TypeNum = DataPlant::TypeOf_HeatPumpWtrHeaterPumped;
nNumPossibleAlphaArgs = 29;
nNumPossibleNumericArgs = 9;
// Actual index of Pumped type
HPWaterHeaterNumOfSpecificType = HPWaterHeaterNum;
} else {
// Wrapped Condenser
DataIPShortCuts::cCurrentModuleObject = cHPWHWrappedCondenser;
HPWH.TypeNum = DataPlant::TypeOf_HeatPumpWtrHeaterWrapped;
nNumPossibleAlphaArgs = 27;
nNumPossibleNumericArgs = 10;
// Actual index of Wrapped type
HPWaterHeaterNumOfSpecificType = HPWaterHeaterNum - NumPumpedCondenser;
}

int NumAlphas;
int NumNums;
int IOStat;
inputProcessor->getObjectItem(DataIPShortCuts::cCurrentModuleObject,
HPWaterHeaterNum,
HPWaterHeaterNumOfSpecificType,
DataIPShortCuts::cAlphaArgs,
NumAlphas,
DataIPShortCuts::rNumericArgs,
Expand Down Expand Up @@ -11337,7 +11345,7 @@ namespace WaterThermalTanks {

// PURPOSE OF THIS SUBROUTINE:
// Calculates the water heater standard ratings, such as Energy Factor and Recovery Efficiency. Results are written
// to the EIO file. Standard ratings are not calculated for storage-only tanks, i.e., MaxCapacity = 0.
// to the EIO file. Standard ratings are not calculated for storage-only tanks, i.e., MaxCapacity = 0, nor for Integrated Heat Pumps

// METHODOLOGY EMPLOYED:
// Water heater inputs are set to the specified test conditions. For HPWHs, the heating capacity and COP are assumed
Expand Down Expand Up @@ -11378,7 +11386,6 @@ namespace WaterThermalTanks {
FirstTimeFlag = true;

int TimeStepPerHour = int(1.0 / DataHVACGlobals::TimeStepSys);
int HPNum = 0;
// Simulate 24 hour test
for (int Step = 1; Step <= TimeStepPerHour * 24; ++Step) {

Expand Down Expand Up @@ -11417,7 +11424,7 @@ namespace WaterThermalTanks {

} else {

HPNum = this->HeatPumpNum;
int HPNum = this->HeatPumpNum; // Convenience variable
Real64 AmbientHumRat = 0.00717; // Humidity ratio at 67.5 F / 50% RH

// set the heat pump air- and water-side mass flow rate
Expand Down Expand Up @@ -11679,7 +11686,8 @@ namespace WaterThermalTanks {
} else {
RecoveryEfficiency = 0.0;
EnergyFactor = 0.0;
if (HPWaterHeater.empty() || !HPWaterHeater(HPNum).bIsIHP) {
// If this a regular tank, or an HPWH that's not an Integrated one
if ((this->HeatPumpNum == 0) || !HPWaterHeater(this->HeatPumpNum).bIsIHP) {
ShowWarningError("Water heater = " + this->Name +
": Recovery Efficiency and Energy Factor could not be calculated during the test for standard ratings");
ShowContinueError("Setpoint was never recovered and/or heater never turned on");
Expand Down
Loading

7 comments on commit 10696ef

@nrel-bot-2b
Copy link

Choose a reason for hiding this comment

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

develop (mitchute) - x86_64-Linux-Ubuntu-18.04-gcc-7.4: OK (1974 of 1974 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot-2
Copy link

Choose a reason for hiding this comment

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

develop (mitchute) - x86_64-Linux-Ubuntu-18.04-cppcheck: OK (0 of 0 tests passed, 0 test warnings)

Build Badge

@nrel-bot-2b
Copy link

Choose a reason for hiding this comment

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

develop (mitchute) - x86_64-Linux-Ubuntu-18.04-custom_check: OK (11 of 11 tests passed, 0 test warnings)

Build Badge

@nrel-bot-2
Copy link

Choose a reason for hiding this comment

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

develop (mitchute) - x86_64-Linux-Ubuntu-18.04-gcc-7.4-UnitTestsCoverage-Debug: OK (1278 of 1278 tests passed, 0 test warnings)

Build Badge Test Badge Coverage Badge

@nrel-bot-2b
Copy link

Choose a reason for hiding this comment

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

develop (mitchute) - x86_64-Linux-Ubuntu-18.04-gcc-7.4-IntegrationCoverage-Debug: OK (678 of 679 tests passed, 0 test warnings)

Failures:\n

integration Test Summary

  • Passed: 678
  • Timeout: 1

Build Badge Test Badge Coverage Badge

@nrel-bot-3
Copy link

Choose a reason for hiding this comment

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

develop (mitchute) - x86_64-MacOS-10.13-clang: OK (1954 of 1954 tests passed, 0 test warnings)

Build Badge Test Badge

@nrel-bot
Copy link

Choose a reason for hiding this comment

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

develop (mitchute) - Win64-Windows-10-VisualStudio-16: OK (1954 of 1954 tests passed, 0 test warnings)

Build Badge Test Badge

Please sign in to comment.