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

Fix PTHP hard crash when autosizing is requested but no sizing run was done #8813

Merged
merged 8 commits into from
Jun 23, 2021
1 change: 1 addition & 0 deletions src/EnergyPlus/PackagedTerminalHeatPump.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5426,6 +5426,7 @@ void SizePTUnit(EnergyPlusData &state, int const PTUnitNum)

// initialize OA flow for sizing other inputs (e.g., capacity)
if (state.dataPTHP->PTUnit(PTUnitNum).CoolOutAirVolFlow == AutoSize) {
CheckZoneSizing(state, state.dataPTHP->PTUnit(PTUnitNum).UnitType, state.dataPTHP->PTUnit(PTUnitNum).Name);
ZoneEqSizing(state.dataSize->CurZoneEqNum).OAVolFlow = state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).MinOA;
} else {
ZoneEqSizing(state.dataSize->CurZoneEqNum).OAVolFlow = state.dataPTHP->PTUnit(PTUnitNum).CoolOutAirVolFlow;
Expand Down
29 changes: 24 additions & 5 deletions tst/EnergyPlus/unit/PackagedTerminalHeatPump.unit.cc
Original file line number Diff line number Diff line change
Expand Up @@ -439,16 +439,35 @@ TEST_F(EnergyPlusFixture, PackagedTerminalHP_VSCoils_Sizing)

ASSERT_TRUE(process_idf(idf_objects));

// Test for #7053:
// Fake that there is at least one UnitarySystemPerformance:Multispeed object
UnitarySystems::DesignSpecMSHP fakeDesignSpecMSHP;
state->dataUnitarySystems->designSpecMSHP.push_back(fakeDesignSpecMSHP);

bool ErrorsFound(false);
GetZoneData(*state, ErrorsFound);
GetZoneEquipmentData(*state);
GetPTUnit(*state);

// Test for #8812:
// Verify zone sizing check if airflow is Autosized to prevent hard crash
state->dataSize->CurZoneEqNum = 1;
state->dataSize->ZoneSizingRunDone = false;
state->dataPTHP->PTUnit(1).HVACSizingIndex = 0;
state->dataPTHP->PTUnit(1).CoolOutAirVolFlow = AutoSize;
EXPECT_THROW(SizePTUnit(*state, 1), std::runtime_error);
std::string const error_string = delimited_string({
" ** Severe ** For autosizing of ZoneHVAC:WaterToAirHeatPump ZONE WSHP, a zone sizing run must be done.",
" ** ~~~ ** No \"Sizing:Zone\" objects were entered.",
" ** ~~~ ** The \"SimulationControl\" object did not have the field \"Do Zone Sizing Calculation\" set to Yes.",
" ** Fatal ** Program terminates due to previously shown condition(s).",
" ...Summary of Errors that led to program termination:",
" ..... Reference severe error count=1",
" ..... Last severe error=For autosizing of ZoneHVAC:WaterToAirHeatPump ZONE WSHP, a zone sizing run must be done.",
});

EXPECT_TRUE(compare_err_stream(error_string, true));

// Test for #7053:
// Fake that there is at least one UnitarySystemPerformance:Multispeed object
UnitarySystems::DesignSpecMSHP fakeDesignSpecMSHP;
state->dataUnitarySystems->designSpecMSHP.push_back(fakeDesignSpecMSHP);

state->dataPlnt->TotNumLoops = 2;
state->dataPlnt->PlantLoop.allocate(state->dataPlnt->TotNumLoops);

Expand Down