diff --git a/src/EnergyPlus/RoomAirModelManager.cc b/src/EnergyPlus/RoomAirModelManager.cc index fd89474081d..da3cae900e5 100644 --- a/src/EnergyPlus/RoomAirModelManager.cc +++ b/src/EnergyPlus/RoomAirModelManager.cc @@ -2741,12 +2741,14 @@ namespace RoomAir { ReturnNodeNum = OutdoorAirUnit::GetOutdoorAirUnitReturnAirNode(state, EquipIndex); } break; case DataZoneEquipment::ZoneEquipType::PackagedTerminalAirConditioner: { // ZoneHVAC : PackagedTerminalAirConditioner - SupplyNodeNum = state.dataUnitarySystems->unitarySys[EquipIndex - 1].getAirOutNode(state, EquipName, 0, errorfound); - ReturnNodeNum = state.dataUnitarySystems->unitarySys[EquipIndex - 1].getAirInNode(state, EquipName, 0, errorfound); + EquipIndex = UnitarySystems::getIndex(state, EquipName, zoneEquipType, errorfound); + SupplyNodeNum = state.dataUnitarySystems->unitarySys[EquipIndex].AirOutNode; + ReturnNodeNum = state.dataUnitarySystems->unitarySys[EquipIndex].AirInNode; } break; case DataZoneEquipment::ZoneEquipType::PackagedTerminalHeatPump: { // ZoneHVAC : PackagedTerminalHeatPump - SupplyNodeNum = state.dataUnitarySystems->unitarySys[EquipIndex - 1].getAirOutNode(state, EquipName, 0, errorfound); - ReturnNodeNum = state.dataUnitarySystems->unitarySys[EquipIndex - 1].getAirInNode(state, EquipName, 0, errorfound); + EquipIndex = UnitarySystems::getIndex(state, EquipName, zoneEquipType, errorfound); + SupplyNodeNum = state.dataUnitarySystems->unitarySys[EquipIndex].AirOutNode; + ReturnNodeNum = state.dataUnitarySystems->unitarySys[EquipIndex].AirInNode; } break; case DataZoneEquipment::ZoneEquipType::UnitHeater: { // ZoneHVAC : UnitHeater ReturnNodeNum = UnitHeater::GetUnitHeaterAirInletNode(state, EquipIndex); @@ -2761,8 +2763,9 @@ namespace RoomAir { SupplyNodeNum = VentilatedSlab::GetVentilatedSlabZoneAirInNode(state, EquipIndex); } break; case DataZoneEquipment::ZoneEquipType::PackagedTerminalHeatPumpWaterToAir: { // ZoneHVAC : WaterToAirHeatPump - SupplyNodeNum = state.dataUnitarySystems->unitarySys[EquipIndex - 1].getAirOutNode(state, EquipName, 0, errorfound); - ReturnNodeNum = state.dataUnitarySystems->unitarySys[EquipIndex - 1].getAirInNode(state, EquipName, 0, errorfound); + EquipIndex = UnitarySystems::getIndex(state, EquipName, zoneEquipType, errorfound); + SupplyNodeNum = state.dataUnitarySystems->unitarySys[EquipIndex].AirOutNode; + ReturnNodeNum = state.dataUnitarySystems->unitarySys[EquipIndex].AirInNode; } break; case DataZoneEquipment::ZoneEquipType::WindowAirConditioner: { // ZoneHVAC : WindowAirConditioner ReturnNodeNum = WindowAC::GetWindowACReturnAirNode(state, EquipIndex); diff --git a/src/EnergyPlus/UnitarySystem.cc b/src/EnergyPlus/UnitarySystem.cc index 4cfd27cdd93..e4ee05808fa 100644 --- a/src/EnergyPlus/UnitarySystem.cc +++ b/src/EnergyPlus/UnitarySystem.cc @@ -16581,6 +16581,25 @@ namespace UnitarySystems { return airNode; } + int + getIndex(EnergyPlusData &state, std::string const &UnitarySysName, DataZoneEquipment::ZoneEquipType zoneEquipType, bool &errFlag) + { + + int EquipIndex = 0; + for (int UnitarySysNum = 0; UnitarySysNum < state.dataUnitarySystems->numUnitarySystems; ++UnitarySysNum) { + if (Util::SameString(UnitarySysName, state.dataUnitarySystems->unitarySys[UnitarySysNum].Name)) { + if (zoneEquipType == DataZoneEquipment::ZoneEquipType::PackagedTerminalAirConditioner || + zoneEquipType == DataZoneEquipment::ZoneEquipType::PackagedTerminalHeatPump || + zoneEquipType == DataZoneEquipment::ZoneEquipType::PackagedTerminalHeatPumpWaterToAir) { + EquipIndex = UnitarySysNum; + break; + } + } + } + if (EquipIndex < 0) errFlag = true; + return EquipIndex; + } + int UnitarySys::getAirOutNode(EnergyPlusData &state, std::string_view UnitarySysName, int const ZoneOAUnitNum, bool &errFlag) { if (state.dataUnitarySystems->getInputOnceFlag) { diff --git a/src/EnergyPlus/UnitarySystem.hh b/src/EnergyPlus/UnitarySystem.hh index c3e906298f6..d602f20dc2e 100644 --- a/src/EnergyPlus/UnitarySystem.hh +++ b/src/EnergyPlus/UnitarySystem.hh @@ -966,6 +966,8 @@ namespace UnitarySystems { void setupAllOutputVars(EnergyPlusData &state, int const numAllSystemTypes); void isWaterCoilHeatRecoveryType(EnergyPlusData const &state, int const waterCoilNodeNum, bool &nodeNotFound); + int getIndex(EnergyPlusData &state, std::string const &UnitarySysName, DataZoneEquipment::ZoneEquipType zoneEquipType, bool &errFlag); + } // namespace UnitarySystems struct UnitarySystemsData : BaseGlobalStruct {