From b0db80055fbb862803a3400098cbaa06ba557f16 Mon Sep 17 00:00:00 2001 From: Lixing Gu Date: Thu, 28 Mar 2024 10:46:56 -0400 Subject: [PATCH 01/57] Upload a fix --- src/EnergyPlus/RoomAirModelManager.cc | 238 +++++++++--------- src/EnergyPlus/RoomAirModelManager.hh | 2 +- .../unit/RoomAirflowNetwork.unit.cc | 160 ++++++++++++ 3 files changed, 280 insertions(+), 120 deletions(-) diff --git a/src/EnergyPlus/RoomAirModelManager.cc b/src/EnergyPlus/RoomAirModelManager.cc index d7aa8ac9986..4c968a81d1e 100644 --- a/src/EnergyPlus/RoomAirModelManager.cc +++ b/src/EnergyPlus/RoomAirModelManager.cc @@ -58,6 +58,7 @@ // EnergyPlus Headers #include +#include #include #include #include @@ -71,19 +72,30 @@ #include #include #include +#include #include #include +#include +#include #include #include #include +#include #include #include +#include #include #include #include #include #include +#include +#include #include +#include +#include +#include +#include #include namespace EnergyPlus { @@ -1635,11 +1647,20 @@ namespace RoomAir { roomAFNNodeHVAC.SupplyFraction = ipsc->rNumericArgs(iEquipArg); roomAFNNodeHVAC.ReturnFraction = ipsc->rNumericArgs(iEquipArg); + // get equipment index + int EquipIndex = 0; + for (int thisZoneEquipNum = 1; thisZoneEquipNum <= state.dataZoneEquip->ZoneEquipList(iZone).NumOfEquipTypes; + ++thisZoneEquipNum) { + if (Util::SameString(state.dataZoneEquip->ZoneEquipList(iZone).EquipName(thisZoneEquipNum), roomAFNNodeHVAC.Name)) { + EquipIndex = state.dataZoneEquip->ZoneEquipList(iZone).EquipIndex(thisZoneEquipNum); + break; + } + } IntEquipError = CheckEquipName(state, roomAFNNodeHVAC.Name, roomAFNNodeHVAC.SupplyNodeName, roomAFNNodeHVAC.ReturnNodeName, - TotNumEquip, + EquipIndex, roomAFNNodeHVAC.zoneEquipType); if (!IntEquipError) { @@ -2676,7 +2697,7 @@ namespace RoomAir { std::string const &EquipName, // Equipment Name std::string &SupplyNodeName, // Supply node name std::string &ReturnNodeName, // Return node name - int TotNumEquip, // how many of this equipment type + int EquipIndex, // Equipment index DataZoneEquipment::ZoneEquipType zoneEquipType) { @@ -2693,210 +2714,188 @@ namespace RoomAir { using Fans::GetFanOutletNode; // Return value - bool EquipFind; // True if an error is found + bool EquipFind = false; // if true, equip is found - // FUNCTION LOCAL VARIABLE DECLARATIONS: - int NumAlphas; - int NumNumbers; - int Status; // Used in GetObjectItem - int MaxNums = 0; // Maximum number of numeric input fields - int MaxAlphas = 0; // Maximum number of alpha input fields - int TotalArgs = 0; // Total number of alpha and numeric arguments(max) for a - Array1D_string Alphas; // Alpha input items for object - Array1D Numbers; // Numeric input items for object bool errorfound; - - NumAlphas = 1; - NumNumbers = 1; - EquipFind = false; + int SupplyNodeNum = 0; + int ReturnNodeNum = 0; SupplyNodeName = ""; if (zoneEquipType == DataZoneEquipment::ZoneEquipType::Invalid) return EquipFind; - std::string_view equipTypeName = DataZoneEquipment::zoneEquipTypeNamesUC[(int)zoneEquipType]; - state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, equipTypeName, TotalArgs, NumAlphas, NumNumbers); - - MaxNums = max(MaxNums, NumNumbers); - MaxAlphas = max(MaxAlphas, NumAlphas); - - if (MaxNums > NumNumbers) { - Numbers.allocate(MaxNums); - Numbers = 0.0; - } else if (!allocated(Numbers)) { - Numbers.allocate(MaxNums); - } - - if (MaxAlphas > NumAlphas) { - Alphas.allocate(MaxAlphas); - Alphas = ""; - } else if (!allocated(Alphas)) { - Alphas.allocate(NumAlphas); - } - - for (int I = 1; I <= TotNumEquip; ++I) { - state.dataInputProcessing->inputProcessor->getObjectItem(state, equipTypeName, I, Alphas, NumAlphas, Numbers, NumNumbers, Status); - if (Util::SameString(Alphas(1), EquipName)) { - EquipFind = true; - break; - } - } - switch (zoneEquipType) { case DataZoneEquipment::ZoneEquipType::VariableRefrigerantFlowTerminal: { // ZoneHVAC:TerminalUnit : VariableRefrigerantFlow - SupplyNodeName = Alphas(4); - ReturnNodeName = ""; // Zone return node + SupplyNodeNum = HVACVariableRefrigerantFlow::GetVRFTUZoneInletAirNode(state, EquipIndex); } break; case DataZoneEquipment::ZoneEquipType::EnergyRecoveryVentilator: { // ZoneHVAC : EnergyRecoveryVentilator - int nodeNum = GetFanOutletNode(state, "Fan:OnOff", Alphas(4), errorfound); - if (errorfound) { - } - SupplyNodeName = state.dataLoopNodes->NodeID(nodeNum); // ????? - ReturnNodeName = ""; // Zone exhaust node + SupplyNodeNum = GetFanOutletNode(state, "Fan:OnOff", EquipName, errorfound); } break; case DataZoneEquipment::ZoneEquipType::FourPipeFanCoil: { // ZoneHVAC : FourPipeFanCoil - SupplyNodeName = Alphas(6); - ReturnNodeName = Alphas(5); + SupplyNodeNum = state.dataFanCoilUnits->FanCoil(EquipIndex).AirOutNode; + ReturnNodeNum = state.dataFanCoilUnits->FanCoil(EquipIndex).AirInNode; } break; case DataZoneEquipment::ZoneEquipType::OutdoorAirUnit: { // ZoneHVAC : OutdoorAirUnit - SupplyNodeName = Alphas(13); - ReturnNodeName = Alphas(14); + SupplyNodeNum = state.dataOutdoorAirUnit->OutAirUnit(EquipIndex).AirOutletNode; + ReturnNodeNum = state.dataOutdoorAirUnit->OutAirUnit(EquipIndex).AirInletNode; } break; case DataZoneEquipment::ZoneEquipType::PackagedTerminalAirConditioner: { // ZoneHVAC : PackagedTerminalAirConditioner - SupplyNodeName = Alphas(4); - ReturnNodeName = Alphas(3); + SupplyNodeNum = state.dataUnitarySystems->unitarySys[EquipIndex - 1].getAirOutNode(state, EquipName, 0, errorfound); + ReturnNodeNum = state.dataUnitarySystems->unitarySys[EquipIndex - 1].getAirInNode(state, EquipName, 0, errorfound); } break; case DataZoneEquipment::ZoneEquipType::PackagedTerminalHeatPump: { // ZoneHVAC : PackagedTerminalHeatPump - SupplyNodeName = Alphas(4); - ReturnNodeName = Alphas(3); + SupplyNodeNum = state.dataUnitarySystems->unitarySys[EquipIndex - 1].getAirOutNode(state, EquipName, 0, errorfound); + ReturnNodeNum = state.dataUnitarySystems->unitarySys[EquipIndex - 1].getAirInNode(state, EquipName, 0, errorfound); } break; case DataZoneEquipment::ZoneEquipType::UnitHeater: { // ZoneHVAC : UnitHeater - SupplyNodeName = Alphas(4); - ReturnNodeName = Alphas(3); + ReturnNodeNum = state.dataUnitHeaters->UnitHeat(EquipIndex).AirInNode; + SupplyNodeNum = state.dataUnitHeaters->UnitHeat(EquipIndex).AirOutNode; } break; case DataZoneEquipment::ZoneEquipType::UnitVentilator: { // ZoneHVAC : UnitVentilator - SupplyNodeName = Alphas(7); - ReturnNodeName = Alphas(6); + ReturnNodeNum = state.dataUnitVentilators->UnitVent(EquipIndex).AirInNode; + SupplyNodeNum = state.dataUnitVentilators->UnitVent(EquipIndex).AirOutNode; } break; case DataZoneEquipment::ZoneEquipType::VentilatedSlab: { // ZoneHVAC : VentilatedSlab - SupplyNodeName = Alphas(20); - ReturnNodeName = Alphas(18); + ReturnNodeNum = state.dataVentilatedSlab->VentSlab(EquipIndex).ReturnAirNode; + SupplyNodeNum = state.dataVentilatedSlab->VentSlab(EquipIndex).ZoneAirInNode; } break; case DataZoneEquipment::ZoneEquipType::PackagedTerminalHeatPumpWaterToAir: { // ZoneHVAC : WaterToAirHeatPump - SupplyNodeName = Alphas(4); - ReturnNodeName = Alphas(3); + SupplyNodeNum = state.dataUnitarySystems->unitarySys[EquipIndex - 1].getAirOutNode(state, EquipName, 0, errorfound); + ReturnNodeNum = state.dataUnitarySystems->unitarySys[EquipIndex - 1].getAirInNode(state, EquipName, 0, errorfound); } break; case DataZoneEquipment::ZoneEquipType::WindowAirConditioner: { // ZoneHVAC : WindowAirConditioner - SupplyNodeName = Alphas(4); - ReturnNodeName = Alphas(3); + ReturnNodeNum = state.dataWindowAC->WindAC(EquipIndex).AirInNode; + SupplyNodeNum = state.dataWindowAC->WindAC(EquipIndex).AirOutNode; } break; case DataZoneEquipment::ZoneEquipType::BaseboardElectric: { // ZoneHVAC : Baseboard : RadiantConvective : Electric + // convective equipment without node connection. Will handle later SupplyNodeName = ""; // convection only } break; case DataZoneEquipment::ZoneEquipType::BaseboardWater: { // ZoneHVAC : Baseboard : RadiantConvective : Water + // convective equipment without node connection. Will handle later SupplyNodeName = ""; } break; case DataZoneEquipment::ZoneEquipType::BaseboardSteam: { // ZoneHVAC : Baseboard : RadiantConvective : Steam + // convective equipment without node connection. Will handle later SupplyNodeName = ""; } break; case DataZoneEquipment::ZoneEquipType::BaseboardConvectiveElectric: { // ZoneHVAC : Baseboard : Convective : Electric + // convective equipment without node connection. Will handle later SupplyNodeName = ""; } break; case DataZoneEquipment::ZoneEquipType::BaseboardConvectiveWater: { // ZoneHVAC : Baseboard : Convective : Water + // convective equipment without node connection. Will handle later SupplyNodeName = ""; } break; case DataZoneEquipment::ZoneEquipType::HighTemperatureRadiant: { // ZoneHVAC : HighTemperatureRadiant + // Radiative equipment without node connection. Will handle later SupplyNodeName = ""; } break; case DataZoneEquipment::ZoneEquipType::DehumidifierDX: { // ZoneHVAC : Dehumidifier : DX - SupplyNodeName = Alphas(4); - ReturnNodeName = Alphas(3); + ReturnNodeNum = state.dataZoneDehumidifier->ZoneDehumid(EquipIndex).AirInletNodeNum; + SupplyNodeNum = state.dataZoneDehumidifier->ZoneDehumid(EquipIndex).AirOutletNodeNum; } break; case DataZoneEquipment::ZoneEquipType::PurchasedAir: { // ZoneHVAC : IdealLoadsAirSystem - SupplyNodeName = Alphas(3); - ReturnNodeName = Alphas(4); + ReturnNodeNum = state.dataPurchasedAirMgr->PurchAir(EquipIndex).ZoneExhaustAirNodeNum; + SupplyNodeNum = state.dataPurchasedAirMgr->PurchAir(EquipIndex).ZoneSupplyAirNodeNum; } break; case DataZoneEquipment::ZoneEquipType::RefrigerationChillerSet: { // ZoneHVAC : RefrigerationChillerSet - SupplyNodeName = Alphas(5); - ReturnNodeName = Alphas(4); + // May not apply + // SupplyNodeName = Alphas(5); + // ReturnNodeName = Alphas(4); } break; case DataZoneEquipment::ZoneEquipType::HybridEvaporativeCooler: { // ZoneHVAC : HybridUnitaryAirConditioners - SupplyNodeName = Alphas(11); - ReturnNodeName = Alphas(9); + ReturnNodeNum = state.dataHybridUnitaryAC->ZoneHybridUnitaryAirConditioner(EquipIndex).InletNode; + SupplyNodeNum = state.dataHybridUnitaryAC->ZoneHybridUnitaryAirConditioner(EquipIndex).OutletNode; } break; case DataZoneEquipment::ZoneEquipType::ExhaustFan: { // Fan : ZoneExhaust - SupplyNodeName = ""; // ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? May not use + + // SupplyNodeName = ""; // ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? May not use } break; case DataZoneEquipment::ZoneEquipType::HeatPumpWaterHeater: { // WaterHeater : HeatPump - SupplyNodeName = Alphas(8); - ReturnNodeName = Alphas(7); + ReturnNodeNum = state.dataWaterThermalTanks->HPWaterHeater(EquipIndex).HeatPumpAirInletNode; + SupplyNodeNum = state.dataWaterThermalTanks->HPWaterHeater(EquipIndex).HeatPumpAirOutletNode; // For AirTerminals, find matching return node later } break; case DataZoneEquipment::ZoneEquipType::AirTerminalDualDuctConstantVolume: { // AirTerminal : DualDuct : ConstantVolume - SupplyNodeName = Alphas(1); - ReturnNodeName = ""; + // Air teminal components are handled later + // SupplyNodeName = Alphas(1); + // ReturnNodeName = ""; } break; case DataZoneEquipment::ZoneEquipType::AirTerminalDualDuctVAV: { // AirTerminal : DualDuct : VAV - SupplyNodeName = Alphas(1); - ReturnNodeName = ""; + // Air teminal components are handled later + // SupplyNodeName = Alphas(1); + // ReturnNodeName = ""; } break; case DataZoneEquipment::ZoneEquipType::AirTerminalSingleDuctConstantVolumeReheat: { // AirTerminal : SingleDuct : ConstantVolume : Reheat - SupplyNodeName = Alphas(1); - ReturnNodeName = ""; + // Air teminal components are handled later + // SupplyNodeName = Alphas(1); + // ReturnNodeName = ""; } break; case DataZoneEquipment::ZoneEquipType::AirTerminalSingleDuctConstantVolumeNoReheat: { // AirTerminal : SingleDuct : - // ConstantVolume : NoReheat - SupplyNodeName = Alphas(4); - ReturnNodeName = ""; + // Air teminal components are handled later + // SupplyNodeName = Alphas(4); + // ReturnNodeName = ""; } break; case DataZoneEquipment::ZoneEquipType::AirTerminalSingleDuctVAVReheat: { // AirTerminal : SingleDuct : VAV : Reheat - SupplyNodeName = Alphas(1); - ReturnNodeName = ""; + // Air teminal components are handled later + // SupplyNodeName = Alphas(1); + // ReturnNodeName = ""; } break; case DataZoneEquipment::ZoneEquipType::AirTerminalSingleDuctVAVNoReheat: { // AirTerminal : SingleDuct : VAV : NoReheat - SupplyNodeName = Alphas(1); - ReturnNodeName = ""; + // Air teminal components are handled later + // SupplyNodeName = Alphas(1); + // ReturnNodeName = ""; } break; case DataZoneEquipment::ZoneEquipType::AirTerminalSingleDuctSeriesPIUReheat: { // AirTerminal : SingleDuct : SeriesPIU : Reheat - SupplyNodeName = Alphas(1); - ReturnNodeName = ""; + // Air teminal components are handled later + // SupplyNodeName = Alphas(1); + // ReturnNodeName = ""; } break; case DataZoneEquipment::ZoneEquipType::AirTerminalSingleDuctParallelPIUReheat: { // AirTerminal : SingleDuct : ParallelPIU : Reheat - SupplyNodeName = Alphas(1); - ReturnNodeName = ""; + // Air teminal components are handled later + // SupplyNodeName = Alphas(1); + // ReturnNodeName = ""; } break; case DataZoneEquipment::ZoneEquipType::AirTerminalSingleDuctCAVFourPipeInduction: { // AirTerminal : SingleDuct : - // ConstantVolume : FourPipeInduction - SupplyNodeName = Alphas(1); - ReturnNodeName = ""; + // Air teminal components are handled later + // ConstantVolume : FourPipeInduction + // SupplyNodeName = Alphas(1); + // ReturnNodeName = ""; } break; case DataZoneEquipment::ZoneEquipType::AirTerminalSingleDuctVAVReheatVariableSpeedFan: { // AirTerminal : SingleDuct : VAV - // : Reheat : VariableSpeedFan - SupplyNodeName = Alphas(1); - ReturnNodeName = ""; + // Air teminal components are handled later + // : Reheat : VariableSpeedFan + // SupplyNodeName = Alphas(1); + // ReturnNodeName = ""; } break; case DataZoneEquipment::ZoneEquipType::AirTerminalSingleDuctVAVHeatAndCoolReheat: { // AirTerminal : SingleDuct : VAV : // HeatAndCool : Reheat - SupplyNodeName = Alphas(1); - ReturnNodeName = ""; + // Air teminal components are handled later + // SupplyNodeName = Alphas(1); + // ReturnNodeName = ""; } break; case DataZoneEquipment::ZoneEquipType::AirTerminalSingleDuctVAVHeatAndCoolNoReheat: { // AirTerminal : SingleDuct : VAV : // HeatAndCool : NoReheat - SupplyNodeName = Alphas(1); - ReturnNodeName = ""; + // Air teminal components are handled later + // SupplyNodeName = Alphas(1); + // ReturnNodeName = ""; } break; case DataZoneEquipment::ZoneEquipType::AirTerminalSingleDuctConstantVolumeCooledBeam: { // AirTerminal : SingleDuct : // ConstantVolume : CooledBeam - SupplyNodeName = Alphas(5); - ReturnNodeName = ""; + // Air teminal components are handled later + // SupplyNodeName = Alphas(5); + // ReturnNodeName = ""; } break; case DataZoneEquipment::ZoneEquipType::AirTerminalDualDuctVAVOutdoorAir: { // AirTerminal : DualDuct : VAV : OutdoorAir - SupplyNodeName = Alphas(3); - ReturnNodeName = ""; + // Air teminal components are handled later + // SupplyNodeName = Alphas(3); + // ReturnNodeName = ""; } break; case DataZoneEquipment::ZoneEquipType::AirLoopHVACReturnAir: { // AirLoopHVACReturnAir - SupplyNodeName = Alphas(4); // - ReturnNodeName = ""; // + // Air teminal components are handled later + // SupplyNodeName = Alphas(4); // + // ReturnNodeName = ""; // } break; default: { assert(false); @@ -2904,14 +2903,15 @@ namespace RoomAir { } // switch - // Need to find a better to handle allocate and deallocate - if (MaxAlphas > NumAlphas) { - Alphas.deallocate(); + if (SupplyNodeNum > 0) { + SupplyNodeName = state.dataLoopNodes->NodeID(SupplyNodeNum); + EquipFind = true; } - if (MaxNums > NumNumbers) { - Numbers.deallocate(); + if (ReturnNodeNum > 0) { + ReturnNodeName = state.dataLoopNodes->NodeID(ReturnNodeNum); + } else { + ReturnNodeName = ""; } - return EquipFind; } diff --git a/src/EnergyPlus/RoomAirModelManager.hh b/src/EnergyPlus/RoomAirModelManager.hh index 3b5f3b9751d..bf030e7fdd0 100644 --- a/src/EnergyPlus/RoomAirModelManager.hh +++ b/src/EnergyPlus/RoomAirModelManager.hh @@ -89,7 +89,7 @@ namespace RoomAir { std::string const &EquipName, // Equipment Name std::string &SupplyNodeName, // Supply node name std::string &ReturnNodeName, // Return node name - int TotNumEquip, // how many of this equipment type + int EquipIndex, // Equipment index DataZoneEquipment::ZoneEquipType zoneEquipType); // equipment type number } // namespace RoomAir diff --git a/tst/EnergyPlus/unit/RoomAirflowNetwork.unit.cc b/tst/EnergyPlus/unit/RoomAirflowNetwork.unit.cc index 17e86e9a5c0..7393e698b6d 100644 --- a/tst/EnergyPlus/unit/RoomAirflowNetwork.unit.cc +++ b/tst/EnergyPlus/unit/RoomAirflowNetwork.unit.cc @@ -53,6 +53,7 @@ // EnergyPlus Headers #include "Fixtures/EnergyPlusFixture.hh" #include +#include #include #include #include @@ -67,14 +68,34 @@ #include #include #include +#include +#include +#include +#include #include +#include +#include +#include #include #include +#include +#include +#include #include +#include #include #include +#include #include #include +#include +#include +#include +#include +#include +#include +#include +#include #include #include @@ -579,3 +600,142 @@ TEST_F(EnergyPlusFixture, RoomAirInternalGains_InternalHeatGains_Check) EXPECT_TRUE(compare_err_stream(error_string, true)); } + +TEST_F(EnergyPlusFixture, RoomAirflowNetwork_CheckEquipName_Test) +{ + // Test #6321 + bool check; + std::string const EquipName = "ZoneEquip"; + std::string SupplyNodeName; + std::string ReturnNodeName; + int TotNumEquip = 1; + int EquipIndex = 1; // Equipment index + DataZoneEquipment::ZoneEquipType zoneEquipType; + + state->dataLoopNodes->NodeID.allocate(2); + state->dataLoopNodes->Node.allocate(2); + state->dataLoopNodes->NodeID(1) = "SupplyNode"; + state->dataLoopNodes->NodeID(2) = "ReturnNode"; + + state->dataHVACVarRefFlow->GetVRFInputFlag = false; + state->dataHVACVarRefFlow->VRFTU.allocate(1); + state->dataHVACVarRefFlow->VRFTU(1).VRFTUOutletNodeNum = 1; + + zoneEquipType = DataZoneEquipment::ZoneEquipType::VariableRefrigerantFlowTerminal; + state->dataHVACVarRefFlow->NumVRFTU = 1; + check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); + if (check) { + EXPECT_EQ("SupplyNode", SupplyNodeName); + } + + zoneEquipType = DataZoneEquipment::ZoneEquipType::EnergyRecoveryVentilator; + state->dataFans->GetFanInputFlag = false; + state->dataFans->Fan.allocate(1); + state->dataFans->Fan(1).FanName = EquipName; + state->dataFans->Fan(1).OutletNodeNum = 1; + check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); + if (check) { + EXPECT_EQ("SupplyNode", SupplyNodeName); + } + + zoneEquipType = DataZoneEquipment::ZoneEquipType::FourPipeFanCoil; + state->dataFanCoilUnits->FanCoil.allocate(1); + state->dataFanCoilUnits->FanCoil(EquipIndex).AirOutNode = 1; + state->dataFanCoilUnits->FanCoil(EquipIndex).AirInNode = 2; + check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); + if (check) { + EXPECT_EQ("SupplyNode", SupplyNodeName); + EXPECT_EQ("ReturnNode", ReturnNodeName); + } + + zoneEquipType = DataZoneEquipment::ZoneEquipType::OutdoorAirUnit; + state->dataOutdoorAirUnit->OutAirUnit.allocate(1); + state->dataOutdoorAirUnit->OutAirUnit(EquipIndex).AirOutletNode = 1; + state->dataOutdoorAirUnit->OutAirUnit(EquipIndex).AirInletNode = 2; + check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); + if (check) { + EXPECT_EQ("SupplyNode", SupplyNodeName); + EXPECT_EQ("ReturnNode", ReturnNodeName); + } + + zoneEquipType = DataZoneEquipment::ZoneEquipType::PackagedTerminalAirConditioner; + UnitarySystems::UnitarySys thisUnit; + state->dataUnitarySystems->unitarySys.push_back(thisUnit); + state->dataUnitarySystems->getInputOnceFlag = false; + state->dataUnitarySystems->unitarySys[EquipIndex - 1].Name = EquipName; + state->dataUnitarySystems->numUnitarySystems = 1; + state->dataUnitarySystems->unitarySys[EquipIndex - 1].AirOutNode = 1; + state->dataUnitarySystems->unitarySys[EquipIndex - 1].AirInNode = 2; + check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); + if (check) { + EXPECT_EQ("SupplyNode", SupplyNodeName); + EXPECT_EQ("ReturnNode", ReturnNodeName); + } + + zoneEquipType = DataZoneEquipment::ZoneEquipType::PackagedTerminalHeatPump; + // UnitarySystems::UnitarySys thisUnit; + // state->dataUnitarySystems->unitarySys.push_back(thisUnit); + state->dataUnitarySystems->getInputOnceFlag = false; + state->dataUnitarySystems->unitarySys[EquipIndex - 1].Name = EquipName; + state->dataUnitarySystems->numUnitarySystems = 1; + state->dataUnitarySystems->unitarySys[EquipIndex - 1].AirOutNode = 1; + state->dataUnitarySystems->unitarySys[EquipIndex - 1].AirInNode = 2; + check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); + if (check) { + EXPECT_EQ("SupplyNode", SupplyNodeName); + EXPECT_EQ("ReturnNode", ReturnNodeName); + } + zoneEquipType = DataZoneEquipment::ZoneEquipType::PackagedTerminalHeatPumpWaterToAir; + // UnitarySystems::UnitarySys thisUnit; + // state->dataUnitarySystems->unitarySys.push_back(thisUnit); + state->dataUnitarySystems->getInputOnceFlag = false; + state->dataUnitarySystems->unitarySys[EquipIndex - 1].Name = EquipName; + state->dataUnitarySystems->numUnitarySystems = 1; + state->dataUnitarySystems->unitarySys[EquipIndex - 1].AirOutNode = 1; + state->dataUnitarySystems->unitarySys[EquipIndex - 1].AirInNode = 2; + check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); + if (check) { + EXPECT_EQ("SupplyNode", SupplyNodeName); + EXPECT_EQ("ReturnNode", ReturnNodeName); + } + + zoneEquipType = DataZoneEquipment::ZoneEquipType::UnitHeater; + state->dataUnitHeaters->UnitHeat.allocate(1); + state->dataUnitHeaters->UnitHeat(EquipIndex).AirOutNode = 1; + state->dataUnitHeaters->UnitHeat(EquipIndex).AirInNode = 2; + check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); + if (check) { + EXPECT_EQ("SupplyNode", SupplyNodeName); + EXPECT_EQ("ReturnNode", ReturnNodeName); + } + + zoneEquipType = DataZoneEquipment::ZoneEquipType::UnitVentilator; + state->dataUnitVentilators->UnitVent.allocate(1); + state->dataUnitVentilators->UnitVent(EquipIndex).AirOutNode = 1; + state->dataUnitVentilators->UnitVent(EquipIndex).AirInNode = 2; + check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); + if (check) { + EXPECT_EQ("SupplyNode", SupplyNodeName); + EXPECT_EQ("ReturnNode", ReturnNodeName); + } + + zoneEquipType = DataZoneEquipment::ZoneEquipType::VentilatedSlab; + state->dataVentilatedSlab->VentSlab.allocate(1); + state->dataVentilatedSlab->VentSlab(EquipIndex).ZoneAirInNode = 1; + state->dataVentilatedSlab->VentSlab(EquipIndex).ReturnAirNode = 2; + check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); + if (check) { + EXPECT_EQ("SupplyNode", SupplyNodeName); + EXPECT_EQ("ReturnNode", ReturnNodeName); + } + + zoneEquipType = DataZoneEquipment::ZoneEquipType::WindowAirConditioner; + state->dataWindowAC->WindAC.allocate(1); + state->dataWindowAC->WindAC(EquipIndex).AirOutNode = 1; + state->dataWindowAC->WindAC(EquipIndex).AirInNode = 2; + check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); + if (check) { + EXPECT_EQ("SupplyNode", SupplyNodeName); + EXPECT_EQ("ReturnNode", ReturnNodeName); + } +} From c7628e5035fcafe238083c5b596c57de8ec72821 Mon Sep 17 00:00:00 2001 From: Lixing Gu Date: Thu, 28 Mar 2024 11:27:28 -0400 Subject: [PATCH 02/57] Clang format --- tst/EnergyPlus/unit/RoomAirflowNetwork.unit.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tst/EnergyPlus/unit/RoomAirflowNetwork.unit.cc b/tst/EnergyPlus/unit/RoomAirflowNetwork.unit.cc index 7393e698b6d..c2fa7ba3407 100644 --- a/tst/EnergyPlus/unit/RoomAirflowNetwork.unit.cc +++ b/tst/EnergyPlus/unit/RoomAirflowNetwork.unit.cc @@ -72,8 +72,8 @@ #include #include #include -#include #include +#include #include #include #include @@ -89,14 +89,14 @@ #include #include #include -#include #include #include +#include #include #include #include -#include #include +#include #include using namespace EnergyPlus; From 29251076a079f06e841baf55a75ec3ecf35b8219 Mon Sep 17 00:00:00 2001 From: Lixing Gu Date: Thu, 28 Mar 2024 15:00:43 -0400 Subject: [PATCH 03/57] Different node names --- .../unit/RoomAirflowNetwork.unit.cc | 58 +++++++++++++------ 1 file changed, 39 insertions(+), 19 deletions(-) diff --git a/tst/EnergyPlus/unit/RoomAirflowNetwork.unit.cc b/tst/EnergyPlus/unit/RoomAirflowNetwork.unit.cc index c2fa7ba3407..4d789a28e83 100644 --- a/tst/EnergyPlus/unit/RoomAirflowNetwork.unit.cc +++ b/tst/EnergyPlus/unit/RoomAirflowNetwork.unit.cc @@ -628,6 +628,8 @@ TEST_F(EnergyPlusFixture, RoomAirflowNetwork_CheckEquipName_Test) EXPECT_EQ("SupplyNode", SupplyNodeName); } + state->dataLoopNodes->NodeID(1) = "SupplyNode1"; + state->dataLoopNodes->NodeID(2) = "ReturnNode1"; zoneEquipType = DataZoneEquipment::ZoneEquipType::EnergyRecoveryVentilator; state->dataFans->GetFanInputFlag = false; state->dataFans->Fan.allocate(1); @@ -635,29 +637,35 @@ TEST_F(EnergyPlusFixture, RoomAirflowNetwork_CheckEquipName_Test) state->dataFans->Fan(1).OutletNodeNum = 1; check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); if (check) { - EXPECT_EQ("SupplyNode", SupplyNodeName); + EXPECT_EQ("SupplyNode1", SupplyNodeName); } + state->dataLoopNodes->NodeID(1) = "SupplyNode2"; + state->dataLoopNodes->NodeID(2) = "ReturnNode2"; zoneEquipType = DataZoneEquipment::ZoneEquipType::FourPipeFanCoil; state->dataFanCoilUnits->FanCoil.allocate(1); state->dataFanCoilUnits->FanCoil(EquipIndex).AirOutNode = 1; state->dataFanCoilUnits->FanCoil(EquipIndex).AirInNode = 2; check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); if (check) { - EXPECT_EQ("SupplyNode", SupplyNodeName); - EXPECT_EQ("ReturnNode", ReturnNodeName); + EXPECT_EQ("SupplyNode2", SupplyNodeName); + EXPECT_EQ("ReturnNode2", ReturnNodeName); } + state->dataLoopNodes->NodeID(1) = "SupplyNode3"; + state->dataLoopNodes->NodeID(2) = "ReturnNode3"; zoneEquipType = DataZoneEquipment::ZoneEquipType::OutdoorAirUnit; state->dataOutdoorAirUnit->OutAirUnit.allocate(1); state->dataOutdoorAirUnit->OutAirUnit(EquipIndex).AirOutletNode = 1; state->dataOutdoorAirUnit->OutAirUnit(EquipIndex).AirInletNode = 2; check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); if (check) { - EXPECT_EQ("SupplyNode", SupplyNodeName); - EXPECT_EQ("ReturnNode", ReturnNodeName); + EXPECT_EQ("SupplyNode3", SupplyNodeName); + EXPECT_EQ("ReturnNode3", ReturnNodeName); } + state->dataLoopNodes->NodeID(1) = "SupplyNode4"; + state->dataLoopNodes->NodeID(2) = "ReturnNode4"; zoneEquipType = DataZoneEquipment::ZoneEquipType::PackagedTerminalAirConditioner; UnitarySystems::UnitarySys thisUnit; state->dataUnitarySystems->unitarySys.push_back(thisUnit); @@ -668,10 +676,12 @@ TEST_F(EnergyPlusFixture, RoomAirflowNetwork_CheckEquipName_Test) state->dataUnitarySystems->unitarySys[EquipIndex - 1].AirInNode = 2; check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); if (check) { - EXPECT_EQ("SupplyNode", SupplyNodeName); - EXPECT_EQ("ReturnNode", ReturnNodeName); + EXPECT_EQ("SupplyNode4", SupplyNodeName); + EXPECT_EQ("ReturnNode4", ReturnNodeName); } + state->dataLoopNodes->NodeID(1) = "SupplyNode5"; + state->dataLoopNodes->NodeID(2) = "ReturnNode5"; zoneEquipType = DataZoneEquipment::ZoneEquipType::PackagedTerminalHeatPump; // UnitarySystems::UnitarySys thisUnit; // state->dataUnitarySystems->unitarySys.push_back(thisUnit); @@ -682,9 +692,11 @@ TEST_F(EnergyPlusFixture, RoomAirflowNetwork_CheckEquipName_Test) state->dataUnitarySystems->unitarySys[EquipIndex - 1].AirInNode = 2; check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); if (check) { - EXPECT_EQ("SupplyNode", SupplyNodeName); - EXPECT_EQ("ReturnNode", ReturnNodeName); + EXPECT_EQ("SupplyNode5", SupplyNodeName); + EXPECT_EQ("ReturnNode5", ReturnNodeName); } + state->dataLoopNodes->NodeID(1) = "SupplyNode6"; + state->dataLoopNodes->NodeID(2) = "ReturnNode6"; zoneEquipType = DataZoneEquipment::ZoneEquipType::PackagedTerminalHeatPumpWaterToAir; // UnitarySystems::UnitarySys thisUnit; // state->dataUnitarySystems->unitarySys.push_back(thisUnit); @@ -695,47 +707,55 @@ TEST_F(EnergyPlusFixture, RoomAirflowNetwork_CheckEquipName_Test) state->dataUnitarySystems->unitarySys[EquipIndex - 1].AirInNode = 2; check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); if (check) { - EXPECT_EQ("SupplyNode", SupplyNodeName); - EXPECT_EQ("ReturnNode", ReturnNodeName); + EXPECT_EQ("SupplyNode6", SupplyNodeName); + EXPECT_EQ("ReturnNode6", ReturnNodeName); } + state->dataLoopNodes->NodeID(1) = "SupplyNode7"; + state->dataLoopNodes->NodeID(2) = "ReturnNode7"; zoneEquipType = DataZoneEquipment::ZoneEquipType::UnitHeater; state->dataUnitHeaters->UnitHeat.allocate(1); state->dataUnitHeaters->UnitHeat(EquipIndex).AirOutNode = 1; state->dataUnitHeaters->UnitHeat(EquipIndex).AirInNode = 2; check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); if (check) { - EXPECT_EQ("SupplyNode", SupplyNodeName); - EXPECT_EQ("ReturnNode", ReturnNodeName); + EXPECT_EQ("SupplyNode7", SupplyNodeName); + EXPECT_EQ("ReturnNode7", ReturnNodeName); } + state->dataLoopNodes->NodeID(1) = "SupplyNode8"; + state->dataLoopNodes->NodeID(2) = "ReturnNode8"; zoneEquipType = DataZoneEquipment::ZoneEquipType::UnitVentilator; state->dataUnitVentilators->UnitVent.allocate(1); state->dataUnitVentilators->UnitVent(EquipIndex).AirOutNode = 1; state->dataUnitVentilators->UnitVent(EquipIndex).AirInNode = 2; check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); if (check) { - EXPECT_EQ("SupplyNode", SupplyNodeName); - EXPECT_EQ("ReturnNode", ReturnNodeName); + EXPECT_EQ("SupplyNode8", SupplyNodeName); + EXPECT_EQ("ReturnNode8", ReturnNodeName); } + state->dataLoopNodes->NodeID(1) = "SupplyNode9"; + state->dataLoopNodes->NodeID(2) = "ReturnNode9"; zoneEquipType = DataZoneEquipment::ZoneEquipType::VentilatedSlab; state->dataVentilatedSlab->VentSlab.allocate(1); state->dataVentilatedSlab->VentSlab(EquipIndex).ZoneAirInNode = 1; state->dataVentilatedSlab->VentSlab(EquipIndex).ReturnAirNode = 2; check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); if (check) { - EXPECT_EQ("SupplyNode", SupplyNodeName); - EXPECT_EQ("ReturnNode", ReturnNodeName); + EXPECT_EQ("SupplyNode9", SupplyNodeName); + EXPECT_EQ("ReturnNode9", ReturnNodeName); } + state->dataLoopNodes->NodeID(1) = "SupplyNode10"; + state->dataLoopNodes->NodeID(2) = "ReturnNode10"; zoneEquipType = DataZoneEquipment::ZoneEquipType::WindowAirConditioner; state->dataWindowAC->WindAC.allocate(1); state->dataWindowAC->WindAC(EquipIndex).AirOutNode = 1; state->dataWindowAC->WindAC(EquipIndex).AirInNode = 2; check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); if (check) { - EXPECT_EQ("SupplyNode", SupplyNodeName); - EXPECT_EQ("ReturnNode", ReturnNodeName); + EXPECT_EQ("SupplyNode10", SupplyNodeName); + EXPECT_EQ("ReturnNode10", ReturnNodeName); } } From 4f79ab334f4ad91c995604c12adef518d19686a5 Mon Sep 17 00:00:00 2001 From: Tanaya Mankad Date: Tue, 16 Apr 2024 11:02:01 -0600 Subject: [PATCH 04/57] Adjust dry-bulb temperature of mixed air if the air state is unphysical. --- src/EnergyPlus/MixedAir.cc | 9 +++ tst/EnergyPlus/unit/MixedAir.unit.cc | 86 ++++++++++++++++++++++++++++ 2 files changed, 95 insertions(+) diff --git a/src/EnergyPlus/MixedAir.cc b/src/EnergyPlus/MixedAir.cc index a3193ac1013..d066d6e20bf 100644 --- a/src/EnergyPlus/MixedAir.cc +++ b/src/EnergyPlus/MixedAir.cc @@ -4693,6 +4693,15 @@ void CalcOAMixer(EnergyPlusData &state, int const OAMixerNum) // Mixed air temperature is calculated from the mixed air enthalpy and humidity ratio. state.dataMixedAir->OAMixer(OAMixerNum).MixTemp = Psychrometrics::PsyTdbFnHW(state.dataMixedAir->OAMixer(OAMixerNum).MixEnthalpy, state.dataMixedAir->OAMixer(OAMixerNum).MixHumRat); + + // Check for saturation temperature > dry-bulb temperature and modify temperature at constant enthalpy + auto T_sat = + Psychrometrics::PsyTsatFnHPb(state, state.dataMixedAir->OAMixer(OAMixerNum).MixEnthalpy, state.dataMixedAir->OAMixer(OAMixerNum).MixPressure); + if (state.dataMixedAir->OAMixer(OAMixerNum).MixTemp < T_sat) { + state.dataMixedAir->OAMixer(OAMixerNum).MixTemp = T_sat; + state.dataMixedAir->OAMixer(OAMixerNum).MixHumRat = + Psychrometrics::PsyWFnTdbH(state, T_sat, state.dataMixedAir->OAMixer(OAMixerNum).MixEnthalpy); + } } // End of Calculation/Simulation Section of the Module diff --git a/tst/EnergyPlus/unit/MixedAir.unit.cc b/tst/EnergyPlus/unit/MixedAir.unit.cc index 77793bce9c7..0992973dc5d 100644 --- a/tst/EnergyPlus/unit/MixedAir.unit.cc +++ b/tst/EnergyPlus/unit/MixedAir.unit.cc @@ -7666,4 +7666,90 @@ TEST_F(EnergyPlusFixture, OAController_LowExhaustMassFlowTest) EXPECT_TRUE(AirLoopCntrlInfo.HeatingActiveFlag); EXPECT_EQ(1, curOACntrl.HRHeatingCoilActive); } + +TEST_F(EnergyPlusFixture, MixedAir_TemperatureError) +{ + std::string const idf_objects = delimited_string({ + " OutdoorAir:NodeList,", + " Outdoor Air Inlet; !-Node or NodeList Name 1", + + " Controller:OutdoorAir,", + " OA Controller 1, !- Name", + " Relief Air Outlet Node, !- Relief Air Outlet Node Name", + " Air Loop Inlet Node, !- Return Air Node Name", + " Mixed Air Node, !- Mixed Air Node Name", + " Outdoor Air Inlet, !- Actuator Node Name", + " autosize, !- Minimum Outdoor Air Flow Rate {m3/s}", + " autosize, !- Maximum Outdoor Air Flow Rate {m3/s}", + " DifferentialDryBulb, !- Economizer Control Type", // Economizer should open for this one, so OA flow should be > min OA + " ModulateFlow, !- Economizer Control Action Type", + " 20, !- Economizer Maximum Limit Dry-Bulb Temperature {C}", + " , !- Economizer Maximum Limit Enthalpy {J/kg}", + " , !- Economizer Maximum Limit Dewpoint Temperature {C}", + " , !- Electronic Enthalpy Limit Curve Name", + " , !- Economizer Minimum Limit Dry-Bulb Temperature {C}", + " NoLockout, !- Lockout Type", // No lockout + " FixedMinimum, !- Minimum Limit Type", + " , !- Minimum Outdoor Air Schedule Name", + " , !- Minimum Fraction of Outdoor Air Schedule Name", + " , !- Maximum Fraction of Outdoor Air Schedule Name", + " , !- Mechanical Ventilation Controller Name", + " , !- Time of Day Economizer Control Schedule Name", + " No, !- High Humidity Control", + " , !- Humidistat Control Zone Name", + " , !- High Humidity Outdoor Air Flow Ratio", + " No; !- Control High Indoor Humidity Based on Outdoor Humidity Ratio", + + " OutdoorAir:Mixer,", + " OA Mixer, !- Name", + " Mixed Air Node, !- Mixed Air Node Name", + " Outdoor Air Inlet, !- Outdoor Air Stream Node Name", + " Relief Air Outlet Node, !- Relief Air Stream Node Name", + " Air Loop Inlet Node; !- Return Air Stream Node Name", + + " AirLoopHVAC:ControllerList,", + " OA Sys 1 controller, !- Name", + " Controller:OutdoorAir, !- Controller 1 Object Type", + " OA Controller 1; !- Controller 1 Name", + + " AirLoopHVAC:OutdoorAirSystem:EquipmentList,", + " OA Sys 1 Equipment list, !- Name", + " OutdoorAir:Mixer, !- Component 2 Object Type", + " OA Mixer; !- Component 2 Name", + + " AirLoopHVAC:OutdoorAirSystem,", + " OA Sys 1, !- Name", + " OA Sys 1 controller, !- Controller List Name", + " OA Sys 1 Equipment list; !- Outdoor Air Equipment List Name", + }); + + ASSERT_TRUE(process_idf(idf_objects)); + GetOAControllerInputs(*state); + + EXPECT_EQ(1, GetNumOAMixers(*state)); + + auto return_node = state->dataMixedAir->OAMixer(1).RetNode; + auto outdoor_air_node = state->dataMixedAir->OAMixer(1).InletNode; + + state->dataLoopNodes->Node(outdoor_air_node).Temp = -17.3; + state->dataLoopNodes->Node(outdoor_air_node).HumRat = 0.0008; + state->dataLoopNodes->Node(outdoor_air_node).Enthalpy = -15312; + state->dataLoopNodes->Node(outdoor_air_node).Press = 99063; + state->dataLoopNodes->Node(outdoor_air_node).MassFlowRate = 0.1223; + state->dataLoopNodes->Node(return_node).Temp = 20.0; + state->dataLoopNodes->Node(return_node).HumRat = 0.0146; + state->dataLoopNodes->Node(return_node).Enthalpy = 57154; + state->dataLoopNodes->Node(return_node).Press = 99063; + state->dataLoopNodes->Node(return_node).MassFlowRate = 0.2923; + + MixedAir::SimOAMixer( + *state, state->dataAirLoop->OutsideAirSys(1).ComponentName(1), state->dataAirLoop->OutsideAirSys(1).ComponentIndex(1)); + + auto T_sat = Psychrometrics::PsyTsatFnHPb( + *state, state->dataMixedAir->OAMixer(1).MixEnthalpy, state->dataMixedAir->OAMixer(1).MixPressure); + + // T_db must be >= T_sat at the mixed-air node to remain physical + EXPECT_TRUE(state->dataMixedAir->OAMixer(1).MixTemp >= T_sat); +} + } // namespace EnergyPlus From ab7cdb48f2ffde91816b3679f8bba72618e5fbcc Mon Sep 17 00:00:00 2001 From: Lixing Gu Date: Thu, 2 May 2024 15:48:08 -0400 Subject: [PATCH 05/57] Address comments --- src/EnergyPlus/FanCoilUnits.cc | 22 ++++++ src/EnergyPlus/FanCoilUnits.hh | 2 + src/EnergyPlus/PurchasedAirManager.cc | 15 ++++ src/EnergyPlus/PurchasedAirManager.hh | 2 + src/EnergyPlus/RoomAirModelManager.cc | 49 +++++++------ src/EnergyPlus/UnitHeater.cc | 33 +++++++++ src/EnergyPlus/UnitHeater.hh | 3 + src/EnergyPlus/VentilatedSlab.cc | 31 ++++++++ src/EnergyPlus/VentilatedSlab.hh | 4 + src/EnergyPlus/WaterThermalTanks.cc | 30 ++++++++ src/EnergyPlus/WaterThermalTanks.hh | 4 + src/EnergyPlus/ZoneDehumidifier.cc | 30 ++++++++ src/EnergyPlus/ZoneDehumidifier.hh | 4 + .../unit/RoomAirflowNetwork.unit.cc | 73 +++++++++++++++++++ 14 files changed, 278 insertions(+), 24 deletions(-) diff --git a/src/EnergyPlus/FanCoilUnits.cc b/src/EnergyPlus/FanCoilUnits.cc index a0aee8a8243..f2895c5f470 100644 --- a/src/EnergyPlus/FanCoilUnits.cc +++ b/src/EnergyPlus/FanCoilUnits.cc @@ -4221,6 +4221,28 @@ namespace FanCoilUnits { return 0; } + int GetFanCoilAirInNode(EnergyPlusData &state, int const FanCoilNum) + { + + // FUNCTION INFORMATION: + // AUTHOR B Griffith + // DATE WRITTEN Dec 2006 + + // PURPOSE OF THIS FUNCTION: + // lookup function for OA inlet node for ventilation rate reporting + + if (state.dataFanCoilUnits->GetFanCoilInputFlag) { + GetFanCoilUnits(state); + state.dataFanCoilUnits->GetFanCoilInputFlag = false; + } + + if (FanCoilNum > 0 && FanCoilNum <= state.dataFanCoilUnits->NumFanCoils) { + return state.dataFanCoilUnits->FanCoil(FanCoilNum).AirInNode; + } + + return 0; + } + int GetFanCoilOutAirNode(EnergyPlusData &state, int const FanCoilNum) { diff --git a/src/EnergyPlus/FanCoilUnits.hh b/src/EnergyPlus/FanCoilUnits.hh index 300a6dd400a..931b397dbe6 100644 --- a/src/EnergyPlus/FanCoilUnits.hh +++ b/src/EnergyPlus/FanCoilUnits.hh @@ -322,6 +322,8 @@ namespace FanCoilUnits { int GetFanCoilZoneInletAirNode(EnergyPlusData &state, int FanCoilNum); + int GetFanCoilAirInNode(EnergyPlusData &state, int FanCoilNum); + int GetFanCoilOutAirNode(EnergyPlusData &state, int FanCoilNum); int GetFanCoilReturnAirNode(EnergyPlusData &state, int FanCoilNum); diff --git a/src/EnergyPlus/PurchasedAirManager.cc b/src/EnergyPlus/PurchasedAirManager.cc index 162961ae20f..11788a042cc 100644 --- a/src/EnergyPlus/PurchasedAirManager.cc +++ b/src/EnergyPlus/PurchasedAirManager.cc @@ -3327,6 +3327,21 @@ int GetPurchasedAirReturnAirNode(EnergyPlusData &state, int const PurchAirNum) return GetPurchasedAirReturnAirNode; } +int GetPurchasedAirZoneExhaustAirNode(EnergyPlusData &state, int PurchAirNum) +{ + if (state.dataPurchasedAirMgr->GetPurchAirInputFlag) { + GetPurchasedAir(state); + state.dataPurchasedAirMgr->GetPurchAirInputFlag = false; + } + + int GetPurchasedAirZoneExhaustAirNode = 0; + if (PurchAirNum > 0 && PurchAirNum <= state.dataPurchasedAirMgr->NumPurchAir) { + GetPurchasedAirZoneExhaustAirNode = state.dataPurchasedAirMgr->PurchAir(PurchAirNum).ZoneExhaustAirNodeNum; + } + + return GetPurchasedAirZoneExhaustAirNode; +} + Real64 GetPurchasedAirMixedAirTemp(EnergyPlusData &state, int const PurchAirNum) { diff --git a/src/EnergyPlus/PurchasedAirManager.hh b/src/EnergyPlus/PurchasedAirManager.hh index d2351e18c95..b3ab5c618fc 100644 --- a/src/EnergyPlus/PurchasedAirManager.hh +++ b/src/EnergyPlus/PurchasedAirManager.hh @@ -379,6 +379,8 @@ namespace PurchasedAirManager { int GetPurchasedAirReturnAirNode(EnergyPlusData &state, int PurchAirNum); + int GetPurchasedAirZoneExhaustAirNode(EnergyPlusData &state, int PurchAirNum); + Real64 GetPurchasedAirMixedAirTemp(EnergyPlusData &state, int PurchAirNum); Real64 GetPurchasedAirMixedAirHumRat(EnergyPlusData &state, int PurchAirNum); diff --git a/src/EnergyPlus/RoomAirModelManager.cc b/src/EnergyPlus/RoomAirModelManager.cc index 4c968a81d1e..96f459c6e09 100644 --- a/src/EnergyPlus/RoomAirModelManager.cc +++ b/src/EnergyPlus/RoomAirModelManager.cc @@ -1262,7 +1262,7 @@ namespace RoomAir { int TotNumOfRAFNNodeGainsLists; int TotNumOfRAFNNodeHVACLists; int TotNumEquip; - bool IntEquipError; + bool IntEquipFound; auto &ipsc = state.dataIPShortCut; ipsc->cCurrentModuleObject = "RoomAirSettings:AirflowNetwork"; @@ -1651,19 +1651,20 @@ namespace RoomAir { int EquipIndex = 0; for (int thisZoneEquipNum = 1; thisZoneEquipNum <= state.dataZoneEquip->ZoneEquipList(iZone).NumOfEquipTypes; ++thisZoneEquipNum) { - if (Util::SameString(state.dataZoneEquip->ZoneEquipList(iZone).EquipName(thisZoneEquipNum), roomAFNNodeHVAC.Name)) { + if (Util::SameString(state.dataZoneEquip->ZoneEquipList(iZone).EquipName(thisZoneEquipNum), roomAFNNodeHVAC.Name) && + roomAFNNodeHVAC.zoneEquipType == state.dataZoneEquip->ZoneEquipList(iZone).EquipType(thisZoneEquipNum)) { EquipIndex = state.dataZoneEquip->ZoneEquipList(iZone).EquipIndex(thisZoneEquipNum); break; } } - IntEquipError = CheckEquipName(state, + IntEquipFound = CheckEquipName(state, roomAFNNodeHVAC.Name, roomAFNNodeHVAC.SupplyNodeName, roomAFNNodeHVAC.ReturnNodeName, EquipIndex, roomAFNNodeHVAC.zoneEquipType); - if (!IntEquipError) { + if (!IntEquipFound) { ShowSevereError(state, format("GetRoomAirflowNetworkData: Invalid {} = {}", ipsc->cAlphaFieldNames(3 + (iEquip - 1) * 2), @@ -2732,12 +2733,12 @@ namespace RoomAir { SupplyNodeNum = GetFanOutletNode(state, "Fan:OnOff", EquipName, errorfound); } break; case DataZoneEquipment::ZoneEquipType::FourPipeFanCoil: { // ZoneHVAC : FourPipeFanCoil - SupplyNodeNum = state.dataFanCoilUnits->FanCoil(EquipIndex).AirOutNode; - ReturnNodeNum = state.dataFanCoilUnits->FanCoil(EquipIndex).AirInNode; + SupplyNodeNum = FanCoilUnits::GetFanCoilZoneInletAirNode(state,EquipIndex); + ReturnNodeNum = FanCoilUnits::GetFanCoilAirInNode(state, EquipIndex); } break; case DataZoneEquipment::ZoneEquipType::OutdoorAirUnit: { // ZoneHVAC : OutdoorAirUnit - SupplyNodeNum = state.dataOutdoorAirUnit->OutAirUnit(EquipIndex).AirOutletNode; - ReturnNodeNum = state.dataOutdoorAirUnit->OutAirUnit(EquipIndex).AirInletNode; + SupplyNodeNum = OutdoorAirUnit::GetOutdoorAirUnitZoneInletNode(state,EquipIndex); + ReturnNodeNum = OutdoorAirUnit::GetOutdoorAirUnitReturnAirNode(state, EquipIndex); } break; case DataZoneEquipment::ZoneEquipType::PackagedTerminalAirConditioner: { // ZoneHVAC : PackagedTerminalAirConditioner SupplyNodeNum = state.dataUnitarySystems->unitarySys[EquipIndex - 1].getAirOutNode(state, EquipName, 0, errorfound); @@ -2748,24 +2749,24 @@ namespace RoomAir { ReturnNodeNum = state.dataUnitarySystems->unitarySys[EquipIndex - 1].getAirInNode(state, EquipName, 0, errorfound); } break; case DataZoneEquipment::ZoneEquipType::UnitHeater: { // ZoneHVAC : UnitHeater - ReturnNodeNum = state.dataUnitHeaters->UnitHeat(EquipIndex).AirInNode; - SupplyNodeNum = state.dataUnitHeaters->UnitHeat(EquipIndex).AirOutNode; + ReturnNodeNum = UnitHeater::GetUnitHeaterAirInletNode(state, EquipIndex); + SupplyNodeNum = UnitHeater::GetUnitHeaterAirOutletNode(state, EquipIndex); } break; case DataZoneEquipment::ZoneEquipType::UnitVentilator: { // ZoneHVAC : UnitVentilator - ReturnNodeNum = state.dataUnitVentilators->UnitVent(EquipIndex).AirInNode; - SupplyNodeNum = state.dataUnitVentilators->UnitVent(EquipIndex).AirOutNode; + ReturnNodeNum = UnitVentilator::GetUnitVentilatorReturnAirNode(state, EquipIndex); + SupplyNodeNum = UnitVentilator::GetUnitVentilatorZoneInletAirNode(state, EquipIndex); } break; case DataZoneEquipment::ZoneEquipType::VentilatedSlab: { // ZoneHVAC : VentilatedSlab - ReturnNodeNum = state.dataVentilatedSlab->VentSlab(EquipIndex).ReturnAirNode; - SupplyNodeNum = state.dataVentilatedSlab->VentSlab(EquipIndex).ZoneAirInNode; + ReturnNodeNum = VentilatedSlab::GetVentilatedSlabReturnAirNode(state, EquipIndex); + 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); } break; case DataZoneEquipment::ZoneEquipType::WindowAirConditioner: { // ZoneHVAC : WindowAirConditioner - ReturnNodeNum = state.dataWindowAC->WindAC(EquipIndex).AirInNode; - SupplyNodeNum = state.dataWindowAC->WindAC(EquipIndex).AirOutNode; + ReturnNodeNum = WindowAC::GetWindowACReturnAirNode(state, EquipIndex); + SupplyNodeNum = WindowAC::GetWindowACZoneInletAirNode(state, EquipIndex); } break; case DataZoneEquipment::ZoneEquipType::BaseboardElectric: { // ZoneHVAC : Baseboard : RadiantConvective : Electric // convective equipment without node connection. Will handle later @@ -2792,12 +2793,12 @@ namespace RoomAir { SupplyNodeName = ""; } break; case DataZoneEquipment::ZoneEquipType::DehumidifierDX: { // ZoneHVAC : Dehumidifier : DX - ReturnNodeNum = state.dataZoneDehumidifier->ZoneDehumid(EquipIndex).AirInletNodeNum; - SupplyNodeNum = state.dataZoneDehumidifier->ZoneDehumid(EquipIndex).AirOutletNodeNum; + ReturnNodeNum = ZoneDehumidifier::GetZoneDehumidifierAirInletNodeNum(state, EquipIndex); + SupplyNodeNum = ZoneDehumidifier::GetZoneDehumidifierAirOutletNodeNum(state, EquipIndex); } break; case DataZoneEquipment::ZoneEquipType::PurchasedAir: { // ZoneHVAC : IdealLoadsAirSystem - ReturnNodeNum = state.dataPurchasedAirMgr->PurchAir(EquipIndex).ZoneExhaustAirNodeNum; - SupplyNodeNum = state.dataPurchasedAirMgr->PurchAir(EquipIndex).ZoneSupplyAirNodeNum; + ReturnNodeNum = PurchasedAirManager::GetPurchasedAirZoneExhaustAirNode(state, EquipIndex); + SupplyNodeNum = PurchasedAirManager::GetPurchasedAirZoneInletAirNode(state, EquipIndex); } break; case DataZoneEquipment::ZoneEquipType::RefrigerationChillerSet: { // ZoneHVAC : RefrigerationChillerSet // May not apply @@ -2805,16 +2806,16 @@ namespace RoomAir { // ReturnNodeName = Alphas(4); } break; case DataZoneEquipment::ZoneEquipType::HybridEvaporativeCooler: { // ZoneHVAC : HybridUnitaryAirConditioners - ReturnNodeNum = state.dataHybridUnitaryAC->ZoneHybridUnitaryAirConditioner(EquipIndex).InletNode; - SupplyNodeNum = state.dataHybridUnitaryAC->ZoneHybridUnitaryAirConditioner(EquipIndex).OutletNode; + ReturnNodeNum = HybridUnitaryAirConditioners::GetHybridUnitaryACReturnAirNode(state, EquipIndex); + SupplyNodeNum = HybridUnitaryAirConditioners::GetHybridUnitaryACZoneInletNode(state, EquipIndex); } break; case DataZoneEquipment::ZoneEquipType::ExhaustFan: { // Fan : ZoneExhaust // SupplyNodeName = ""; // ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? May not use } break; case DataZoneEquipment::ZoneEquipType::HeatPumpWaterHeater: { // WaterHeater : HeatPump - ReturnNodeNum = state.dataWaterThermalTanks->HPWaterHeater(EquipIndex).HeatPumpAirInletNode; - SupplyNodeNum = state.dataWaterThermalTanks->HPWaterHeater(EquipIndex).HeatPumpAirOutletNode; + ReturnNodeNum = WaterThermalTanks::GetHeatPumpWaterHeaterAirInletNodeNum(state, EquipIndex); + SupplyNodeNum = WaterThermalTanks::GetHeatPumpWaterHeaterAirOutletNodeNum(state, EquipIndex); // For AirTerminals, find matching return node later } break; case DataZoneEquipment::ZoneEquipType::AirTerminalDualDuctConstantVolume: { // AirTerminal : DualDuct : ConstantVolume diff --git a/src/EnergyPlus/UnitHeater.cc b/src/EnergyPlus/UnitHeater.cc index 89859c180b3..9407d59945b 100644 --- a/src/EnergyPlus/UnitHeater.cc +++ b/src/EnergyPlus/UnitHeater.cc @@ -2023,6 +2023,39 @@ namespace UnitHeater { } } + int GetUnitHeaterAirOutletNode(EnergyPlusData &state, int UnitHeaterNum) + { + // Return value + int GetUnitHeaterAirOutletNode = 0; + + if (state.dataUnitHeaters->GetUnitHeaterInputFlag) { + GetUnitHeaterInput(state); + state.dataUnitHeaters->GetUnitHeaterInputFlag = false; + } + + if (UnitHeaterNum > 0 && UnitHeaterNum <= state.dataUnitHeaters->NumOfUnitHeats) { + GetUnitHeaterAirOutletNode = state.dataUnitHeaters->UnitHeat(UnitHeaterNum).AirOutNode; + } + + return GetUnitHeaterAirOutletNode; + } + + int GetUnitHeaterAirInletNode(EnergyPlusData &state, int UnitHeaterNum) + { + int GetUnitHeaterAirInletNode = 0; + + if (state.dataUnitHeaters->GetUnitHeaterInputFlag) { + GetUnitHeaterInput(state); + state.dataUnitHeaters->GetUnitHeaterInputFlag = false; + } + + if (UnitHeaterNum > 0 && UnitHeaterNum <= state.dataUnitHeaters->NumOfUnitHeats) { + GetUnitHeaterAirInletNode = state.dataUnitHeaters->UnitHeat(UnitHeaterNum).AirInNode; + } + + return GetUnitHeaterAirInletNode; + } + } // namespace UnitHeater } // namespace EnergyPlus diff --git a/src/EnergyPlus/UnitHeater.hh b/src/EnergyPlus/UnitHeater.hh index 33e9950cdf9..f78b2d6f7ae 100644 --- a/src/EnergyPlus/UnitHeater.hh +++ b/src/EnergyPlus/UnitHeater.hh @@ -203,6 +203,9 @@ namespace UnitHeater { void ReportUnitHeater(EnergyPlusData &state, int const UnitHeatNum); // Unit index in unit heater array + int GetUnitHeaterAirOutletNode(EnergyPlusData &state, int OAUnitNum); + + int GetUnitHeaterAirInletNode(EnergyPlusData &state, int OAUnitNum); } // namespace UnitHeater struct UnitHeatersData : BaseGlobalStruct diff --git a/src/EnergyPlus/VentilatedSlab.cc b/src/EnergyPlus/VentilatedSlab.cc index 6e50944431f..1954642d413 100644 --- a/src/EnergyPlus/VentilatedSlab.cc +++ b/src/EnergyPlus/VentilatedSlab.cc @@ -4761,6 +4761,37 @@ namespace VentilatedSlab { } } + int GetVentilatedSlabReturnAirNode(EnergyPlusData &state, int const VentSlabNum) + { + int ReturnAirNode = 0; + if (state.dataVentilatedSlab->GetInputFlag) { + GetVentilatedSlabInput(state); + state.dataVentilatedSlab->GetInputFlag = false; + } + + if (VentSlabNum > 0 && VentSlabNum <= state.dataVentilatedSlab->NumOfVentSlabs) { + ReturnAirNode = state.dataVentilatedSlab->VentSlab(VentSlabNum).ReturnAirNode; + } + + return ReturnAirNode; + } + + int GetVentilatedSlabZoneAirInNode(EnergyPlusData &state, int const VentSlabNum) + { + int ZoneAirInNode = 0; + + if (state.dataVentilatedSlab->GetInputFlag) { + GetVentilatedSlabInput(state); + state.dataVentilatedSlab->GetInputFlag = false; + } + + if (VentSlabNum > 0 && VentSlabNum <= state.dataVentilatedSlab->NumOfVentSlabs) { + ZoneAirInNode = state.dataVentilatedSlab->VentSlab(VentSlabNum).ZoneAirInNode; + } + + return ZoneAirInNode; + } + //***************************************************************************************** } // namespace VentilatedSlab diff --git a/src/EnergyPlus/VentilatedSlab.hh b/src/EnergyPlus/VentilatedSlab.hh index 276d487f058..a889522a110 100644 --- a/src/EnergyPlus/VentilatedSlab.hh +++ b/src/EnergyPlus/VentilatedSlab.hh @@ -383,6 +383,10 @@ namespace VentilatedSlab { void ReportVentilatedSlab(EnergyPlusData &state, int const Item); // Index for the ventilated slab under consideration within the derived types + int GetVentilatedSlabReturnAirNode(EnergyPlusData &state, int const VentSlabNum); + + int GetVentilatedSlabZoneAirInNode(EnergyPlusData &state, int const VentSlabNum); + //***************************************************************************************** } // namespace VentilatedSlab diff --git a/src/EnergyPlus/WaterThermalTanks.cc b/src/EnergyPlus/WaterThermalTanks.cc index fd0a2527d4e..019e7411770 100644 --- a/src/EnergyPlus/WaterThermalTanks.cc +++ b/src/EnergyPlus/WaterThermalTanks.cc @@ -12625,4 +12625,34 @@ bool GetHeatPumpWaterHeaterNodeNumber(EnergyPlusData &state, int const NodeNumbe return HeatPumpWaterHeaterNodeException; } +int GetHeatPumpWaterHeaterAirInletNodeNum(EnergyPlusData &state, int HPNum) +{ + int HeatPumpWaterHeaterAirInletNodeNum = 0; + if (state.dataWaterThermalTanks->getWaterThermalTankInputFlag) { + GetWaterThermalTankInput(state); + state.dataWaterThermalTanks->getWaterThermalTankInputFlag = false; + } + + if (HPNum > 0 && HPNum <= state.dataWaterThermalTanks->numHeatPumpWaterHeater) { + HeatPumpWaterHeaterAirInletNodeNum = state.dataWaterThermalTanks->HPWaterHeater(HPNum).HeatPumpAirInletNode; + } + + return HeatPumpWaterHeaterAirInletNodeNum; +} + +int GetHeatPumpWaterHeaterAirOutletNodeNum(EnergyPlusData &state, int HPNum) +{ + int HeatPumpWaterHeaterAirOutletNodeNum = 0; + if (state.dataWaterThermalTanks->getWaterThermalTankInputFlag) { + GetWaterThermalTankInput(state); + state.dataWaterThermalTanks->getWaterThermalTankInputFlag = false; + } + + if (HPNum > 0 && HPNum <= state.dataWaterThermalTanks->numHeatPumpWaterHeater) { + HeatPumpWaterHeaterAirOutletNodeNum = state.dataWaterThermalTanks->HPWaterHeater(HPNum).HeatPumpAirOutletNode; + } + + return HeatPumpWaterHeaterAirOutletNodeNum; +} + } // namespace EnergyPlus::WaterThermalTanks diff --git a/src/EnergyPlus/WaterThermalTanks.hh b/src/EnergyPlus/WaterThermalTanks.hh index 27a488f56c3..fc7bae1b424 100644 --- a/src/EnergyPlus/WaterThermalTanks.hh +++ b/src/EnergyPlus/WaterThermalTanks.hh @@ -989,6 +989,10 @@ namespace WaterThermalTanks { bool GetHeatPumpWaterHeaterNodeNumber(EnergyPlusData &state, int NodeNumber); + int GetHeatPumpWaterHeaterAirInletNodeNum(EnergyPlusData &state, int HPNum); + + int GetHeatPumpWaterHeaterAirOutletNodeNum(EnergyPlusData &state, int HPNum); + } // namespace WaterThermalTanks struct WaterThermalTanksData : BaseGlobalStruct diff --git a/src/EnergyPlus/ZoneDehumidifier.cc b/src/EnergyPlus/ZoneDehumidifier.cc index 95aa88d1a5a..b2689917565 100644 --- a/src/EnergyPlus/ZoneDehumidifier.cc +++ b/src/EnergyPlus/ZoneDehumidifier.cc @@ -1181,6 +1181,36 @@ namespace ZoneDehumidifier { return FindZoneDehumidifierNodeNumber; } + int GetZoneDehumidifierAirOutletNodeNum(EnergyPlusData &state, int ZoneDehumidNum) + { + int ZoneDehumidifierAirOutletNodeNum = 0; + if (state.dataZoneDehumidifier->GetInputFlag) { + GetZoneDehumidifierInput(state); + state.dataZoneDehumidifier->GetInputFlag = false; + } + + if (ZoneDehumidNum > 0 && ZoneDehumidNum <= (int)state.dataZoneDehumidifier->ZoneDehumid.size()) { + ZoneDehumidifierAirOutletNodeNum = state.dataZoneDehumidifier->ZoneDehumid(ZoneDehumidNum).AirOutletNodeNum; + } + + return ZoneDehumidifierAirOutletNodeNum; + } + + int GetZoneDehumidifierAirInletNodeNum(EnergyPlusData &state, int ZoneDehumidNum) + { + int ZoneDehumidifierAirInletNodeNum = 0; + if (state.dataZoneDehumidifier->GetInputFlag) { + GetZoneDehumidifierInput(state); + state.dataZoneDehumidifier->GetInputFlag = false; + } + + if (ZoneDehumidNum > 0 && ZoneDehumidNum <= (int)state.dataZoneDehumidifier->ZoneDehumid.size()) { + ZoneDehumidifierAirInletNodeNum = state.dataZoneDehumidifier->ZoneDehumid(ZoneDehumidNum).AirInletNodeNum; + } + + return ZoneDehumidifierAirInletNodeNum; + } + } // namespace ZoneDehumidifier } // namespace EnergyPlus diff --git a/src/EnergyPlus/ZoneDehumidifier.hh b/src/EnergyPlus/ZoneDehumidifier.hh index 0444b8b91f2..6da985a515f 100644 --- a/src/EnergyPlus/ZoneDehumidifier.hh +++ b/src/EnergyPlus/ZoneDehumidifier.hh @@ -153,6 +153,10 @@ namespace ZoneDehumidifier { bool GetZoneDehumidifierNodeNumber(EnergyPlusData &state, int NodeNumber); // Node being tested + int GetZoneDehumidifierAirOutletNodeNum(EnergyPlusData &state, int ZoneDehumidNum); + + int GetZoneDehumidifierAirInletNodeNum(EnergyPlusData &state, int ZoneDehumidNum); + } // namespace ZoneDehumidifier struct ZoneDehumidifierData : BaseGlobalStruct diff --git a/tst/EnergyPlus/unit/RoomAirflowNetwork.unit.cc b/tst/EnergyPlus/unit/RoomAirflowNetwork.unit.cc index 4d789a28e83..c5feb4ae39c 100644 --- a/tst/EnergyPlus/unit/RoomAirflowNetwork.unit.cc +++ b/tst/EnergyPlus/unit/RoomAirflowNetwork.unit.cc @@ -78,6 +78,7 @@ #include #include #include +#include #include #include #include @@ -646,6 +647,8 @@ TEST_F(EnergyPlusFixture, RoomAirflowNetwork_CheckEquipName_Test) state->dataFanCoilUnits->FanCoil.allocate(1); state->dataFanCoilUnits->FanCoil(EquipIndex).AirOutNode = 1; state->dataFanCoilUnits->FanCoil(EquipIndex).AirInNode = 2; + state->dataFanCoilUnits->NumFanCoils = 1; + state->dataFanCoilUnits->GetFanCoilInputFlag = false; check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); if (check) { EXPECT_EQ("SupplyNode2", SupplyNodeName); @@ -658,6 +661,8 @@ TEST_F(EnergyPlusFixture, RoomAirflowNetwork_CheckEquipName_Test) state->dataOutdoorAirUnit->OutAirUnit.allocate(1); state->dataOutdoorAirUnit->OutAirUnit(EquipIndex).AirOutletNode = 1; state->dataOutdoorAirUnit->OutAirUnit(EquipIndex).AirInletNode = 2; + state->dataOutdoorAirUnit->NumOfOAUnits = 1; + state->dataOutdoorAirUnit->GetOutdoorAirUnitInputFlag = false; check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); if (check) { EXPECT_EQ("SupplyNode3", SupplyNodeName); @@ -717,6 +722,8 @@ TEST_F(EnergyPlusFixture, RoomAirflowNetwork_CheckEquipName_Test) state->dataUnitHeaters->UnitHeat.allocate(1); state->dataUnitHeaters->UnitHeat(EquipIndex).AirOutNode = 1; state->dataUnitHeaters->UnitHeat(EquipIndex).AirInNode = 2; + state->dataUnitHeaters->NumOfUnitHeats = 1; + state->dataUnitHeaters->GetUnitHeaterInputFlag = false; check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); if (check) { EXPECT_EQ("SupplyNode7", SupplyNodeName); @@ -729,6 +736,8 @@ TEST_F(EnergyPlusFixture, RoomAirflowNetwork_CheckEquipName_Test) state->dataUnitVentilators->UnitVent.allocate(1); state->dataUnitVentilators->UnitVent(EquipIndex).AirOutNode = 1; state->dataUnitVentilators->UnitVent(EquipIndex).AirInNode = 2; + state->dataUnitVentilators->NumOfUnitVents = 1; + state->dataUnitVentilators->GetUnitVentilatorInputFlag = false; check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); if (check) { EXPECT_EQ("SupplyNode8", SupplyNodeName); @@ -741,6 +750,8 @@ TEST_F(EnergyPlusFixture, RoomAirflowNetwork_CheckEquipName_Test) state->dataVentilatedSlab->VentSlab.allocate(1); state->dataVentilatedSlab->VentSlab(EquipIndex).ZoneAirInNode = 1; state->dataVentilatedSlab->VentSlab(EquipIndex).ReturnAirNode = 2; + state->dataVentilatedSlab->NumOfVentSlabs = 1; + state->dataVentilatedSlab->GetInputFlag = false; check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); if (check) { EXPECT_EQ("SupplyNode9", SupplyNodeName); @@ -753,9 +764,71 @@ TEST_F(EnergyPlusFixture, RoomAirflowNetwork_CheckEquipName_Test) state->dataWindowAC->WindAC.allocate(1); state->dataWindowAC->WindAC(EquipIndex).AirOutNode = 1; state->dataWindowAC->WindAC(EquipIndex).AirInNode = 2; + state->dataWindowAC->WindAC(EquipIndex).OAMixIndex = 1; + state->dataWindowAC->NumWindAC = 1; + state->dataWindowAC->GetWindowACInputFlag = false; + state->dataMixedAir->NumOAMixers = 1; + state->dataMixedAir->OAMixer.allocate(1); + state->dataMixedAir->OAMixer(1).RetNode = 2; + state->dataMixedAir->GetOAMixerInputFlag = false; check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); if (check) { EXPECT_EQ("SupplyNode10", SupplyNodeName); EXPECT_EQ("ReturnNode10", ReturnNodeName); } + + state->dataLoopNodes->NodeID(1) = "SupplyNode11"; + state->dataLoopNodes->NodeID(2) = "ReturnNode11"; + zoneEquipType = DataZoneEquipment::ZoneEquipType::DehumidifierDX; + state->dataZoneDehumidifier->ZoneDehumid.allocate(1); + state->dataZoneDehumidifier->ZoneDehumid(EquipIndex).AirOutletNodeNum = 1; + state->dataZoneDehumidifier->ZoneDehumid(EquipIndex).AirInletNodeNum = 2; + state->dataZoneDehumidifier->GetInputFlag = false; + check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); + if (check) { + EXPECT_EQ("SupplyNode11", SupplyNodeName); + EXPECT_EQ("ReturnNode11", ReturnNodeName); + } + + state->dataLoopNodes->NodeID(1) = "SupplyNode12"; + state->dataLoopNodes->NodeID(2) = "ReturnNode12"; + zoneEquipType = DataZoneEquipment::ZoneEquipType::PurchasedAir; + state->dataPurchasedAirMgr->PurchAir.allocate(1); + state->dataPurchasedAirMgr->PurchAir(EquipIndex).ZoneSupplyAirNodeNum = 1; + state->dataPurchasedAirMgr->PurchAir(EquipIndex).ZoneExhaustAirNodeNum = 2; + state->dataPurchasedAirMgr->NumPurchAir = 1; + state->dataPurchasedAirMgr->GetPurchAirInputFlag = false; + check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); + if (check) { + EXPECT_EQ("SupplyNode12", SupplyNodeName); + EXPECT_EQ("ReturnNode12", ReturnNodeName); + } + + state->dataLoopNodes->NodeID(1) = "SupplyNode13"; + state->dataLoopNodes->NodeID(2) = "ReturnNode13"; + zoneEquipType = DataZoneEquipment::ZoneEquipType::PurchasedAir; + state->dataHybridUnitaryAC->ZoneHybridUnitaryAirConditioner.allocate(1); + state->dataHybridUnitaryAC->ZoneHybridUnitaryAirConditioner(EquipIndex).OutletNode = 1; + state->dataHybridUnitaryAC->ZoneHybridUnitaryAirConditioner(EquipIndex).InletNode = 2; + state->dataHybridUnitaryAC->NumZoneHybridEvap = 1; + state->dataHybridUnitaryAC->GetInputZoneHybridEvap = false; + check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); + if (check) { + EXPECT_EQ("SupplyNode13", SupplyNodeName); + EXPECT_EQ("ReturnNode13", ReturnNodeName); + } + + state->dataLoopNodes->NodeID(1) = "SupplyNode14"; + state->dataLoopNodes->NodeID(2) = "ReturnNode14"; + zoneEquipType = DataZoneEquipment::ZoneEquipType::PurchasedAir; + state->dataWaterThermalTanks->HPWaterHeater.allocate(1); + state->dataWaterThermalTanks->HPWaterHeater(EquipIndex).HeatPumpAirOutletNode = 1; + state->dataWaterThermalTanks->HPWaterHeater(EquipIndex).HeatPumpAirInletNode = 2; + state->dataWaterThermalTanks->numHeatPumpWaterHeater = 1; + state->dataWaterThermalTanks->getWaterThermalTankInputFlag = false; + check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); + if (check) { + EXPECT_EQ("SupplyNode14", SupplyNodeName); + EXPECT_EQ("ReturnNode14", ReturnNodeName); + } } From b989dc0e4031627fe397f2d7f525abd389477605 Mon Sep 17 00:00:00 2001 From: Lixing Gu Date: Thu, 2 May 2024 16:12:27 -0400 Subject: [PATCH 06/57] Clang format --- src/EnergyPlus/RoomAirModelManager.cc | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/EnergyPlus/RoomAirModelManager.cc b/src/EnergyPlus/RoomAirModelManager.cc index 4a5a124a4cf..0ec8890ecc5 100644 --- a/src/EnergyPlus/RoomAirModelManager.cc +++ b/src/EnergyPlus/RoomAirModelManager.cc @@ -2724,21 +2724,19 @@ namespace RoomAir { if (zoneEquipType == DataZoneEquipment::ZoneEquipType::Invalid) return EquipFind; - ErrorObjectHeader eoh{routineName, equipTypeName, EquipName}; - switch (zoneEquipType) { case DataZoneEquipment::ZoneEquipType::VariableRefrigerantFlowTerminal: { // ZoneHVAC:TerminalUnit : VariableRefrigerantFlow SupplyNodeNum = HVACVariableRefrigerantFlow::GetVRFTUZoneInletAirNode(state, EquipIndex); } break; case DataZoneEquipment::ZoneEquipType::EnergyRecoveryVentilator: { // ZoneHVAC : EnergyRecoveryVentilator - SupplyNodeNum = GetFanOutletNode(state, "Fan:OnOff", EquipName, errorfound); + //SupplyNodeNum = GetFanOutletNode(state, "Fan:OnOff", EquipName, errorfound); } break; case DataZoneEquipment::ZoneEquipType::FourPipeFanCoil: { // ZoneHVAC : FourPipeFanCoil - SupplyNodeNum = FanCoilUnits::GetFanCoilZoneInletAirNode(state,EquipIndex); + SupplyNodeNum = FanCoilUnits::GetFanCoilZoneInletAirNode(state, EquipIndex); ReturnNodeNum = FanCoilUnits::GetFanCoilAirInNode(state, EquipIndex); } break; case DataZoneEquipment::ZoneEquipType::OutdoorAirUnit: { // ZoneHVAC : OutdoorAirUnit - SupplyNodeNum = OutdoorAirUnit::GetOutdoorAirUnitZoneInletNode(state,EquipIndex); + SupplyNodeNum = OutdoorAirUnit::GetOutdoorAirUnitZoneInletNode(state, EquipIndex); ReturnNodeNum = OutdoorAirUnit::GetOutdoorAirUnitReturnAirNode(state, EquipIndex); } break; case DataZoneEquipment::ZoneEquipType::PackagedTerminalAirConditioner: { // ZoneHVAC : PackagedTerminalAirConditioner From 73c79b284dbd11b47519f25d372d99a51a8fa415 Mon Sep 17 00:00:00 2001 From: Lixing Gu Date: Thu, 2 May 2024 16:33:50 -0400 Subject: [PATCH 07/57] Clang format --- src/EnergyPlus/RoomAirModelManager.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/EnergyPlus/RoomAirModelManager.cc b/src/EnergyPlus/RoomAirModelManager.cc index 0ec8890ecc5..3d75e46788e 100644 --- a/src/EnergyPlus/RoomAirModelManager.cc +++ b/src/EnergyPlus/RoomAirModelManager.cc @@ -2729,7 +2729,7 @@ namespace RoomAir { SupplyNodeNum = HVACVariableRefrigerantFlow::GetVRFTUZoneInletAirNode(state, EquipIndex); } break; case DataZoneEquipment::ZoneEquipType::EnergyRecoveryVentilator: { // ZoneHVAC : EnergyRecoveryVentilator - //SupplyNodeNum = GetFanOutletNode(state, "Fan:OnOff", EquipName, errorfound); + // SupplyNodeNum = GetFanOutletNode(state, "Fan:OnOff", EquipName, errorfound); } break; case DataZoneEquipment::ZoneEquipType::FourPipeFanCoil: { // ZoneHVAC : FourPipeFanCoil SupplyNodeNum = FanCoilUnits::GetFanCoilZoneInletAirNode(state, EquipIndex); From 32d7e2641bd1f2d226fcfc4a76247fa149ed245f Mon Sep 17 00:00:00 2001 From: Lixing Gu Date: Mon, 6 May 2024 10:14:44 -0400 Subject: [PATCH 08/57] Correct a mistake --- src/EnergyPlus/RoomAirModelManager.cc | 3 ++- tst/EnergyPlus/unit/RoomAirflowNetwork.unit.cc | 9 +++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/EnergyPlus/RoomAirModelManager.cc b/src/EnergyPlus/RoomAirModelManager.cc index 3d75e46788e..109683cf620 100644 --- a/src/EnergyPlus/RoomAirModelManager.cc +++ b/src/EnergyPlus/RoomAirModelManager.cc @@ -75,6 +75,7 @@ #include #include #include +#include #include #include #include @@ -2729,7 +2730,7 @@ namespace RoomAir { SupplyNodeNum = HVACVariableRefrigerantFlow::GetVRFTUZoneInletAirNode(state, EquipIndex); } break; case DataZoneEquipment::ZoneEquipType::EnergyRecoveryVentilator: { // ZoneHVAC : EnergyRecoveryVentilator - // SupplyNodeNum = GetFanOutletNode(state, "Fan:OnOff", EquipName, errorfound); + SupplyNodeNum = HVACStandAloneERV::GetStandAloneERVOutAirNode(state, EquipIndex); } break; case DataZoneEquipment::ZoneEquipType::FourPipeFanCoil: { // ZoneHVAC : FourPipeFanCoil SupplyNodeNum = FanCoilUnits::GetFanCoilZoneInletAirNode(state, EquipIndex); diff --git a/tst/EnergyPlus/unit/RoomAirflowNetwork.unit.cc b/tst/EnergyPlus/unit/RoomAirflowNetwork.unit.cc index ae365f29cc5..cfb694c8af9 100644 --- a/tst/EnergyPlus/unit/RoomAirflowNetwork.unit.cc +++ b/tst/EnergyPlus/unit/RoomAirflowNetwork.unit.cc @@ -72,6 +72,7 @@ #include #include #include +#include #include #include #include @@ -633,10 +634,10 @@ TEST_F(EnergyPlusFixture, RoomAirflowNetwork_CheckEquipName_Test) state->dataLoopNodes->NodeID(1) = "SupplyNode1"; state->dataLoopNodes->NodeID(2) = "ReturnNode1"; zoneEquipType = DataZoneEquipment::ZoneEquipType::EnergyRecoveryVentilator; - state->dataFans->GetFanInputFlag = false; - state->dataFans->Fan.allocate(1); - state->dataFans->Fan(1).FanName = EquipName; - state->dataFans->Fan(1).OutletNodeNum = 1; + state->dataHVACStandAloneERV->GetERVInputFlag = false; + state->dataHVACStandAloneERV->StandAloneERV.allocate(1); + state->dataHVACStandAloneERV->NumStandAloneERVs = 1; + state->dataHVACStandAloneERV->StandAloneERV(1).SupplyAirInletNode = 1; check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); if (check) { EXPECT_EQ("SupplyNode1", SupplyNodeName); From 1698d9ba650520fe058549abe22562c29664973b Mon Sep 17 00:00:00 2001 From: Lixing Gu Date: Wed, 29 May 2024 10:51:35 -0400 Subject: [PATCH 09/57] Add a test file with FanCoil and change code accordingly --- src/EnergyPlus/FanCoilUnits.cc | 18 ++++++++++++++++-- src/EnergyPlus/FanCoilUnits.hh | 4 ++-- src/EnergyPlus/RoomAirModelManager.cc | 20 ++++++++++---------- 3 files changed, 28 insertions(+), 14 deletions(-) diff --git a/src/EnergyPlus/FanCoilUnits.cc b/src/EnergyPlus/FanCoilUnits.cc index f2b342b35d8..fdc3dd3793b 100644 --- a/src/EnergyPlus/FanCoilUnits.cc +++ b/src/EnergyPlus/FanCoilUnits.cc @@ -4093,7 +4093,7 @@ namespace FanCoilUnits { } } - int GetFanCoilZoneInletAirNode(EnergyPlusData &state, int const FanCoilNum) + int GetFanCoilZoneInletAirNode(EnergyPlusData &state, int &FanCoilNum, std::string_view CompName) { // FUNCTION INFORMATION: @@ -4112,10 +4112,17 @@ namespace FanCoilUnits { return state.dataFanCoilUnits->FanCoil(FanCoilNum).AirOutNode; } + if (FanCoilNum == 0 && CompName != "") { + FanCoilNum = Util::FindItemInList(CompName, state.dataFanCoilUnits->FanCoil); + if (FanCoilNum == 0) { + ShowFatalError(state, format("SimFanCoil: Unit not found={}", CompName)); + } + return state.dataFanCoilUnits->FanCoil(FanCoilNum).AirOutNode; + } return 0; } - int GetFanCoilAirInNode(EnergyPlusData &state, int const FanCoilNum) + int GetFanCoilAirInNode(EnergyPlusData &state, int &FanCoilNum, std::string_view CompName) { // FUNCTION INFORMATION: @@ -4134,6 +4141,13 @@ namespace FanCoilUnits { return state.dataFanCoilUnits->FanCoil(FanCoilNum).AirInNode; } + if (FanCoilNum == 0 && CompName != "") { + FanCoilNum = Util::FindItemInList(CompName, state.dataFanCoilUnits->FanCoil); + if (FanCoilNum == 0) { + ShowFatalError(state, format("SimFanCoil: Unit not found={}", CompName)); + } + return state.dataFanCoilUnits->FanCoil(FanCoilNum).AirInNode; + } return 0; } diff --git a/src/EnergyPlus/FanCoilUnits.hh b/src/EnergyPlus/FanCoilUnits.hh index 1936bee3e2f..03091b00f32 100644 --- a/src/EnergyPlus/FanCoilUnits.hh +++ b/src/EnergyPlus/FanCoilUnits.hh @@ -318,9 +318,9 @@ namespace FanCoilUnits { void ReportFanCoilUnit(EnergyPlusData &state, int FanCoilNum); // number of the current fan coil unit being simulated - int GetFanCoilZoneInletAirNode(EnergyPlusData &state, int FanCoilNum); + int GetFanCoilZoneInletAirNode(EnergyPlusData &state, int &FanCoilNum, std::string_view CompName = ""); - int GetFanCoilAirInNode(EnergyPlusData &state, int FanCoilNum); + int GetFanCoilAirInNode(EnergyPlusData &state, int &FanCoilNum, std::string_view CompName = ""); int GetFanCoilOutAirNode(EnergyPlusData &state, int FanCoilNum); diff --git a/src/EnergyPlus/RoomAirModelManager.cc b/src/EnergyPlus/RoomAirModelManager.cc index 109683cf620..fd89474081d 100644 --- a/src/EnergyPlus/RoomAirModelManager.cc +++ b/src/EnergyPlus/RoomAirModelManager.cc @@ -1577,11 +1577,11 @@ namespace RoomAir { } // loop thru TotNumOfRAFNNodeGainsLists // Get data of HVAC equipment - ipsc->cCurrentModuleObject = "RoomAir:Node:AirflowNetwork:HVACEquipment"; - TotNumOfRAFNNodeHVACLists = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, ipsc->cCurrentModuleObject); + std::string const cCurrentModuleObject = "RoomAir:Node:AirflowNetwork:HVACEquipment"; + TotNumOfRAFNNodeHVACLists = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject); for (int Loop = 1; Loop <= TotNumOfRAFNNodeHVACLists; ++Loop) { state.dataInputProcessing->inputProcessor->getObjectItem(state, - ipsc->cCurrentModuleObject, + cCurrentModuleObject, Loop, ipsc->cAlphaArgs, NumAlphas, @@ -1593,10 +1593,10 @@ namespace RoomAir { ipsc->cAlphaFieldNames, ipsc->cNumericFieldNames); - ErrorObjectHeader eoh{routineName, ipsc->cCurrentModuleObject, ipsc->cAlphaArgs(1)}; + ErrorObjectHeader eoh{routineName, cCurrentModuleObject, ipsc->cAlphaArgs(1)}; if (mod((NumAlphas + NumNumbers - 1), 4) != 0) { - ShowSevereError(state, format("GetRoomAirflowNetworkData: For {}: {}", ipsc->cCurrentModuleObject, ipsc->cAlphaArgs(1))); + ShowSevereError(state, format("GetRoomAirflowNetworkData: For {}: {}", cCurrentModuleObject, ipsc->cAlphaArgs(1))); ShowContinueError(state, format("Extensible field set are not evenly divisable by 4. Number of data entries = {}", fmt::to_string(NumAlphas + NumNumbers - 1))); @@ -1619,8 +1619,8 @@ namespace RoomAir { auto &roomAFNNode = roomAFNZoneInfo.Node(RAFNNodeNum); if (allocated(roomAFNNode.HVAC)) { ShowSevereError(state, format("GetRoomAirflowNetworkData: Invalid {} = {}", ipsc->cAlphaFieldNames(1), ipsc->cAlphaArgs(1))); - ShowContinueError(state, format("Entered in {} = {}", ipsc->cCurrentModuleObject, ipsc->cAlphaArgs(1))); - ShowContinueError(state, format("Duplicate {} name.", ipsc->cCurrentModuleObject)); + ShowContinueError(state, format("Entered in {} = {}", cCurrentModuleObject, ipsc->cAlphaArgs(1))); + ShowContinueError(state, format("Duplicate {} name.", cCurrentModuleObject)); ErrorsFound = true; continue; } @@ -1670,7 +1670,7 @@ namespace RoomAir { format("GetRoomAirflowNetworkData: Invalid {} = {}", ipsc->cAlphaFieldNames(3 + (iEquip - 1) * 2), ipsc->cAlphaArgs(2 + (iEquip - 1) * 2))); - ShowContinueError(state, format("Entered in {} = {}", ipsc->cCurrentModuleObject, ipsc->cAlphaArgs(1))); + ShowContinueError(state, format("Entered in {} = {}", cCurrentModuleObject, ipsc->cAlphaArgs(1))); ShowContinueError(state, "Internal gain did not match correctly"); ErrorsFound = true; } @@ -2733,8 +2733,8 @@ namespace RoomAir { SupplyNodeNum = HVACStandAloneERV::GetStandAloneERVOutAirNode(state, EquipIndex); } break; case DataZoneEquipment::ZoneEquipType::FourPipeFanCoil: { // ZoneHVAC : FourPipeFanCoil - SupplyNodeNum = FanCoilUnits::GetFanCoilZoneInletAirNode(state, EquipIndex); - ReturnNodeNum = FanCoilUnits::GetFanCoilAirInNode(state, EquipIndex); + SupplyNodeNum = FanCoilUnits::GetFanCoilZoneInletAirNode(state, EquipIndex, EquipName); + ReturnNodeNum = FanCoilUnits::GetFanCoilAirInNode(state, EquipIndex, EquipName); } break; case DataZoneEquipment::ZoneEquipType::OutdoorAirUnit: { // ZoneHVAC : OutdoorAirUnit SupplyNodeNum = OutdoorAirUnit::GetOutdoorAirUnitZoneInletNode(state, EquipIndex); From 1d30477420f985284237b91f8ec3d1927dfa106b Mon Sep 17 00:00:00 2001 From: Lixing Gu Date: Wed, 29 May 2024 16:07:21 -0400 Subject: [PATCH 10/57] Get correct index for unitary --- src/EnergyPlus/RoomAirModelManager.cc | 15 +++++++++------ src/EnergyPlus/UnitarySystem.cc | 19 +++++++++++++++++++ src/EnergyPlus/UnitarySystem.hh | 2 ++ 3 files changed, 30 insertions(+), 6 deletions(-) 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 { From 097c9ed13d9a9705a04651eed813cebb115de7b5 Mon Sep 17 00:00:00 2001 From: Lixing Gu Date: Thu, 30 May 2024 09:20:48 -0400 Subject: [PATCH 11/57] Address further comments --- src/EnergyPlus/UnitarySystem.cc | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/EnergyPlus/UnitarySystem.cc b/src/EnergyPlus/UnitarySystem.cc index e4ee05808fa..09155500b4d 100644 --- a/src/EnergyPlus/UnitarySystem.cc +++ b/src/EnergyPlus/UnitarySystem.cc @@ -16581,11 +16581,15 @@ namespace UnitarySystems { return airNode; } - int - getIndex(EnergyPlusData &state, std::string const &UnitarySysName, DataZoneEquipment::ZoneEquipType zoneEquipType, bool &errFlag) + int getIndex(EnergyPlusData &state, std::string const &UnitarySysName, DataZoneEquipment::ZoneEquipType zoneEquipType, bool &errFlag) { - int EquipIndex = 0; + if (state.dataUnitarySystems->getInputOnceFlag) { + UnitarySystems::UnitarySys::getUnitarySystemInput(state, UnitarySysName, false, 0); + state.dataUnitarySystems->getInputOnceFlag = false; + } + + int EquipIndex = -1; for (int UnitarySysNum = 0; UnitarySysNum < state.dataUnitarySystems->numUnitarySystems; ++UnitarySysNum) { if (Util::SameString(UnitarySysName, state.dataUnitarySystems->unitarySys[UnitarySysNum].Name)) { if (zoneEquipType == DataZoneEquipment::ZoneEquipType::PackagedTerminalAirConditioner || From 214ea1dbb202eb8cc27b3392c7d366abebe6c6db Mon Sep 17 00:00:00 2001 From: Lixing Gu Date: Thu, 30 May 2024 11:39:15 -0400 Subject: [PATCH 12/57] Add one more optional argument --- src/EnergyPlus/RoomAirModelManager.cc | 6 +++--- src/EnergyPlus/UnitarySystem.cc | 8 +++++--- src/EnergyPlus/UnitarySystem.hh | 6 +++++- 3 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/EnergyPlus/RoomAirModelManager.cc b/src/EnergyPlus/RoomAirModelManager.cc index da3cae900e5..8850e2d63d3 100644 --- a/src/EnergyPlus/RoomAirModelManager.cc +++ b/src/EnergyPlus/RoomAirModelManager.cc @@ -2741,12 +2741,12 @@ namespace RoomAir { ReturnNodeNum = OutdoorAirUnit::GetOutdoorAirUnitReturnAirNode(state, EquipIndex); } break; case DataZoneEquipment::ZoneEquipType::PackagedTerminalAirConditioner: { // ZoneHVAC : PackagedTerminalAirConditioner - EquipIndex = UnitarySystems::getIndex(state, EquipName, zoneEquipType, errorfound); + EquipIndex = UnitarySystems::getZoneEqIndex(state, EquipName, zoneEquipType, errorfound); SupplyNodeNum = state.dataUnitarySystems->unitarySys[EquipIndex].AirOutNode; ReturnNodeNum = state.dataUnitarySystems->unitarySys[EquipIndex].AirInNode; } break; case DataZoneEquipment::ZoneEquipType::PackagedTerminalHeatPump: { // ZoneHVAC : PackagedTerminalHeatPump - EquipIndex = UnitarySystems::getIndex(state, EquipName, zoneEquipType, errorfound); + EquipIndex = UnitarySystems::getZoneEqIndex(state, EquipName, zoneEquipType, errorfound); SupplyNodeNum = state.dataUnitarySystems->unitarySys[EquipIndex].AirOutNode; ReturnNodeNum = state.dataUnitarySystems->unitarySys[EquipIndex].AirInNode; } break; @@ -2763,7 +2763,7 @@ namespace RoomAir { SupplyNodeNum = VentilatedSlab::GetVentilatedSlabZoneAirInNode(state, EquipIndex); } break; case DataZoneEquipment::ZoneEquipType::PackagedTerminalHeatPumpWaterToAir: { // ZoneHVAC : WaterToAirHeatPump - EquipIndex = UnitarySystems::getIndex(state, EquipName, zoneEquipType, errorfound); + EquipIndex = UnitarySystems::getZoneEqIndex(state, EquipName, zoneEquipType, errorfound); SupplyNodeNum = state.dataUnitarySystems->unitarySys[EquipIndex].AirOutNode; ReturnNodeNum = state.dataUnitarySystems->unitarySys[EquipIndex].AirInNode; } break; diff --git a/src/EnergyPlus/UnitarySystem.cc b/src/EnergyPlus/UnitarySystem.cc index 09155500b4d..7cbc5a2b83c 100644 --- a/src/EnergyPlus/UnitarySystem.cc +++ b/src/EnergyPlus/UnitarySystem.cc @@ -16581,11 +16581,12 @@ namespace UnitarySystems { return airNode; } - int getIndex(EnergyPlusData &state, std::string const &UnitarySysName, DataZoneEquipment::ZoneEquipType zoneEquipType, bool &errFlag) + int getZoneEqIndex( + EnergyPlusData &state, std::string const &UnitarySysName, DataZoneEquipment::ZoneEquipType zoneEquipType, bool &errFlag, int const OAUnitNum) { if (state.dataUnitarySystems->getInputOnceFlag) { - UnitarySystems::UnitarySys::getUnitarySystemInput(state, UnitarySysName, false, 0); + UnitarySystems::UnitarySys::getUnitarySystemInput(state, UnitarySysName, false, OAUnitNum); state.dataUnitarySystems->getInputOnceFlag = false; } @@ -16594,7 +16595,8 @@ namespace UnitarySystems { if (Util::SameString(UnitarySysName, state.dataUnitarySystems->unitarySys[UnitarySysNum].Name)) { if (zoneEquipType == DataZoneEquipment::ZoneEquipType::PackagedTerminalAirConditioner || zoneEquipType == DataZoneEquipment::ZoneEquipType::PackagedTerminalHeatPump || - zoneEquipType == DataZoneEquipment::ZoneEquipType::PackagedTerminalHeatPumpWaterToAir) { + zoneEquipType == DataZoneEquipment::ZoneEquipType::PackagedTerminalHeatPumpWaterToAir || + zoneEquipType == DataZoneEquipment::ZoneEquipType::UnitarySystem) { EquipIndex = UnitarySysNum; break; } diff --git a/src/EnergyPlus/UnitarySystem.hh b/src/EnergyPlus/UnitarySystem.hh index d602f20dc2e..474ccb6bf5a 100644 --- a/src/EnergyPlus/UnitarySystem.hh +++ b/src/EnergyPlus/UnitarySystem.hh @@ -966,7 +966,11 @@ 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); + int getZoneEqIndex(EnergyPlusData &state, + std::string const &UnitarySysName, + DataZoneEquipment::ZoneEquipType zoneEquipType, + bool &errFlag, + int const OAUnitNum = 0); } // namespace UnitarySystems struct UnitarySystemsData : BaseGlobalStruct From 0a71ac929e588f35e72f774241dac49e4c1a4e66 Mon Sep 17 00:00:00 2001 From: Lixing Gu Date: Thu, 30 May 2024 14:41:28 -0400 Subject: [PATCH 13/57] GetEqIndex for fan coil --- src/EnergyPlus/FanCoilUnits.cc | 37 +++++++++++++++------------ src/EnergyPlus/FanCoilUnits.hh | 5 ++-- src/EnergyPlus/RoomAirModelManager.cc | 5 ++-- 3 files changed, 27 insertions(+), 20 deletions(-) diff --git a/src/EnergyPlus/FanCoilUnits.cc b/src/EnergyPlus/FanCoilUnits.cc index ad78b4d7889..62886e1d69c 100644 --- a/src/EnergyPlus/FanCoilUnits.cc +++ b/src/EnergyPlus/FanCoilUnits.cc @@ -4097,7 +4097,7 @@ namespace FanCoilUnits { } } - int GetFanCoilZoneInletAirNode(EnergyPlusData &state, int &FanCoilNum, std::string_view CompName) + int GetFanCoilZoneInletAirNode(EnergyPlusData &state, int const FanCoilNum) { // FUNCTION INFORMATION: @@ -4116,17 +4116,10 @@ namespace FanCoilUnits { return state.dataFanCoilUnits->FanCoil(FanCoilNum).AirOutNode; } - if (FanCoilNum == 0 && CompName != "") { - FanCoilNum = Util::FindItemInList(CompName, state.dataFanCoilUnits->FanCoil); - if (FanCoilNum == 0) { - ShowFatalError(state, format("SimFanCoil: Unit not found={}", CompName)); - } - return state.dataFanCoilUnits->FanCoil(FanCoilNum).AirOutNode; - } return 0; } - int GetFanCoilAirInNode(EnergyPlusData &state, int &FanCoilNum, std::string_view CompName) + int GetFanCoilAirInNode(EnergyPlusData &state, int const FanCoilNum) { // FUNCTION INFORMATION: @@ -4145,13 +4138,6 @@ namespace FanCoilUnits { return state.dataFanCoilUnits->FanCoil(FanCoilNum).AirInNode; } - if (FanCoilNum == 0 && CompName != "") { - FanCoilNum = Util::FindItemInList(CompName, state.dataFanCoilUnits->FanCoil); - if (FanCoilNum == 0) { - ShowFatalError(state, format("SimFanCoil: Unit not found={}", CompName)); - } - return state.dataFanCoilUnits->FanCoil(FanCoilNum).AirInNode; - } return 0; } @@ -4455,6 +4441,25 @@ namespace FanCoilUnits { } } + int getEqIndex(EnergyPlusData &state, std::string_view CompName, bool &errFlag) + { + if (state.dataFanCoilUnits->GetFanCoilInputFlag) { + GetFanCoilUnits(state); + state.dataFanCoilUnits->GetFanCoilInputFlag = false; + } + + errFlag = true; + for (int FanCoilIndex = 1; FanCoilIndex <= state.dataFanCoilUnits->Num4PipeFanCoils; ++FanCoilIndex) { + auto &fanCoil = state.dataFanCoilUnits->FanCoil(FanCoilIndex); + if (Util::SameString(fanCoil.Name, CompName)) { + errFlag = false; + return FanCoilIndex; + } + } + + return 0; + } + } // namespace FanCoilUnits } // namespace EnergyPlus diff --git a/src/EnergyPlus/FanCoilUnits.hh b/src/EnergyPlus/FanCoilUnits.hh index 87da87cf4aa..5dce466105b 100644 --- a/src/EnergyPlus/FanCoilUnits.hh +++ b/src/EnergyPlus/FanCoilUnits.hh @@ -319,9 +319,9 @@ namespace FanCoilUnits { void ReportFanCoilUnit(EnergyPlusData &state, int FanCoilNum); // number of the current fan coil unit being simulated - int GetFanCoilZoneInletAirNode(EnergyPlusData &state, int &FanCoilNum, std::string_view CompName = ""); + int GetFanCoilZoneInletAirNode(EnergyPlusData &state, int const FanCoilNum); - int GetFanCoilAirInNode(EnergyPlusData &state, int &FanCoilNum, std::string_view CompName = ""); + int GetFanCoilAirInNode(EnergyPlusData &state, int const FanCoilNum); int GetFanCoilOutAirNode(EnergyPlusData &state, int FanCoilNum); @@ -382,6 +382,7 @@ namespace FanCoilUnits { int WaterControlNode, Real64 MinWaterFlow); + int getEqIndex(EnergyPlusData &state, std::string_view CompName, bool &errFlag); } // namespace FanCoilUnits struct FanCoilUnitsData : BaseGlobalStruct diff --git a/src/EnergyPlus/RoomAirModelManager.cc b/src/EnergyPlus/RoomAirModelManager.cc index 8850e2d63d3..24e4e921777 100644 --- a/src/EnergyPlus/RoomAirModelManager.cc +++ b/src/EnergyPlus/RoomAirModelManager.cc @@ -2733,8 +2733,9 @@ namespace RoomAir { SupplyNodeNum = HVACStandAloneERV::GetStandAloneERVOutAirNode(state, EquipIndex); } break; case DataZoneEquipment::ZoneEquipType::FourPipeFanCoil: { // ZoneHVAC : FourPipeFanCoil - SupplyNodeNum = FanCoilUnits::GetFanCoilZoneInletAirNode(state, EquipIndex, EquipName); - ReturnNodeNum = FanCoilUnits::GetFanCoilAirInNode(state, EquipIndex, EquipName); + EquipIndex = FanCoilUnits::getEqIndex(state, EquipName, errorfound); + SupplyNodeNum = state.dataFanCoilUnits->FanCoil(EquipIndex).AirOutNode; + ReturnNodeNum = state.dataFanCoilUnits->FanCoil(EquipIndex).AirInNode; } break; case DataZoneEquipment::ZoneEquipType::OutdoorAirUnit: { // ZoneHVAC : OutdoorAirUnit SupplyNodeNum = OutdoorAirUnit::GetOutdoorAirUnitZoneInletNode(state, EquipIndex); From f4a17a5cd64ab9745cb7dd444934a3075aa3fb8f Mon Sep 17 00:00:00 2001 From: Lixing Gu Date: Thu, 30 May 2024 15:14:47 -0400 Subject: [PATCH 14/57] Solve an error --- src/EnergyPlus/FanCoilUnits.cc | 8 ++++---- src/EnergyPlus/UnitarySystem.cc | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/EnergyPlus/FanCoilUnits.cc b/src/EnergyPlus/FanCoilUnits.cc index 62886e1d69c..0483dbf3467 100644 --- a/src/EnergyPlus/FanCoilUnits.cc +++ b/src/EnergyPlus/FanCoilUnits.cc @@ -4448,16 +4448,16 @@ namespace FanCoilUnits { state.dataFanCoilUnits->GetFanCoilInputFlag = false; } - errFlag = true; + int EquipIndex = 0; for (int FanCoilIndex = 1; FanCoilIndex <= state.dataFanCoilUnits->Num4PipeFanCoils; ++FanCoilIndex) { auto &fanCoil = state.dataFanCoilUnits->FanCoil(FanCoilIndex); if (Util::SameString(fanCoil.Name, CompName)) { - errFlag = false; - return FanCoilIndex; + EquipIndex = FanCoilIndex; } } - return 0; + if (EquipIndex == 0) errFlag = true; + return EquipIndex; } } // namespace FanCoilUnits diff --git a/src/EnergyPlus/UnitarySystem.cc b/src/EnergyPlus/UnitarySystem.cc index 7cbc5a2b83c..04d7c31013d 100644 --- a/src/EnergyPlus/UnitarySystem.cc +++ b/src/EnergyPlus/UnitarySystem.cc @@ -16586,7 +16586,7 @@ namespace UnitarySystems { { if (state.dataUnitarySystems->getInputOnceFlag) { - UnitarySystems::UnitarySys::getUnitarySystemInput(state, UnitarySysName, false, OAUnitNum); + UnitarySystems::UnitarySys::getUnitarySystemInput(state, UnitarySysName, true, OAUnitNum); state.dataUnitarySystems->getInputOnceFlag = false; } From 56d97c12c05415f68f733b792bbfab80d647433a Mon Sep 17 00:00:00 2001 From: Lixing Gu Date: Wed, 5 Jun 2024 13:47:04 -0400 Subject: [PATCH 15/57] Create getEqIndex functions --- src/EnergyPlus/FanCoilUnits.cc | 2 +- src/EnergyPlus/HVACStandAloneERV.cc | 19 +++++++ src/EnergyPlus/HVACStandAloneERV.hh | 2 + src/EnergyPlus/HVACVariableRefrigerantFlow.cc | 19 +++++++ src/EnergyPlus/HVACVariableRefrigerantFlow.hh | 2 + .../HybridUnitaryAirConditioners.cc | 18 +++++++ .../HybridUnitaryAirConditioners.hh | 2 + src/EnergyPlus/OutdoorAirUnit.cc | 18 +++++++ src/EnergyPlus/OutdoorAirUnit.hh | 2 + src/EnergyPlus/PurchasedAirManager.cc | 18 +++++++ src/EnergyPlus/PurchasedAirManager.hh | 2 + src/EnergyPlus/RoomAirModelManager.cc | 51 +++++++++++-------- src/EnergyPlus/UnitHeater.cc | 17 +++++++ src/EnergyPlus/UnitHeater.hh | 6 ++- src/EnergyPlus/UnitVentilator.cc | 17 +++++++ src/EnergyPlus/UnitVentilator.hh | 2 + src/EnergyPlus/VentilatedSlab.cc | 17 +++++++ src/EnergyPlus/VentilatedSlab.hh | 1 + src/EnergyPlus/WaterThermalTanks.cc | 18 +++++++ src/EnergyPlus/WaterThermalTanks.hh | 2 + src/EnergyPlus/WindowAC.cc | 18 +++++++ src/EnergyPlus/WindowAC.hh | 2 + src/EnergyPlus/ZoneDehumidifier.cc | 18 +++++++ src/EnergyPlus/ZoneDehumidifier.hh | 2 + .../unit/RoomAirflowNetwork.unit.cc | 12 +++++ 25 files changed, 264 insertions(+), 23 deletions(-) diff --git a/src/EnergyPlus/FanCoilUnits.cc b/src/EnergyPlus/FanCoilUnits.cc index 0483dbf3467..048abf9b95e 100644 --- a/src/EnergyPlus/FanCoilUnits.cc +++ b/src/EnergyPlus/FanCoilUnits.cc @@ -4449,7 +4449,7 @@ namespace FanCoilUnits { } int EquipIndex = 0; - for (int FanCoilIndex = 1; FanCoilIndex <= state.dataFanCoilUnits->Num4PipeFanCoils; ++FanCoilIndex) { + for (int FanCoilIndex = 1; FanCoilIndex <= state.dataFanCoilUnits->NumFanCoils; ++FanCoilIndex) { auto &fanCoil = state.dataFanCoilUnits->FanCoil(FanCoilIndex); if (Util::SameString(fanCoil.Name, CompName)) { EquipIndex = FanCoilIndex; diff --git a/src/EnergyPlus/HVACStandAloneERV.cc b/src/EnergyPlus/HVACStandAloneERV.cc index f4919236616..9ae6958a2f8 100644 --- a/src/EnergyPlus/HVACStandAloneERV.cc +++ b/src/EnergyPlus/HVACStandAloneERV.cc @@ -1686,4 +1686,23 @@ bool GetStandAloneERVNodeNumber(EnergyPlusData &state, int const NodeNumber) return false; } + int getEqIndex(EnergyPlusData &state, std::string_view CompName, bool &errFlag) +{ + if (state.dataHVACStandAloneERV->GetERVInputFlag) { + GetStandAloneERV(state); + state.dataHVACStandAloneERV->GetERVInputFlag = false; + } + + int EqIndex = 0; + errFlag = true; + for (int StandAloneERVNum = 1; StandAloneERVNum <= state.dataHVACStandAloneERV->NumStandAloneERVs; StandAloneERVNum++) { + if (Util::SameString(CompName, state.dataHVACStandAloneERV->StandAloneERV(StandAloneERVNum).Name)) { + EqIndex = StandAloneERVNum; + errFlag = false; + break; + } + } + return EqIndex; +} + } // namespace EnergyPlus::HVACStandAloneERV diff --git a/src/EnergyPlus/HVACStandAloneERV.hh b/src/EnergyPlus/HVACStandAloneERV.hh index 5ee9f82cc5a..4ae1049f1df 100644 --- a/src/EnergyPlus/HVACStandAloneERV.hh +++ b/src/EnergyPlus/HVACStandAloneERV.hh @@ -186,6 +186,8 @@ namespace HVACStandAloneERV { bool GetStandAloneERVNodeNumber(EnergyPlusData &state, int NodeNumber); + int getEqIndex(EnergyPlusData &state, std::string_view CompName, bool &errFlag); + } // namespace HVACStandAloneERV struct HVACStandAloneERVData : BaseGlobalStruct diff --git a/src/EnergyPlus/HVACVariableRefrigerantFlow.cc b/src/EnergyPlus/HVACVariableRefrigerantFlow.cc index dcc34225c5a..aa8926dc591 100644 --- a/src/EnergyPlus/HVACVariableRefrigerantFlow.cc +++ b/src/EnergyPlus/HVACVariableRefrigerantFlow.cc @@ -10768,6 +10768,25 @@ int GetVRFTUReturnAirNode(EnergyPlusData &state, int const VRFTUNum) } } +int getEqIndex(EnergyPlusData &state, std::string_view VRFTUName, bool &errFlag) +{ + if (state.dataHVACVarRefFlow->GetVRFInputFlag) { + GetVRFInput(state); + state.dataHVACVarRefFlow->GetVRFInputFlag = false; + } + + int EqIndex = 0; + errFlag = true; + for (int VRFTUNum = 1; VRFTUNum <= state.dataHVACVarRefFlow->NumVRFTU; VRFTUNum++) { + if (Util::SameString(VRFTUName, state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name)) { + EqIndex = VRFTUNum; + errFlag = false; + break; + } + } + return EqIndex; +} + void getVRFTUZoneLoad( EnergyPlusData &state, int const VRFTUNum, Real64 &zoneLoad, Real64 &LoadToHeatingSP, Real64 &LoadToCoolingSP, bool const InitFlag) { diff --git a/src/EnergyPlus/HVACVariableRefrigerantFlow.hh b/src/EnergyPlus/HVACVariableRefrigerantFlow.hh index b6c0b09796d..bed14c4ea80 100644 --- a/src/EnergyPlus/HVACVariableRefrigerantFlow.hh +++ b/src/EnergyPlus/HVACVariableRefrigerantFlow.hh @@ -972,6 +972,8 @@ namespace HVACVariableRefrigerantFlow { Real64 const T_suc // Compressor suction temperature Te' [C] ); + int getEqIndex(EnergyPlusData &state, std::string_view VRFTUName, bool &errFlag); + } // namespace HVACVariableRefrigerantFlow struct HVACVarRefFlowData : BaseGlobalStruct diff --git a/src/EnergyPlus/HybridUnitaryAirConditioners.cc b/src/EnergyPlus/HybridUnitaryAirConditioners.cc index 9d9147a0487..50069e27aee 100644 --- a/src/EnergyPlus/HybridUnitaryAirConditioners.cc +++ b/src/EnergyPlus/HybridUnitaryAirConditioners.cc @@ -1366,6 +1366,24 @@ int GetHybridUnitaryACReturnAirNode(EnergyPlusData &state, int const CompNum) return GetHybridUnitaryACReturnAirNode; } +int getHybridUnitaryACIndex(EnergyPlusData &state, std::string_view CompName, bool &errFlag) +{ + if (state.dataHybridUnitaryAC->GetInputZoneHybridEvap) { + GetInputZoneHybridUnitaryAirConditioners(state, errFlag); + state.dataHybridUnitaryAC->GetInputZoneHybridEvap = false; + } + + int EquipIndex = 0; + for (int UnitLoop = 1; UnitLoop <= state.dataHybridUnitaryAC->NumZoneHybridEvap; ++UnitLoop) { + if (Util::SameString(state.dataHybridUnitaryAC->ZoneHybridUnitaryAirConditioner(UnitLoop).Name, CompName)) { + EquipIndex = UnitLoop; + } + } + + if (EquipIndex == 0) errFlag = true; + return EquipIndex; +} + //***************************************************************************************** } // namespace EnergyPlus::HybridUnitaryAirConditioners diff --git a/src/EnergyPlus/HybridUnitaryAirConditioners.hh b/src/EnergyPlus/HybridUnitaryAirConditioners.hh index 64f0a152e76..c979bd12218 100644 --- a/src/EnergyPlus/HybridUnitaryAirConditioners.hh +++ b/src/EnergyPlus/HybridUnitaryAirConditioners.hh @@ -98,6 +98,8 @@ namespace HybridUnitaryAirConditioners { int GetHybridUnitaryACReturnAirNode(EnergyPlusData &state, int UnitNum); + int getHybridUnitaryACIndex(EnergyPlusData &state, std::string_view CompName, bool &errFlag); + } // namespace HybridUnitaryAirConditioners struct HybridUnitaryAirConditionersData : BaseGlobalStruct diff --git a/src/EnergyPlus/OutdoorAirUnit.cc b/src/EnergyPlus/OutdoorAirUnit.cc index 2dcc30e4a61..4d993fdde39 100644 --- a/src/EnergyPlus/OutdoorAirUnit.cc +++ b/src/EnergyPlus/OutdoorAirUnit.cc @@ -2471,6 +2471,24 @@ namespace OutdoorAirUnit { return GetOutdoorAirUnitReturnAirNode; } + int getOutdoorAirUnitEqIndex(EnergyPlusData &state, std::string_view EquipName, bool &errFlag) + { + if (state.dataOutdoorAirUnit->GetOutdoorAirUnitInputFlag) { + OutdoorAirUnit::GetOutdoorAirUnitInputs(state); + state.dataOutdoorAirUnit->GetOutdoorAirUnitInputFlag = false; + } + + int EquipIndex = 0; + for (int OAUnitNum = 1; OAUnitNum <= state.dataOutdoorAirUnit->NumOfOAUnits; ++OAUnitNum) { + if (Util::SameString(state.dataOutdoorAirUnit->OutAirUnit(OAUnitNum).Name, EquipName)) { + EquipIndex = OAUnitNum; + } + } + + if (EquipIndex == 0) errFlag = true; + return EquipIndex; + } + } // namespace OutdoorAirUnit } // namespace EnergyPlus diff --git a/src/EnergyPlus/OutdoorAirUnit.hh b/src/EnergyPlus/OutdoorAirUnit.hh index 81eb5084e59..7f166537c91 100644 --- a/src/EnergyPlus/OutdoorAirUnit.hh +++ b/src/EnergyPlus/OutdoorAirUnit.hh @@ -309,6 +309,8 @@ namespace OutdoorAirUnit { int GetOutdoorAirUnitZoneInletNode(EnergyPlusData &state, int OAUnitNum); int GetOutdoorAirUnitReturnAirNode(EnergyPlusData &state, int OAUnitNum); + + int getOutdoorAirUnitEqIndex(EnergyPlusData &state, std::string_view EquipName, bool &errFlag); } // namespace OutdoorAirUnit struct OutdoorAirUnitData : BaseGlobalStruct diff --git a/src/EnergyPlus/PurchasedAirManager.cc b/src/EnergyPlus/PurchasedAirManager.cc index b5e8becc3e3..b1552ec305e 100644 --- a/src/EnergyPlus/PurchasedAirManager.cc +++ b/src/EnergyPlus/PurchasedAirManager.cc @@ -3333,6 +3333,24 @@ int GetPurchasedAirZoneExhaustAirNode(EnergyPlusData &state, int PurchAirNum) return GetPurchasedAirZoneExhaustAirNode; } +int getPurchasedAirIndex(EnergyPlusData &state, std::string_view PurchAirName, bool &errFlag) +{ + if (state.dataPurchasedAirMgr->GetPurchAirInputFlag) { + GetPurchasedAir(state); + state.dataPurchasedAirMgr->GetPurchAirInputFlag = false; + } + + int EquipIndex = 0; + for (int PurchAirNum = 1; PurchAirNum <= state.dataPurchasedAirMgr->NumPurchAir; ++PurchAirNum) { + if (Util::SameString(state.dataPurchasedAirMgr->PurchAir(PurchAirNum).Name, PurchAirName)) { + EquipIndex = PurchAirNum; + } + } + + if (EquipIndex == 0) errFlag = true; + return EquipIndex; +} + Real64 GetPurchasedAirMixedAirTemp(EnergyPlusData &state, int const PurchAirNum) { diff --git a/src/EnergyPlus/PurchasedAirManager.hh b/src/EnergyPlus/PurchasedAirManager.hh index fb06821efc0..db21045584b 100644 --- a/src/EnergyPlus/PurchasedAirManager.hh +++ b/src/EnergyPlus/PurchasedAirManager.hh @@ -381,6 +381,8 @@ namespace PurchasedAirManager { int GetPurchasedAirZoneExhaustAirNode(EnergyPlusData &state, int PurchAirNum); + int getPurchasedAirIndex(EnergyPlusData &state, std::string_view PurchAirName, bool &errFlag); + Real64 GetPurchasedAirMixedAirTemp(EnergyPlusData &state, int PurchAirNum); Real64 GetPurchasedAirMixedAirHumRat(EnergyPlusData &state, int PurchAirNum); diff --git a/src/EnergyPlus/RoomAirModelManager.cc b/src/EnergyPlus/RoomAirModelManager.cc index 24e4e921777..04e7aa5468e 100644 --- a/src/EnergyPlus/RoomAirModelManager.cc +++ b/src/EnergyPlus/RoomAirModelManager.cc @@ -2727,10 +2727,12 @@ namespace RoomAir { switch (zoneEquipType) { case DataZoneEquipment::ZoneEquipType::VariableRefrigerantFlowTerminal: { // ZoneHVAC:TerminalUnit : VariableRefrigerantFlow - SupplyNodeNum = HVACVariableRefrigerantFlow::GetVRFTUZoneInletAirNode(state, EquipIndex); + EquipIndex = HVACVariableRefrigerantFlow::getEqIndex(state, EquipName, errorfound); + SupplyNodeNum = state.dataHVACVarRefFlow->VRFTU(EquipIndex).VRFTUOutletNodeNum; } break; case DataZoneEquipment::ZoneEquipType::EnergyRecoveryVentilator: { // ZoneHVAC : EnergyRecoveryVentilator - SupplyNodeNum = HVACStandAloneERV::GetStandAloneERVOutAirNode(state, EquipIndex); + EquipIndex = HVACStandAloneERV::getEqIndex(state, EquipName, errorfound); + SupplyNodeNum = state.dataHVACStandAloneERV->StandAloneERV(EquipIndex).SupplyAirInletNode; } break; case DataZoneEquipment::ZoneEquipType::FourPipeFanCoil: { // ZoneHVAC : FourPipeFanCoil EquipIndex = FanCoilUnits::getEqIndex(state, EquipName, errorfound); @@ -2738,8 +2740,9 @@ namespace RoomAir { ReturnNodeNum = state.dataFanCoilUnits->FanCoil(EquipIndex).AirInNode; } break; case DataZoneEquipment::ZoneEquipType::OutdoorAirUnit: { // ZoneHVAC : OutdoorAirUnit - SupplyNodeNum = OutdoorAirUnit::GetOutdoorAirUnitZoneInletNode(state, EquipIndex); - ReturnNodeNum = OutdoorAirUnit::GetOutdoorAirUnitReturnAirNode(state, EquipIndex); + EquipIndex = OutdoorAirUnit::getOutdoorAirUnitEqIndex(state, EquipName, errorfound); + SupplyNodeNum = state.dataOutdoorAirUnit->OutAirUnit(EquipIndex).AirOutletNode; + ReturnNodeNum = state.dataOutdoorAirUnit->OutAirUnit(EquipIndex).AirInletNode; } break; case DataZoneEquipment::ZoneEquipType::PackagedTerminalAirConditioner: { // ZoneHVAC : PackagedTerminalAirConditioner EquipIndex = UnitarySystems::getZoneEqIndex(state, EquipName, zoneEquipType, errorfound); @@ -2752,16 +2755,19 @@ namespace RoomAir { ReturnNodeNum = state.dataUnitarySystems->unitarySys[EquipIndex].AirInNode; } break; case DataZoneEquipment::ZoneEquipType::UnitHeater: { // ZoneHVAC : UnitHeater - ReturnNodeNum = UnitHeater::GetUnitHeaterAirInletNode(state, EquipIndex); - SupplyNodeNum = UnitHeater::GetUnitHeaterAirOutletNode(state, EquipIndex); + EquipIndex = UnitHeater::getUnitHeaterIndex(state, EquipName, errorfound); + ReturnNodeNum = state.dataUnitHeaters->UnitHeat(EquipIndex).AirInNode; + SupplyNodeNum = state.dataUnitHeaters->UnitHeat(EquipIndex).AirOutNode; } break; case DataZoneEquipment::ZoneEquipType::UnitVentilator: { // ZoneHVAC : UnitVentilator - ReturnNodeNum = UnitVentilator::GetUnitVentilatorReturnAirNode(state, EquipIndex); - SupplyNodeNum = UnitVentilator::GetUnitVentilatorZoneInletAirNode(state, EquipIndex); + EquipIndex = UnitVentilator::getUnitVentilatorIndex(state, EquipName, errorfound); + ReturnNodeNum = state.dataUnitVentilators->UnitVent(EquipIndex).AirInNode; + SupplyNodeNum = state.dataUnitVentilators->UnitVent(EquipIndex).AirOutNode; } break; case DataZoneEquipment::ZoneEquipType::VentilatedSlab: { // ZoneHVAC : VentilatedSlab - ReturnNodeNum = VentilatedSlab::GetVentilatedSlabReturnAirNode(state, EquipIndex); - SupplyNodeNum = VentilatedSlab::GetVentilatedSlabZoneAirInNode(state, EquipIndex); + EquipIndex = VentilatedSlab::getVentilatedSlabIndex(state, EquipName, errorfound); + ReturnNodeNum = state.dataVentilatedSlab->VentSlab(EquipIndex).ReturnAirNode; + SupplyNodeNum = state.dataVentilatedSlab->VentSlab(EquipIndex).ZoneAirInNode; } break; case DataZoneEquipment::ZoneEquipType::PackagedTerminalHeatPumpWaterToAir: { // ZoneHVAC : WaterToAirHeatPump EquipIndex = UnitarySystems::getZoneEqIndex(state, EquipName, zoneEquipType, errorfound); @@ -2769,8 +2775,9 @@ namespace RoomAir { ReturnNodeNum = state.dataUnitarySystems->unitarySys[EquipIndex].AirInNode; } break; case DataZoneEquipment::ZoneEquipType::WindowAirConditioner: { // ZoneHVAC : WindowAirConditioner - ReturnNodeNum = WindowAC::GetWindowACReturnAirNode(state, EquipIndex); - SupplyNodeNum = WindowAC::GetWindowACZoneInletAirNode(state, EquipIndex); + EquipIndex = WindowAC::getWindowACIndex(state, EquipName, errorfound); + ReturnNodeNum = state.dataWindowAC->WindAC(EquipIndex).AirInNode; + SupplyNodeNum = state.dataWindowAC->WindAC(EquipIndex).AirOutNode; } break; case DataZoneEquipment::ZoneEquipType::BaseboardElectric: { // ZoneHVAC : Baseboard : RadiantConvective : Electric // convective equipment without node connection. Will handle later @@ -2797,12 +2804,14 @@ namespace RoomAir { SupplyNodeName = ""; } break; case DataZoneEquipment::ZoneEquipType::DehumidifierDX: { // ZoneHVAC : Dehumidifier : DX - ReturnNodeNum = ZoneDehumidifier::GetZoneDehumidifierAirInletNodeNum(state, EquipIndex); - SupplyNodeNum = ZoneDehumidifier::GetZoneDehumidifierAirOutletNodeNum(state, EquipIndex); + EquipIndex = ZoneDehumidifier::getZoneDehumidifierIndex(state, EquipName, errorfound); + ReturnNodeNum = state.dataZoneDehumidifier->ZoneDehumid(EquipIndex).AirInletNodeNum; + SupplyNodeNum = state.dataZoneDehumidifier->ZoneDehumid(EquipIndex).AirOutletNodeNum; } break; case DataZoneEquipment::ZoneEquipType::PurchasedAir: { // ZoneHVAC : IdealLoadsAirSystem - ReturnNodeNum = PurchasedAirManager::GetPurchasedAirZoneExhaustAirNode(state, EquipIndex); - SupplyNodeNum = PurchasedAirManager::GetPurchasedAirZoneInletAirNode(state, EquipIndex); + EquipIndex = PurchasedAirManager::getPurchasedAirIndex(state, EquipName, errorfound); + ReturnNodeNum = state.dataPurchasedAirMgr->PurchAir(EquipIndex).ZoneExhaustAirNodeNum; + SupplyNodeNum = state.dataPurchasedAirMgr->PurchAir(EquipIndex).ZoneSupplyAirNodeNum; } break; case DataZoneEquipment::ZoneEquipType::RefrigerationChillerSet: { // ZoneHVAC : RefrigerationChillerSet // May not apply @@ -2810,16 +2819,18 @@ namespace RoomAir { // ReturnNodeName = Alphas(4); } break; case DataZoneEquipment::ZoneEquipType::HybridEvaporativeCooler: { // ZoneHVAC : HybridUnitaryAirConditioners - ReturnNodeNum = HybridUnitaryAirConditioners::GetHybridUnitaryACReturnAirNode(state, EquipIndex); - SupplyNodeNum = HybridUnitaryAirConditioners::GetHybridUnitaryACZoneInletNode(state, EquipIndex); + EquipIndex = HybridUnitaryAirConditioners::getHybridUnitaryACIndex(state, EquipName, errorfound); + ReturnNodeNum = state.dataHybridUnitaryAC->ZoneHybridUnitaryAirConditioner(EquipIndex).InletNode; + SupplyNodeNum = state.dataHybridUnitaryAC->ZoneHybridUnitaryAirConditioner(EquipIndex).OutletNode; } break; case DataZoneEquipment::ZoneEquipType::ExhaustFan: { // Fan : ZoneExhaust // SupplyNodeName = ""; // ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? May not use } break; case DataZoneEquipment::ZoneEquipType::HeatPumpWaterHeater: { // WaterHeater : HeatPump - ReturnNodeNum = WaterThermalTanks::GetHeatPumpWaterHeaterAirInletNodeNum(state, EquipIndex); - SupplyNodeNum = WaterThermalTanks::GetHeatPumpWaterHeaterAirOutletNodeNum(state, EquipIndex); + EquipIndex = WaterThermalTanks::getHeatPumpWaterHeaterIndex(state, EquipName, errorfound); + ReturnNodeNum = state.dataWaterThermalTanks->HPWaterHeater(EquipIndex).HeatPumpAirInletNode; + SupplyNodeNum = state.dataWaterThermalTanks->HPWaterHeater(EquipIndex).HeatPumpAirOutletNode; // For AirTerminals, find matching return node later } break; case DataZoneEquipment::ZoneEquipType::AirTerminalDualDuctConstantVolume: { // AirTerminal : DualDuct : ConstantVolume diff --git a/src/EnergyPlus/UnitHeater.cc b/src/EnergyPlus/UnitHeater.cc index 0cabd7e02c8..127fe2079bc 100644 --- a/src/EnergyPlus/UnitHeater.cc +++ b/src/EnergyPlus/UnitHeater.cc @@ -1927,6 +1927,23 @@ namespace UnitHeater { return GetUnitHeaterAirInletNode; } + int getUnitHeaterIndex(EnergyPlusData &state, std::string_view CompName, bool &errFlag) + { + if (state.dataUnitHeaters->GetUnitHeaterInputFlag) { + GetUnitHeaterInput(state); + state.dataUnitHeaters->GetUnitHeaterInputFlag = false; + } + int EquipIndex = 0; + for (int UnitHeatNum = 1; UnitHeatNum <= state.dataUnitHeaters->NumOfUnitHeats; ++UnitHeatNum) { + if (Util::SameString(state.dataUnitHeaters->UnitHeat(UnitHeatNum).Name, CompName)) { + EquipIndex = UnitHeatNum; + } + } + + if (EquipIndex == 0) errFlag = true; + return EquipIndex; + } + } // namespace UnitHeater } // namespace EnergyPlus diff --git a/src/EnergyPlus/UnitHeater.hh b/src/EnergyPlus/UnitHeater.hh index 502ec4a4a46..e84f7790d14 100644 --- a/src/EnergyPlus/UnitHeater.hh +++ b/src/EnergyPlus/UnitHeater.hh @@ -202,9 +202,11 @@ namespace UnitHeater { void ReportUnitHeater(EnergyPlusData &state, int const UnitHeatNum); // Unit index in unit heater array - int GetUnitHeaterAirOutletNode(EnergyPlusData &state, int OAUnitNum); + int GetUnitHeaterAirOutletNode(EnergyPlusData &state, int UnitHeatNum); - int GetUnitHeaterAirInletNode(EnergyPlusData &state, int OAUnitNum); + int GetUnitHeaterAirInletNode(EnergyPlusData &state, int UnitHeatNum); + + int getUnitHeaterIndex(EnergyPlusData &state, std::string_view CompName, bool &errFlag); } // namespace UnitHeater struct UnitHeatersData : BaseGlobalStruct diff --git a/src/EnergyPlus/UnitVentilator.cc b/src/EnergyPlus/UnitVentilator.cc index 729cf7a5a24..ea690c1ec45 100644 --- a/src/EnergyPlus/UnitVentilator.cc +++ b/src/EnergyPlus/UnitVentilator.cc @@ -3366,6 +3366,23 @@ namespace UnitVentilator { return GetUnitVentilatorReturnAirNode; } + int getUnitVentilatorIndex(EnergyPlusData &state, std::string_view CompName, bool &errFlag) + { + if (state.dataUnitVentilators->GetUnitVentilatorInputFlag) { + GetUnitVentilatorInput(state); + state.dataUnitVentilators->GetUnitVentilatorInputFlag = false; + } + int EquipIndex = 0; + for (int UnitVentNum = 1; UnitVentNum <= state.dataUnitVentilators->NumOfUnitVents; ++UnitVentNum) { + if (Util::SameString(state.dataUnitVentilators->UnitVent(UnitVentNum).Name, CompName)) { + EquipIndex = UnitVentNum; + } + } + + if (EquipIndex == 0) errFlag = true; + return EquipIndex; + } + Real64 SetOAMassFlowRateForCoolingVariablePercent(EnergyPlusData &state, int const UnitVentNum, // Unit Ventilator index Real64 const MinOAFrac, // Minimum Outside Air Fraction diff --git a/src/EnergyPlus/UnitVentilator.hh b/src/EnergyPlus/UnitVentilator.hh index ea732cae27d..9354a666e6a 100644 --- a/src/EnergyPlus/UnitVentilator.hh +++ b/src/EnergyPlus/UnitVentilator.hh @@ -262,6 +262,8 @@ namespace UnitVentilator { int GetUnitVentilatorReturnAirNode(EnergyPlusData &state, int const UnitVentNum); + int getUnitVentilatorIndex(EnergyPlusData &state, std::string_view CompName, bool &errFlag); + Real64 SetOAMassFlowRateForCoolingVariablePercent(EnergyPlusData &state, int const UnitVentNum, // Unit Ventilator index number Real64 const MinOAFrac, // Minimum Outside Air Fraction diff --git a/src/EnergyPlus/VentilatedSlab.cc b/src/EnergyPlus/VentilatedSlab.cc index 301ec2d1715..f132ee63d8e 100644 --- a/src/EnergyPlus/VentilatedSlab.cc +++ b/src/EnergyPlus/VentilatedSlab.cc @@ -4766,6 +4766,23 @@ namespace VentilatedSlab { return ZoneAirInNode; } + int getVentilatedSlabIndex(EnergyPlusData &state, std::string_view CompName, bool &errFlag) + { + if (state.dataVentilatedSlab->GetInputFlag) { + GetVentilatedSlabInput(state); + state.dataVentilatedSlab->GetInputFlag = false; + } + + int EquipIndex = 0; + for (int VentSlabNum = 1; VentSlabNum <= state.dataVentilatedSlab->NumOfVentSlabs; ++VentSlabNum) { + if (Util::SameString(state.dataVentilatedSlab->VentSlab(VentSlabNum).Name, CompName)) { + EquipIndex = VentSlabNum; + } + } + + if (EquipIndex == 0) errFlag = true; + return EquipIndex; + } //***************************************************************************************** } // namespace VentilatedSlab diff --git a/src/EnergyPlus/VentilatedSlab.hh b/src/EnergyPlus/VentilatedSlab.hh index 52794f957e9..f20180c8602 100644 --- a/src/EnergyPlus/VentilatedSlab.hh +++ b/src/EnergyPlus/VentilatedSlab.hh @@ -387,6 +387,7 @@ namespace VentilatedSlab { int GetVentilatedSlabZoneAirInNode(EnergyPlusData &state, int const VentSlabNum); + int getVentilatedSlabIndex(EnergyPlusData &state, std::string_view CompName, bool &errFlag); //***************************************************************************************** } // namespace VentilatedSlab diff --git a/src/EnergyPlus/WaterThermalTanks.cc b/src/EnergyPlus/WaterThermalTanks.cc index 11b6f052499..bdea7fce4c8 100644 --- a/src/EnergyPlus/WaterThermalTanks.cc +++ b/src/EnergyPlus/WaterThermalTanks.cc @@ -12495,4 +12495,22 @@ int GetHeatPumpWaterHeaterAirOutletNodeNum(EnergyPlusData &state, int HPNum) return HeatPumpWaterHeaterAirOutletNodeNum; } +int getHeatPumpWaterHeaterIndex(EnergyPlusData &state, std::string_view CompName, bool &errFlag) +{ + if (state.dataWaterThermalTanks->getWaterThermalTankInputFlag) { + GetWaterThermalTankInput(state); + state.dataWaterThermalTanks->getWaterThermalTankInputFlag = false; + } + + int EquipIndex = 0; + for (int HPNum = 1; HPNum <= state.dataWaterThermalTanks->numHeatPumpWaterHeater; ++HPNum) { + if (Util::SameString(state.dataWaterThermalTanks->HPWaterHeater(HPNum).Name, CompName)) { + EquipIndex = HPNum; + } + } + + if (EquipIndex == 0) errFlag = true; + return EquipIndex; +} + } // namespace EnergyPlus::WaterThermalTanks diff --git a/src/EnergyPlus/WaterThermalTanks.hh b/src/EnergyPlus/WaterThermalTanks.hh index 741d5edcd1c..7ff93332d85 100644 --- a/src/EnergyPlus/WaterThermalTanks.hh +++ b/src/EnergyPlus/WaterThermalTanks.hh @@ -992,6 +992,8 @@ namespace WaterThermalTanks { int GetHeatPumpWaterHeaterAirOutletNodeNum(EnergyPlusData &state, int HPNum); + int getHeatPumpWaterHeaterIndex(EnergyPlusData &state, std::string_view CompName, bool &errFlag); + } // namespace WaterThermalTanks struct WaterThermalTanksData : BaseGlobalStruct diff --git a/src/EnergyPlus/WindowAC.cc b/src/EnergyPlus/WindowAC.cc index 6dad593cbcc..9d405e13750 100644 --- a/src/EnergyPlus/WindowAC.cc +++ b/src/EnergyPlus/WindowAC.cc @@ -1619,6 +1619,24 @@ namespace WindowAC { return GetWindowACMixedAirNode; } + int getWindowACIndex(EnergyPlusData &state, std::string_view CompName, bool &errFlag) + { + if (state.dataWindowAC->GetWindowACInputFlag) { + GetWindowAC(state); + state.dataWindowAC->GetWindowACInputFlag = false; + } + + int EquipIndex = 0; + for (int WindACIndex = 1; WindACIndex <= state.dataWindowAC->NumWindAC; ++WindACIndex) { + if (Util::SameString(state.dataWindowAC->WindAC(WindACIndex).Name, CompName)) { + EquipIndex = WindACIndex; + } + } + + if (EquipIndex == 0) errFlag = true; + return EquipIndex; + } + } // namespace WindowAC } // namespace EnergyPlus diff --git a/src/EnergyPlus/WindowAC.hh b/src/EnergyPlus/WindowAC.hh index 53a111e820d..0d2e8014e73 100644 --- a/src/EnergyPlus/WindowAC.hh +++ b/src/EnergyPlus/WindowAC.hh @@ -205,6 +205,8 @@ namespace WindowAC { int GetWindowACMixedAirNode(EnergyPlusData &state, int const WindACNum); + int getWindowACIndex(EnergyPlusData &state, std::string_view CompName, bool &errFlag); + } // namespace WindowAC struct WindowACData : BaseGlobalStruct diff --git a/src/EnergyPlus/ZoneDehumidifier.cc b/src/EnergyPlus/ZoneDehumidifier.cc index 74b31945904..e21e5f4c887 100644 --- a/src/EnergyPlus/ZoneDehumidifier.cc +++ b/src/EnergyPlus/ZoneDehumidifier.cc @@ -1209,6 +1209,24 @@ namespace ZoneDehumidifier { return ZoneDehumidifierAirInletNodeNum; } + int getZoneDehumidifierIndex(EnergyPlusData &state, std::string_view CompName, bool &errFlag) + { + if (state.dataZoneDehumidifier->GetInputFlag) { + GetZoneDehumidifierInput(state); + state.dataZoneDehumidifier->GetInputFlag = false; + } + + int EquipIndex = 0; + for (int ZoneDehumidNum = 1; ZoneDehumidNum <= (int)state.dataZoneDehumidifier->ZoneDehumid.size(); ++ZoneDehumidNum) { + if (Util::SameString(state.dataZoneDehumidifier->ZoneDehumid(ZoneDehumidNum).Name, CompName)) { + EquipIndex = ZoneDehumidNum; + } + } + + if (EquipIndex == 0) errFlag = true; + return EquipIndex; + } + } // namespace ZoneDehumidifier } // namespace EnergyPlus diff --git a/src/EnergyPlus/ZoneDehumidifier.hh b/src/EnergyPlus/ZoneDehumidifier.hh index 6da985a515f..57adbfe4d57 100644 --- a/src/EnergyPlus/ZoneDehumidifier.hh +++ b/src/EnergyPlus/ZoneDehumidifier.hh @@ -157,6 +157,8 @@ namespace ZoneDehumidifier { int GetZoneDehumidifierAirInletNodeNum(EnergyPlusData &state, int ZoneDehumidNum); + int getZoneDehumidifierIndex(EnergyPlusData &state, std::string_view CompName, bool &errFlag); + } // namespace ZoneDehumidifier struct ZoneDehumidifierData : BaseGlobalStruct diff --git a/tst/EnergyPlus/unit/RoomAirflowNetwork.unit.cc b/tst/EnergyPlus/unit/RoomAirflowNetwork.unit.cc index cfb694c8af9..5555bfcb259 100644 --- a/tst/EnergyPlus/unit/RoomAirflowNetwork.unit.cc +++ b/tst/EnergyPlus/unit/RoomAirflowNetwork.unit.cc @@ -626,6 +626,7 @@ TEST_F(EnergyPlusFixture, RoomAirflowNetwork_CheckEquipName_Test) zoneEquipType = DataZoneEquipment::ZoneEquipType::VariableRefrigerantFlowTerminal; state->dataHVACVarRefFlow->NumVRFTU = 1; + state->dataHVACVarRefFlow->VRFTU(1).Name = EquipName; check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); if (check) { EXPECT_EQ("SupplyNode", SupplyNodeName); @@ -638,6 +639,7 @@ TEST_F(EnergyPlusFixture, RoomAirflowNetwork_CheckEquipName_Test) state->dataHVACStandAloneERV->StandAloneERV.allocate(1); state->dataHVACStandAloneERV->NumStandAloneERVs = 1; state->dataHVACStandAloneERV->StandAloneERV(1).SupplyAirInletNode = 1; + state->dataHVACStandAloneERV->StandAloneERV(1).Name = EquipName; check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); if (check) { EXPECT_EQ("SupplyNode1", SupplyNodeName); @@ -651,6 +653,7 @@ TEST_F(EnergyPlusFixture, RoomAirflowNetwork_CheckEquipName_Test) state->dataFanCoilUnits->FanCoil(EquipIndex).AirInNode = 2; state->dataFanCoilUnits->NumFanCoils = 1; state->dataFanCoilUnits->GetFanCoilInputFlag = false; + state->dataFanCoilUnits->FanCoil(EquipIndex).Name = EquipName; check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); if (check) { EXPECT_EQ("SupplyNode2", SupplyNodeName); @@ -665,6 +668,7 @@ TEST_F(EnergyPlusFixture, RoomAirflowNetwork_CheckEquipName_Test) state->dataOutdoorAirUnit->OutAirUnit(EquipIndex).AirInletNode = 2; state->dataOutdoorAirUnit->NumOfOAUnits = 1; state->dataOutdoorAirUnit->GetOutdoorAirUnitInputFlag = false; + state->dataOutdoorAirUnit->OutAirUnit(EquipIndex).Name = EquipName; check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); if (check) { EXPECT_EQ("SupplyNode3", SupplyNodeName); @@ -726,6 +730,7 @@ TEST_F(EnergyPlusFixture, RoomAirflowNetwork_CheckEquipName_Test) state->dataUnitHeaters->UnitHeat(EquipIndex).AirInNode = 2; state->dataUnitHeaters->NumOfUnitHeats = 1; state->dataUnitHeaters->GetUnitHeaterInputFlag = false; + state->dataUnitHeaters->UnitHeat(EquipIndex).Name = EquipName; check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); if (check) { EXPECT_EQ("SupplyNode7", SupplyNodeName); @@ -739,6 +744,7 @@ TEST_F(EnergyPlusFixture, RoomAirflowNetwork_CheckEquipName_Test) state->dataUnitVentilators->UnitVent(EquipIndex).AirOutNode = 1; state->dataUnitVentilators->UnitVent(EquipIndex).AirInNode = 2; state->dataUnitVentilators->NumOfUnitVents = 1; + state->dataUnitVentilators->UnitVent(EquipIndex).Name = EquipName; state->dataUnitVentilators->GetUnitVentilatorInputFlag = false; check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); if (check) { @@ -754,6 +760,7 @@ TEST_F(EnergyPlusFixture, RoomAirflowNetwork_CheckEquipName_Test) state->dataVentilatedSlab->VentSlab(EquipIndex).ReturnAirNode = 2; state->dataVentilatedSlab->NumOfVentSlabs = 1; state->dataVentilatedSlab->GetInputFlag = false; + state->dataVentilatedSlab->VentSlab(EquipIndex).Name = EquipName; check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); if (check) { EXPECT_EQ("SupplyNode9", SupplyNodeName); @@ -772,6 +779,7 @@ TEST_F(EnergyPlusFixture, RoomAirflowNetwork_CheckEquipName_Test) state->dataMixedAir->NumOAMixers = 1; state->dataMixedAir->OAMixer.allocate(1); state->dataMixedAir->OAMixer(1).RetNode = 2; + state->dataWindowAC->WindAC(EquipIndex).Name = EquipName; state->dataMixedAir->GetOAMixerInputFlag = false; check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); if (check) { @@ -785,6 +793,7 @@ TEST_F(EnergyPlusFixture, RoomAirflowNetwork_CheckEquipName_Test) state->dataZoneDehumidifier->ZoneDehumid.allocate(1); state->dataZoneDehumidifier->ZoneDehumid(EquipIndex).AirOutletNodeNum = 1; state->dataZoneDehumidifier->ZoneDehumid(EquipIndex).AirInletNodeNum = 2; + state->dataZoneDehumidifier->ZoneDehumid(EquipIndex).Name = EquipName; state->dataZoneDehumidifier->GetInputFlag = false; check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); if (check) { @@ -799,6 +808,7 @@ TEST_F(EnergyPlusFixture, RoomAirflowNetwork_CheckEquipName_Test) state->dataPurchasedAirMgr->PurchAir(EquipIndex).ZoneSupplyAirNodeNum = 1; state->dataPurchasedAirMgr->PurchAir(EquipIndex).ZoneExhaustAirNodeNum = 2; state->dataPurchasedAirMgr->NumPurchAir = 1; + state->dataPurchasedAirMgr->PurchAir(EquipIndex).Name = EquipName; state->dataPurchasedAirMgr->GetPurchAirInputFlag = false; check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); if (check) { @@ -813,6 +823,7 @@ TEST_F(EnergyPlusFixture, RoomAirflowNetwork_CheckEquipName_Test) state->dataHybridUnitaryAC->ZoneHybridUnitaryAirConditioner(EquipIndex).OutletNode = 1; state->dataHybridUnitaryAC->ZoneHybridUnitaryAirConditioner(EquipIndex).InletNode = 2; state->dataHybridUnitaryAC->NumZoneHybridEvap = 1; + state->dataHybridUnitaryAC->ZoneHybridUnitaryAirConditioner(EquipIndex).Name = EquipName; state->dataHybridUnitaryAC->GetInputZoneHybridEvap = false; check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); if (check) { @@ -827,6 +838,7 @@ TEST_F(EnergyPlusFixture, RoomAirflowNetwork_CheckEquipName_Test) state->dataWaterThermalTanks->HPWaterHeater(EquipIndex).HeatPumpAirOutletNode = 1; state->dataWaterThermalTanks->HPWaterHeater(EquipIndex).HeatPumpAirInletNode = 2; state->dataWaterThermalTanks->numHeatPumpWaterHeater = 1; + state->dataWaterThermalTanks->HPWaterHeater(EquipIndex).Name = EquipName; state->dataWaterThermalTanks->getWaterThermalTankInputFlag = false; check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); if (check) { From a66cef820684a1eeae96c31a77892a5ebf1a47fa Mon Sep 17 00:00:00 2001 From: Lixing Gu Date: Wed, 5 Jun 2024 15:25:23 -0400 Subject: [PATCH 16/57] Remove errFlag override --- src/EnergyPlus/HVACStandAloneERV.cc | 4 ++-- src/EnergyPlus/HVACVariableRefrigerantFlow.cc | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/EnergyPlus/HVACStandAloneERV.cc b/src/EnergyPlus/HVACStandAloneERV.cc index 9ae6958a2f8..574e771fa13 100644 --- a/src/EnergyPlus/HVACStandAloneERV.cc +++ b/src/EnergyPlus/HVACStandAloneERV.cc @@ -1694,14 +1694,14 @@ bool GetStandAloneERVNodeNumber(EnergyPlusData &state, int const NodeNumber) } int EqIndex = 0; - errFlag = true; + for (int StandAloneERVNum = 1; StandAloneERVNum <= state.dataHVACStandAloneERV->NumStandAloneERVs; StandAloneERVNum++) { if (Util::SameString(CompName, state.dataHVACStandAloneERV->StandAloneERV(StandAloneERVNum).Name)) { EqIndex = StandAloneERVNum; - errFlag = false; break; } } + if (EqIndex == 0) errFlag = true; return EqIndex; } diff --git a/src/EnergyPlus/HVACVariableRefrigerantFlow.cc b/src/EnergyPlus/HVACVariableRefrigerantFlow.cc index aa8926dc591..7344312ac09 100644 --- a/src/EnergyPlus/HVACVariableRefrigerantFlow.cc +++ b/src/EnergyPlus/HVACVariableRefrigerantFlow.cc @@ -10776,14 +10776,13 @@ int getEqIndex(EnergyPlusData &state, std::string_view VRFTUName, bool &errFlag) } int EqIndex = 0; - errFlag = true; for (int VRFTUNum = 1; VRFTUNum <= state.dataHVACVarRefFlow->NumVRFTU; VRFTUNum++) { if (Util::SameString(VRFTUName, state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name)) { EqIndex = VRFTUNum; - errFlag = false; break; } } + if (EqIndex == 0) errFlag = true; return EqIndex; } From 4a1dc464357dca1ffebd985403a41269e0bb483e Mon Sep 17 00:00:00 2001 From: Lixing Gu Date: Wed, 5 Jun 2024 16:45:46 -0400 Subject: [PATCH 17/57] Clang format --- src/EnergyPlus/HVACStandAloneERV.cc | 28 +++++++++++++-------------- src/EnergyPlus/PurchasedAirManager.cc | 22 ++++++++++----------- 2 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/EnergyPlus/HVACStandAloneERV.cc b/src/EnergyPlus/HVACStandAloneERV.cc index 574e771fa13..a991369c301 100644 --- a/src/EnergyPlus/HVACStandAloneERV.cc +++ b/src/EnergyPlus/HVACStandAloneERV.cc @@ -1686,23 +1686,23 @@ bool GetStandAloneERVNodeNumber(EnergyPlusData &state, int const NodeNumber) return false; } - int getEqIndex(EnergyPlusData &state, std::string_view CompName, bool &errFlag) +int getEqIndex(EnergyPlusData &state, std::string_view CompName, bool &errFlag) { - if (state.dataHVACStandAloneERV->GetERVInputFlag) { - GetStandAloneERV(state); - state.dataHVACStandAloneERV->GetERVInputFlag = false; - } + if (state.dataHVACStandAloneERV->GetERVInputFlag) { + GetStandAloneERV(state); + state.dataHVACStandAloneERV->GetERVInputFlag = false; + } - int EqIndex = 0; - - for (int StandAloneERVNum = 1; StandAloneERVNum <= state.dataHVACStandAloneERV->NumStandAloneERVs; StandAloneERVNum++) { - if (Util::SameString(CompName, state.dataHVACStandAloneERV->StandAloneERV(StandAloneERVNum).Name)) { - EqIndex = StandAloneERVNum; - break; - } + int EqIndex = 0; + + for (int StandAloneERVNum = 1; StandAloneERVNum <= state.dataHVACStandAloneERV->NumStandAloneERVs; StandAloneERVNum++) { + if (Util::SameString(CompName, state.dataHVACStandAloneERV->StandAloneERV(StandAloneERVNum).Name)) { + EqIndex = StandAloneERVNum; + break; } - if (EqIndex == 0) errFlag = true; - return EqIndex; + } + if (EqIndex == 0) errFlag = true; + return EqIndex; } } // namespace EnergyPlus::HVACStandAloneERV diff --git a/src/EnergyPlus/PurchasedAirManager.cc b/src/EnergyPlus/PurchasedAirManager.cc index b1552ec305e..5b1d719f2a2 100644 --- a/src/EnergyPlus/PurchasedAirManager.cc +++ b/src/EnergyPlus/PurchasedAirManager.cc @@ -3335,20 +3335,20 @@ int GetPurchasedAirZoneExhaustAirNode(EnergyPlusData &state, int PurchAirNum) int getPurchasedAirIndex(EnergyPlusData &state, std::string_view PurchAirName, bool &errFlag) { - if (state.dataPurchasedAirMgr->GetPurchAirInputFlag) { - GetPurchasedAir(state); - state.dataPurchasedAirMgr->GetPurchAirInputFlag = false; - } + if (state.dataPurchasedAirMgr->GetPurchAirInputFlag) { + GetPurchasedAir(state); + state.dataPurchasedAirMgr->GetPurchAirInputFlag = false; + } - int EquipIndex = 0; - for (int PurchAirNum = 1; PurchAirNum <= state.dataPurchasedAirMgr->NumPurchAir; ++PurchAirNum) { - if (Util::SameString(state.dataPurchasedAirMgr->PurchAir(PurchAirNum).Name, PurchAirName)) { - EquipIndex = PurchAirNum; - } + int EquipIndex = 0; + for (int PurchAirNum = 1; PurchAirNum <= state.dataPurchasedAirMgr->NumPurchAir; ++PurchAirNum) { + if (Util::SameString(state.dataPurchasedAirMgr->PurchAir(PurchAirNum).Name, PurchAirName)) { + EquipIndex = PurchAirNum; } + } - if (EquipIndex == 0) errFlag = true; - return EquipIndex; + if (EquipIndex == 0) errFlag = true; + return EquipIndex; } Real64 GetPurchasedAirMixedAirTemp(EnergyPlusData &state, int const PurchAirNum) From 40dc60176f5e81850298bcf1890c868a822c82f5 Mon Sep 17 00:00:00 2001 From: Lixing Gu Date: Thu, 6 Jun 2024 11:31:28 -0400 Subject: [PATCH 18/57] Cleanup --- src/EnergyPlus/RoomAirModelManager.cc | 10 ++----- src/EnergyPlus/RoomAirModelManager.hh | 1 - .../unit/RoomAirflowNetwork.unit.cc | 30 +++++++++---------- 3 files changed, 18 insertions(+), 23 deletions(-) diff --git a/src/EnergyPlus/RoomAirModelManager.cc b/src/EnergyPlus/RoomAirModelManager.cc index 04e7aa5468e..7b8c40f8ed6 100644 --- a/src/EnergyPlus/RoomAirModelManager.cc +++ b/src/EnergyPlus/RoomAirModelManager.cc @@ -1658,12 +1658,8 @@ namespace RoomAir { break; } } - IntEquipFound = CheckEquipName(state, - roomAFNNodeHVAC.Name, - roomAFNNodeHVAC.SupplyNodeName, - roomAFNNodeHVAC.ReturnNodeName, - EquipIndex, - roomAFNNodeHVAC.zoneEquipType); + IntEquipFound = CheckEquipName( + state, roomAFNNodeHVAC.Name, roomAFNNodeHVAC.SupplyNodeName, roomAFNNodeHVAC.ReturnNodeName, roomAFNNodeHVAC.zoneEquipType); if (!IntEquipFound) { ShowSevereError(state, @@ -2699,7 +2695,6 @@ namespace RoomAir { std::string const &EquipName, // Equipment Name std::string &SupplyNodeName, // Supply node name std::string &ReturnNodeName, // Return node name - int EquipIndex, // Equipment index DataZoneEquipment::ZoneEquipType zoneEquipType) { @@ -2722,6 +2717,7 @@ namespace RoomAir { int ReturnNodeNum = 0; SupplyNodeName = ""; + int EquipIndex; if (zoneEquipType == DataZoneEquipment::ZoneEquipType::Invalid) return EquipFind; diff --git a/src/EnergyPlus/RoomAirModelManager.hh b/src/EnergyPlus/RoomAirModelManager.hh index bf030e7fdd0..6f2082797fb 100644 --- a/src/EnergyPlus/RoomAirModelManager.hh +++ b/src/EnergyPlus/RoomAirModelManager.hh @@ -89,7 +89,6 @@ namespace RoomAir { std::string const &EquipName, // Equipment Name std::string &SupplyNodeName, // Supply node name std::string &ReturnNodeName, // Return node name - int EquipIndex, // Equipment index DataZoneEquipment::ZoneEquipType zoneEquipType); // equipment type number } // namespace RoomAir diff --git a/tst/EnergyPlus/unit/RoomAirflowNetwork.unit.cc b/tst/EnergyPlus/unit/RoomAirflowNetwork.unit.cc index 5555bfcb259..36709ad80c0 100644 --- a/tst/EnergyPlus/unit/RoomAirflowNetwork.unit.cc +++ b/tst/EnergyPlus/unit/RoomAirflowNetwork.unit.cc @@ -627,7 +627,7 @@ TEST_F(EnergyPlusFixture, RoomAirflowNetwork_CheckEquipName_Test) zoneEquipType = DataZoneEquipment::ZoneEquipType::VariableRefrigerantFlowTerminal; state->dataHVACVarRefFlow->NumVRFTU = 1; state->dataHVACVarRefFlow->VRFTU(1).Name = EquipName; - check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); + check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, zoneEquipType); if (check) { EXPECT_EQ("SupplyNode", SupplyNodeName); } @@ -640,7 +640,7 @@ TEST_F(EnergyPlusFixture, RoomAirflowNetwork_CheckEquipName_Test) state->dataHVACStandAloneERV->NumStandAloneERVs = 1; state->dataHVACStandAloneERV->StandAloneERV(1).SupplyAirInletNode = 1; state->dataHVACStandAloneERV->StandAloneERV(1).Name = EquipName; - check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); + check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, zoneEquipType); if (check) { EXPECT_EQ("SupplyNode1", SupplyNodeName); } @@ -654,7 +654,7 @@ TEST_F(EnergyPlusFixture, RoomAirflowNetwork_CheckEquipName_Test) state->dataFanCoilUnits->NumFanCoils = 1; state->dataFanCoilUnits->GetFanCoilInputFlag = false; state->dataFanCoilUnits->FanCoil(EquipIndex).Name = EquipName; - check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); + check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, zoneEquipType); if (check) { EXPECT_EQ("SupplyNode2", SupplyNodeName); EXPECT_EQ("ReturnNode2", ReturnNodeName); @@ -669,7 +669,7 @@ TEST_F(EnergyPlusFixture, RoomAirflowNetwork_CheckEquipName_Test) state->dataOutdoorAirUnit->NumOfOAUnits = 1; state->dataOutdoorAirUnit->GetOutdoorAirUnitInputFlag = false; state->dataOutdoorAirUnit->OutAirUnit(EquipIndex).Name = EquipName; - check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); + check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, zoneEquipType); if (check) { EXPECT_EQ("SupplyNode3", SupplyNodeName); EXPECT_EQ("ReturnNode3", ReturnNodeName); @@ -685,7 +685,7 @@ TEST_F(EnergyPlusFixture, RoomAirflowNetwork_CheckEquipName_Test) state->dataUnitarySystems->numUnitarySystems = 1; state->dataUnitarySystems->unitarySys[EquipIndex - 1].AirOutNode = 1; state->dataUnitarySystems->unitarySys[EquipIndex - 1].AirInNode = 2; - check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); + check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, zoneEquipType); if (check) { EXPECT_EQ("SupplyNode4", SupplyNodeName); EXPECT_EQ("ReturnNode4", ReturnNodeName); @@ -701,7 +701,7 @@ TEST_F(EnergyPlusFixture, RoomAirflowNetwork_CheckEquipName_Test) state->dataUnitarySystems->numUnitarySystems = 1; state->dataUnitarySystems->unitarySys[EquipIndex - 1].AirOutNode = 1; state->dataUnitarySystems->unitarySys[EquipIndex - 1].AirInNode = 2; - check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); + check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, zoneEquipType); if (check) { EXPECT_EQ("SupplyNode5", SupplyNodeName); EXPECT_EQ("ReturnNode5", ReturnNodeName); @@ -716,7 +716,7 @@ TEST_F(EnergyPlusFixture, RoomAirflowNetwork_CheckEquipName_Test) state->dataUnitarySystems->numUnitarySystems = 1; state->dataUnitarySystems->unitarySys[EquipIndex - 1].AirOutNode = 1; state->dataUnitarySystems->unitarySys[EquipIndex - 1].AirInNode = 2; - check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); + check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, zoneEquipType); if (check) { EXPECT_EQ("SupplyNode6", SupplyNodeName); EXPECT_EQ("ReturnNode6", ReturnNodeName); @@ -731,7 +731,7 @@ TEST_F(EnergyPlusFixture, RoomAirflowNetwork_CheckEquipName_Test) state->dataUnitHeaters->NumOfUnitHeats = 1; state->dataUnitHeaters->GetUnitHeaterInputFlag = false; state->dataUnitHeaters->UnitHeat(EquipIndex).Name = EquipName; - check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); + check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, zoneEquipType); if (check) { EXPECT_EQ("SupplyNode7", SupplyNodeName); EXPECT_EQ("ReturnNode7", ReturnNodeName); @@ -746,7 +746,7 @@ TEST_F(EnergyPlusFixture, RoomAirflowNetwork_CheckEquipName_Test) state->dataUnitVentilators->NumOfUnitVents = 1; state->dataUnitVentilators->UnitVent(EquipIndex).Name = EquipName; state->dataUnitVentilators->GetUnitVentilatorInputFlag = false; - check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); + check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, zoneEquipType); if (check) { EXPECT_EQ("SupplyNode8", SupplyNodeName); EXPECT_EQ("ReturnNode8", ReturnNodeName); @@ -761,7 +761,7 @@ TEST_F(EnergyPlusFixture, RoomAirflowNetwork_CheckEquipName_Test) state->dataVentilatedSlab->NumOfVentSlabs = 1; state->dataVentilatedSlab->GetInputFlag = false; state->dataVentilatedSlab->VentSlab(EquipIndex).Name = EquipName; - check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); + check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, zoneEquipType); if (check) { EXPECT_EQ("SupplyNode9", SupplyNodeName); EXPECT_EQ("ReturnNode9", ReturnNodeName); @@ -781,7 +781,7 @@ TEST_F(EnergyPlusFixture, RoomAirflowNetwork_CheckEquipName_Test) state->dataMixedAir->OAMixer(1).RetNode = 2; state->dataWindowAC->WindAC(EquipIndex).Name = EquipName; state->dataMixedAir->GetOAMixerInputFlag = false; - check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); + check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, zoneEquipType); if (check) { EXPECT_EQ("SupplyNode10", SupplyNodeName); EXPECT_EQ("ReturnNode10", ReturnNodeName); @@ -795,7 +795,7 @@ TEST_F(EnergyPlusFixture, RoomAirflowNetwork_CheckEquipName_Test) state->dataZoneDehumidifier->ZoneDehumid(EquipIndex).AirInletNodeNum = 2; state->dataZoneDehumidifier->ZoneDehumid(EquipIndex).Name = EquipName; state->dataZoneDehumidifier->GetInputFlag = false; - check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); + check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, zoneEquipType); if (check) { EXPECT_EQ("SupplyNode11", SupplyNodeName); EXPECT_EQ("ReturnNode11", ReturnNodeName); @@ -810,7 +810,7 @@ TEST_F(EnergyPlusFixture, RoomAirflowNetwork_CheckEquipName_Test) state->dataPurchasedAirMgr->NumPurchAir = 1; state->dataPurchasedAirMgr->PurchAir(EquipIndex).Name = EquipName; state->dataPurchasedAirMgr->GetPurchAirInputFlag = false; - check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); + check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, zoneEquipType); if (check) { EXPECT_EQ("SupplyNode12", SupplyNodeName); EXPECT_EQ("ReturnNode12", ReturnNodeName); @@ -825,7 +825,7 @@ TEST_F(EnergyPlusFixture, RoomAirflowNetwork_CheckEquipName_Test) state->dataHybridUnitaryAC->NumZoneHybridEvap = 1; state->dataHybridUnitaryAC->ZoneHybridUnitaryAirConditioner(EquipIndex).Name = EquipName; state->dataHybridUnitaryAC->GetInputZoneHybridEvap = false; - check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); + check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, zoneEquipType); if (check) { EXPECT_EQ("SupplyNode13", SupplyNodeName); EXPECT_EQ("ReturnNode13", ReturnNodeName); @@ -840,7 +840,7 @@ TEST_F(EnergyPlusFixture, RoomAirflowNetwork_CheckEquipName_Test) state->dataWaterThermalTanks->numHeatPumpWaterHeater = 1; state->dataWaterThermalTanks->HPWaterHeater(EquipIndex).Name = EquipName; state->dataWaterThermalTanks->getWaterThermalTankInputFlag = false; - check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, EquipIndex, zoneEquipType); + check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, zoneEquipType); if (check) { EXPECT_EQ("SupplyNode14", SupplyNodeName); EXPECT_EQ("ReturnNode14", ReturnNodeName); From 29905bdb3593fa6bdd94a19ae1aed6f982f28411 Mon Sep 17 00:00:00 2001 From: Lixing Gu Date: Mon, 10 Jun 2024 13:19:29 -0400 Subject: [PATCH 19/57] Update WaterHeater:HeatPump type --- idd/Energy+.idd.in | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/idd/Energy+.idd.in b/idd/Energy+.idd.in index 466fc0a596b..f37bddeb533 100644 --- a/idd/Energy+.idd.in +++ b/idd/Energy+.idd.in @@ -21172,7 +21172,8 @@ RoomAir:Node:AirflowNetwork:HVACEquipment, \key ZoneHVAC:IdealLoadsAirSystem \key ZoneHVAC:RefrigerationChillerSet \key Fan:ZoneExhaust - \key WaterHeater:HeatPump + \key WaterHeater:HeatPump:PumpedCondenser + \key WaterHeater:HeatPump:WrappedCondenser \key AirTerminal:DualDuct:ConstantVolume \key AirTerminal:DualDuct:VAV \key AirTerminal:SingleDuct:ConstantVolume:Reheat @@ -21222,7 +21223,8 @@ RoomAir:Node:AirflowNetwork:HVACEquipment, \key ZoneHVAC:IdealLoadsAirSystem \key ZoneHVAC:RefrigerationChillerSet \key Fan:ZoneExhaust - \key WaterHeater:HeatPump + \key WaterHeater:HeatPump:PumpedCondenser + \key WaterHeater:HeatPump:WrappedCondenser \key AirTerminal:DualDuct:ConstantVolume \key AirTerminal:DualDuct:VAV \key AirTerminal:SingleDuct:ConstantVolume:Reheat From 0b2affaee84d756ad3531241ed28ebfac25c398c Mon Sep 17 00:00:00 2001 From: Julien Marrec Date: Thu, 20 Jun 2024 01:08:22 +0200 Subject: [PATCH 20/57] Add a test for #10574 --- tst/EnergyPlus/unit/WaterThermalTanks.unit.cc | 262 ++++++++++++++++++ 1 file changed, 262 insertions(+) diff --git a/tst/EnergyPlus/unit/WaterThermalTanks.unit.cc b/tst/EnergyPlus/unit/WaterThermalTanks.unit.cc index ff99c1ca594..9b135c20092 100644 --- a/tst/EnergyPlus/unit/WaterThermalTanks.unit.cc +++ b/tst/EnergyPlus/unit/WaterThermalTanks.unit.cc @@ -56,16 +56,22 @@ #include #include #include +#include #include #include #include #include +#include #include #include #include +#include +#include #include #include #include +#include +#include #include #include #include @@ -5427,3 +5433,259 @@ TEST_F(EnergyPlusFixture, setBackupElementCapacityTest) expectedAnswer = -456.0; EXPECT_NEAR(DSup.BackupElementCapacity, expectedAnswer, allowedTolerance); } + +TEST_F(EnergyPlusFixture, MixedTank_PVT_Per_VolumeSizing_PerSolarCollectorArea) +{ + + std::string const idf_objects = delimited_string({ + + "Schedule:Constant, Sch 80C, , 80.0;", + "Schedule:Constant, Sch 55C, , 55.0;", + "Schedule:Constant, Always 1, , 1.0;", + + "Zone,", + " Zone1, !- Name", + " 0 , !- Direction of Relative North {deg}", + " 0, !- X Origin {m}", + " 0, !- Y Origin {m}", + " 0, !- Z Origin {m}", + " 1, !- Type", + " 1, !- Multiplier", + " , !- Ceiling Height {m}", + " 300, !- Volume {m3}", + " 100, !- Floor Area {m2}", + " TARP, !- Zone Inside Convection Algorithm", + " , !- Zone Outside Convection Algorithm", + " Yes; !- Part of Total Floor Area", + + "BuildingSurface:Detailed," + " Zone1, !- Name", + " Floor, !- Surface Type", + " DummyConstruction, !- Construction Name", + " Zone1, !- Zone Name", + " , !- Space Name", + " Outdoors, !- Outside Boundary Condition", + " , !- Outside Boundary Condition Object", + " NoSun, !- Sun Exposure", + " NoWind, !- Wind Exposure", + " 0, !- View Factor to Ground", + " 4, !- Number of Vertices", + " 10.0, 0.0, 0.0, !- X,Y,Z 1 {m}", + " 0.0, 0.0, 0.0, !- X,Y,Z 2 {m}", + " 0.0, 10.0, 0.0, !- X,Y,Z 3 {m}", + " 10.0, 10.0, 0.0; !- X,Y,Z 4 {m}", + + "Construction," + " DummyConstruction, !- Name", + " DummyMaterial; !- Outside Layer", + + "Material," + " DummyMaterial, !- Name", + " MediumRough, !- Roughness", + " 0.4, !- Thickness {m}", + " 0.033, !- Conductivity {W/m-K}", + " 32, !- Density {kg/m3}", + " 1210, !- Specific Heat {J/kg-K}", + " 0.9, !- Thermal Absorptance", + " 0.7, !- Solar Absorptance", + " 0.7; !- Visible Absorptance", + + "WaterHeater:Mixed," + " Solar Loop Water Heater, !- Name", + " Autosize, !- Tank Volume {m3}", + " Sch 80C, !- Setpoint Temperature Schedule Name", + " 5.00, !- Deadband Temperature Difference {deltaC}", + " 100.00, !- Maximum Temperature Limit {C}", + " Cycle, !- Heater Control Type", + " 0.0, !- Heater Maximum Capacity {W}", + " 0.0, !- Heater Minimum Capacity {W}", + " , !- Heater Ignition Minimum Flow Rate {m3/s}", + " , !- Heater Ignition Delay {s}", + " Electricity, !- Heater Fuel Type", + " 0.8, !- Heater Thermal Efficiency", + " , !- Part Load Factor Curve Name", + " , !- Off Cycle Parasitic Fuel Consumption Rate {W}", + " , !- Off Cycle Parasitic Fuel Type", + " , !- Off Cycle Parasitic Heat Fraction to Tank", + " , !- On Cycle Parasitic Fuel Consumption Rate {W}", + " , !- On Cycle Parasitic Fuel Type", + " , !- On Cycle Parasitic Heat Fraction to Tank", + " Zone, !- Ambient Temperature Indicator", + " , !- Ambient Temperature Schedule Name", + " Zone1, !- Ambient Temperature Zone Name", + " , !- Ambient Temperature Outdoor Air Node Name", + " 0.0000, !- Off Cycle Loss Coefficient to Ambient Temperature {W/K}", + " 1.00, !- Off Cycle Loss Fraction to Zone", + " 0.0000, !- On Cycle Loss Coefficient to Ambient Temperature {W/K}", + " 1.00, !- On Cycle Loss Fraction to Zone", + " 0.01, !- Peak Use Flow Rate {m3/s}", + " Always 1, !- Use Flow Rate Fraction Schedule Name", + " , !- Cold Water Supply Temperature Schedule Name", + " , !- Use Side Inlet Node Name", + " , !- Use Side Outlet Node Name", + " 1.00, !- Use Side Effectiveness", + " Solar Loop Water Heater Heating Inlet Node, !- Source Side Inlet Node Name", + " Solar Loop Water Heater Heating Outlet Node, !- Source Side Outlet Node Name", + " 1.00, !- Source Side Effectiveness", + " 1.0, !- Use Side Design Flow Rate {m3/s}", + " 1.0, !- Source Side Design Flow Rate {m3/s}", + " 1.500000, !- Indirect Water Heating Recovery Time {hr}", + " IndirectHeatPrimarySetpoint, !- Source Side Flow Control Mode", + " Sch 55C; !- Indirect Alternate Setpoint Temperature Schedule Name", + + "WaterHeater:Sizing," + " Solar Loop Water Heater, !- WaterHeater Name", + " PerSolarCollectorArea, !- Design Mode", + " 0.600000, !- Time Storage Can Meet Peak Draw {hr}", + " 0.600000, !- Time for Tank Recovery {hr}", + " 1.000000, !- Nominal Tank Volume for Autosizing Plant Connections {m3}", + " 4, !- Number of Bedrooms", + " 2, !- Number of Bathrooms", + " 0.200000, !- Storage Capacity per Person {m3/person}", + " 0.200000, !- Recovery Capacity per Person {m3/hr-person}", + " 0.020000, !- Storage Capacity per Floor Area {m3/m2}", + " 0.020000, !- Recovery Capacity per Floor Area {m3/hr-m2}", + " 4, !- Number of Units", + " 0.200000, !- Storage Capacity per Unit {m3}", + " 0.200000, !- Recovery Capacity PerUnit {m3/hr}", + " 0.200, !- Storage Capacity per Collector Area {m3/m2}", + " 1.000; !- Height Aspect Ratio", + + "SolarCollector:FlatPlate:PhotovoltaicThermal," + " Collector 2 PVT, !- Name", + " Solar collector 3, !- Surface Name", + " 30percentPVThalfarea, !- Photovoltaic-Thermal Model Performance Name", + " Collector 2 PV, !- Photovoltaic Name", + " Water, !- Thermal Working Fluid Type", + " Solar Collector Water Inlet Node, !- Water Inlet Node Name", + " Solar Collector Water Outlet Node, !- Water Outlet Node Name", + " , !- Air Inlet Node Name", + " , !- Air Outlet Node Name", + " autosize; !- Design Flow Rate {m3/s}", + + "SolarCollectorPerformance:PhotovoltaicThermal:Simple," + " 30percentPVThalfarea, !- Name", + " 0.5, !- Fraction of Surface Area with Active Thermal Collector {dimensionless}", + " Fixed, !- Thermal Conversion Efficiency Input Mode Type", + " 0.3, !- Value for Thermal Conversion Efficiency if Fixed", + " , !- Thermal Conversion Efficiency Schedule Name", + " 0.84; !- Front Surface Emittance", + + "Generator:Photovoltaic," + " Collector 2 PV, !- Name", + " Solar collector 3, !- Surface Name", + " PhotovoltaicPerformance:Simple, !- Photovoltaic Performance Object Type", + " 15percentPV Constant Efficiency, !- Module Performance Name", + " PhotovoltaicThermalSolarCollector, !- Heat Transfer Integration Mode", + " 1, !- Number of Series Strings in Parallel {dimensionless}", + " 1; !- Number of Modules in Series {dimensionless}", + + "PhotovoltaicPerformance:Simple," + " 15percentPV Constant Efficiency, !- Name", + " 0.90, !- Fraction of Surface Area with Active Solar Cells {dimensionless}", + " Fixed, !- Conversion Efficiency Input Mode", + " 0.15; !- Value for Cell Efficiency if Fixed", + + "Shading:Building:Detailed,", + " Solar collector 3, !- Name", + " , !- Transmittance Schedule Name", + " 4, !- Number of Vertices", + " 0, 10, 6, !- X,Y,Z Vertex 1 {m}", + " 0, 0, 6, !- X,Y,Z Vertex 2 {m}", + " 1, 0, 6, !- X,Y,Z Vertex 3 {m}", + " 1, 10, 6; !- X,Y,Z Vertex 4 {m} ", + }); + + ASSERT_TRUE(process_idf(idf_objects)); + + bool ErrorsFound = false; + HeatBalanceManager::GetHeatBalanceInput(*state); // Gets materials, constructions, zones, surfaces, etc. + HeatBalanceSurfaceManager::AllocateSurfaceHeatBalArrays(*state); + HeatBalanceManager::AllocateHeatBalArrays(*state); + + SurfaceGeometry::GetSurfaceData(*state, ErrorsFound); + EXPECT_FALSE(ErrorsFound); + SolarShading::AllocateModuleArrays(*state); + + Photovoltaics::GetPVInput(*state); + PhotovoltaicThermalCollectors::GetPVTcollectorsInput(*state); + + EXPECT_EQ(1, state->dataPhotovoltaicThermalCollector->NumPVT); + auto &pvt = state->dataPhotovoltaicThermalCollector->PVT(1); + // 10 m^2 for the surface, 0.5 Fraction of Surface Area with Active Thermal Collector + EXPECT_EQ(10.0 * 0.5, pvt.AreaCol); + InternalHeatGains::GetInternalHeatGainsInput(*state); + has_err_output(true); + EXPECT_FALSE(WaterThermalTanks::GetWaterThermalTankInput(*state)); // This returns true if ErrorsFound + EXPECT_TRUE(compare_err_stream("")); + + EXPECT_EQ(4, state->dataLoopNodes->NumOfNodes); + + EXPECT_EQ(1, state->dataWaterThermalTanks->numWaterHeaterMixed); + EXPECT_EQ(1, state->dataWaterThermalTanks->numWaterHeaterSizing); + EXPECT_EQ(0, state->dataWaterThermalTanks->numWaterHeaterStratified); + EXPECT_EQ(0, state->dataWaterThermalTanks->numWaterHeaterDesuperheater); + auto &Tank = state->dataWaterThermalTanks->WaterThermalTank(1); + EXPECT_TRUE(Tank.VolumeWasAutoSized); + + // set up the plant loops + // first the load side + state->dataPlnt->TotNumLoops = 1; + state->dataPlnt->PlantLoop.allocate(1); + + auto &plantLoop = state->dataPlnt->PlantLoop(1); + auto &supplySide = plantLoop.LoopSide(DataPlant::LoopSideLocation::Supply); + supplySide.TotalBranches = 1; + supplySide.Branch.allocate(1); + supplySide.Branch(1).TotalComponents = 1; + supplySide.Branch(1).Comp.allocate(1); + auto &PlantSupplySideComp = supplySide.Branch(1).Comp(1); + PlantSupplySideComp.Type = DataPlant::PlantEquipmentType::WtrHeaterMixed; + PlantSupplySideComp.Name = Tank.Name; + PlantSupplySideComp.NodeNumIn = Tank.SourceInletNode; + PlantSupplySideComp.NodeNumOut = Tank.SourceOutletNode; + + auto &demandSide = plantLoop.LoopSide(DataPlant::LoopSideLocation::Demand); + demandSide.TotalBranches = 1; + demandSide.Branch.allocate(1); + demandSide.Branch(1).TotalComponents = 1; + demandSide.Branch(1).Comp.allocate(1); + auto &PlantDemandSideComp = demandSide.Branch(1).Comp(1); + PlantDemandSideComp.Type = DataPlant::PlantEquipmentType::PVTSolarCollectorFlatPlate; + PlantDemandSideComp.Name = pvt.Name; + PlantDemandSideComp.NodeNumIn = pvt.PlantInletNodeNum; + PlantDemandSideComp.NodeNumOut = pvt.PlantOutletNodeNum; + + state->dataGlobal->BeginEnvrnFlag = false; + + EXPECT_ENUM_EQ(DataPlant::LoopSideLocation::Invalid, pvt.WPlantLoc.loopSideNum); + EXPECT_EQ(0, pvt.WPlantLoc.loopNum); + // This is actually unused by PVTCollectorStruct::onInitLoopEquip but in case that changes, make it make sense + PlantLocation plantLocDemand = PlantLocation(1, DataPlant::LoopSideLocation::Demand, 1, 1); + pvt.onInitLoopEquip(*state, plantLocDemand); + EXPECT_ENUM_EQ(DataPlant::LoopSideLocation::Demand, pvt.WPlantLoc.loopSideNum); + EXPECT_EQ(1, pvt.WPlantLoc.loopNum); + + EXPECT_ENUM_EQ(DataPlant::LoopSideLocation::Invalid, Tank.SrcSidePlantLoc.loopSideNum); + EXPECT_EQ(0, Tank.SrcSidePlantLoc.loopNum); + PlantLocation plantLocSupply = PlantLocation(1, DataPlant::LoopSideLocation::Supply, 1, 1); + EXPECT_DOUBLE_EQ(0.00, Tank.Sizing.TotalSolarCollectorArea); + EXPECT_DOUBLE_EQ(DataSizing::AutoSize, Tank.Volume); + + has_eio_output(true); + + state->dataPlnt->PlantFirstSizesOkayToFinalize = true; + state->dataPlnt->PlantFinalSizesOkayToReport = true; + Tank.onInitLoopEquip(*state, plantLocSupply); + EXPECT_ENUM_EQ(DataPlant::LoopSideLocation::Supply, Tank.SrcSidePlantLoc.loopSideNum); + EXPECT_EQ(1, Tank.SrcSidePlantLoc.loopNum); + + // compare_eio_stream(delimited_string({ + // "Water Heater Information,WaterHeater:Mixed,SOLAR LOOP WATER HEATER,-99998.9999,0.0,0.000,0.0000", + // "! , Component Type, Component Name, Input Field Description, Value", + // " Component Sizing Information, WaterHeater:Mixed, SOLAR LOOP WATER HEATER, Tank Volume [m3], 1.00000", + // })); + EXPECT_DOUBLE_EQ(5.00, Tank.Sizing.TotalSolarCollectorArea); + EXPECT_DOUBLE_EQ(0.2, Tank.Sizing.TankCapacityPerCollectorArea); + EXPECT_DOUBLE_EQ(1.0, Tank.Volume); +} From ed631fc941d1ae63488d6a3b5489e5b8f5c99cfd Mon Sep 17 00:00:00 2001 From: Julien Marrec Date: Thu, 20 Jun 2024 01:26:26 +0200 Subject: [PATCH 21/57] Specifically test for the NaN ``` [ RUN ] EnergyPlusFixture.WH_Sizing /Users/julien/Software/Others/EnergyPlus2/tst/EnergyPlus/unit/WaterThermalTanks.unit.cc:5690: Failure Expected equality of these values: 5.00 Which is: 5 Tank.Sizing.TotalSolarCollectorArea Which is: 0 /Users/julien/Software/Others/EnergyPlus2/tst/EnergyPlus/unit/WaterThermalTanks.unit.cc:5692: Failure Expected equality of these values: 1.0 Which is: 1 Tank.Volume Which is: 0 /Users/julien/Software/Others/EnergyPlus2/tst/EnergyPlus/unit/WaterThermalTanks.unit.cc:5711: Failure Value of: std::isnan(Tank.AmbientZoneGain) Actual: true Expected: false /Users/julien/Software/Others/EnergyPlus2/tst/EnergyPlus/unit/WaterThermalTanks.unit.cc:5712: Failure Expected equality of these values: 0.0 Which is: 0 Tank.AmbientZoneGain Which is: nan ``` --- tst/EnergyPlus/unit/WaterThermalTanks.unit.cc | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tst/EnergyPlus/unit/WaterThermalTanks.unit.cc b/tst/EnergyPlus/unit/WaterThermalTanks.unit.cc index 9b135c20092..c22cfba24ce 100644 --- a/tst/EnergyPlus/unit/WaterThermalTanks.unit.cc +++ b/tst/EnergyPlus/unit/WaterThermalTanks.unit.cc @@ -78,6 +78,8 @@ #include #include +#include + using namespace EnergyPlus; using namespace OutputReportPredefined; @@ -5688,4 +5690,24 @@ TEST_F(EnergyPlusFixture, MixedTank_PVT_Per_VolumeSizing_PerSolarCollectorArea) EXPECT_DOUBLE_EQ(5.00, Tank.Sizing.TotalSolarCollectorArea); EXPECT_DOUBLE_EQ(0.2, Tank.Sizing.TankCapacityPerCollectorArea); EXPECT_DOUBLE_EQ(1.0, Tank.Volume); + + state->dataGlobal->HourOfDay = 0; + state->dataGlobal->TimeStep = 1; + state->dataGlobal->TimeStepZone = 1.0 / 60.0; // one-minute system time step + state->dataHVACGlobal->TimeStepSys = state->dataGlobal->TimeStepZone; + state->dataHVACGlobal->TimeStepSysSec = state->dataHVACGlobal->TimeStepSys * Constant::SecInHour; + Tank.SavedTankTemp = 60.0; + Tank.TankTemp = 60.0; + Tank.AmbientTempZone = 20.0; + Tank.AmbientTemp = 20.0; + Tank.UseInletTemp = 20.0; + Tank.SetPointTemp = 55.0; + Tank.SetPointTemp2 = Tank.SetPointTemp; + Tank.TimeElapsed = 0.0; + + Tank.SourceMassFlowRate = 0.0; + + Tank.CalcWaterThermalTankMixed(*state); + EXPECT_FALSE(std::isnan(Tank.AmbientZoneGain)); + EXPECT_DOUBLE_EQ(0.0, Tank.AmbientZoneGain); // Didn't define on/off cycle losses } From df5042fb91e1dd2592e365832fff2a0b38e8496d Mon Sep 17 00:00:00 2001 From: Julien Marrec Date: Thu, 20 Jun 2024 01:35:15 +0200 Subject: [PATCH 22/57] Fix #10574 - Deal with BIPVT for WaterHeater sizing and throw error if Total Collector area found is zero --- src/EnergyPlus/WaterThermalTanks.cc | 95 +++++++++++++++++++++++------ 1 file changed, 78 insertions(+), 17 deletions(-) diff --git a/src/EnergyPlus/WaterThermalTanks.cc b/src/EnergyPlus/WaterThermalTanks.cc index 730b4f5ddad..4f747999d2a 100644 --- a/src/EnergyPlus/WaterThermalTanks.cc +++ b/src/EnergyPlus/WaterThermalTanks.cc @@ -77,6 +77,7 @@ #include #include #include +#include #include #include #include @@ -11201,9 +11202,6 @@ void WaterThermalTankData::SizeTankForSupplySide(EnergyPlusData &state) static constexpr std::string_view RoutineName("SizeTankForSupplySide"); - Real64 Tstart = 14.44; - Real64 Tfinish = 57.22; - Real64 tmpTankVolume = this->Volume; Real64 tmpMaxCapacity = this->MaxCapacity; @@ -11221,8 +11219,11 @@ void WaterThermalTankData::SizeTankForSupplySide(EnergyPlusData &state) } if (this->MaxCapacityWasAutoSized) { if (this->Sizing.RecoveryTime > 0.0) { - Real64 rho; - Real64 Cp; + Real64 rho = 0.0; + Real64 Cp = 0.0; + constexpr Real64 Tstart = 14.44; + constexpr Real64 Tfinish = 57.22; + if (this->SrcSidePlantLoc.loopNum > 0) { rho = FluidProperties::GetDensityGlycol(state, state.dataPlnt->PlantLoop(this->SrcSidePlantLoc.loopNum).FluidName, @@ -11242,8 +11243,7 @@ void WaterThermalTankData::SizeTankForSupplySide(EnergyPlusData &state) (this->Sizing.RecoveryTime * Constant::SecInHour); // m3 | kg/m3 | J/Kg/K | K | seconds } else { ShowFatalError( - state, - format("SizeTankForSupplySide: Tank=\"{}\", requested sizing for max capacity but entered Recovery Time is zero.", this->Name)); + state, format("{}: Tank=\"{}\", requested sizing for max capacity but entered Recovery Time is zero.", RoutineName, this->Name)); } } @@ -11259,12 +11259,40 @@ void WaterThermalTankData::SizeTankForSupplySide(EnergyPlusData &state) } else if (this->Sizing.DesignMode == SizingMode::PerSolarColArea) { this->Sizing.TotalSolarCollectorArea = 0.0; + if (state.dataSolarCollectors->GetInputFlag) { + SolarCollectors::GetSolarCollectorInput(state); + state.dataSolarCollectors->GetInputFlag = false; + } + for (int CollectorNum = 1; CollectorNum <= state.dataSolarCollectors->NumOfCollectors; ++CollectorNum) { - this->Sizing.TotalSolarCollectorArea += state.dataSurface->Surface(state.dataSolarCollectors->Collector(CollectorNum).Surface).Area; + auto const &collector = state.dataSolarCollectors->Collector(CollectorNum); + this->Sizing.TotalSolarCollectorArea += state.dataSurface->Surface(collector.Surface).Area; + } + + if (state.dataPhotovoltaicThermalCollector->GetInputFlag) { + PhotovoltaicThermalCollectors::GetPVTcollectorsInput(state); + state.dataPhotovoltaicThermalCollector->GetInputFlag = false; } - if (this->VolumeWasAutoSized) tmpTankVolume = this->Sizing.TotalSolarCollectorArea * this->Sizing.TankCapacityPerCollectorArea; - if (this->MaxCapacityWasAutoSized) tmpMaxCapacity = 0.0; + for (int CollectorNum = 1; CollectorNum <= state.dataPhotovoltaicThermalCollector->NumPVT; ++CollectorNum) { + auto const &collector = state.dataPhotovoltaicThermalCollector->PVT(CollectorNum); + this->Sizing.TotalSolarCollectorArea += collector.AreaCol; + } + + if (this->VolumeWasAutoSized) { + if (this->Sizing.TotalSolarCollectorArea > 0) { + tmpTankVolume = this->Sizing.TotalSolarCollectorArea * this->Sizing.TankCapacityPerCollectorArea; + } else { + ShowFatalError(state, + format("{}: Tank=\"{}\", requested sizing for volume with PerSolarCollectorArea but total found " + "area of Collectors is zero.", + RoutineName, + this->Name)); + } + } + if (this->MaxCapacityWasAutoSized) { + tmpMaxCapacity = 0.0; + } if (this->VolumeWasAutoSized && state.dataPlnt->PlantFirstSizesOkayToFinalize) { this->Volume = tmpTankVolume; if (state.dataPlnt->PlantFinalSizesOkayToReport) { @@ -11285,7 +11313,9 @@ void WaterThermalTankData::SizeTankForSupplySide(EnergyPlusData &state) } } - if (this->MaxCapacityWasAutoSized) this->setBackupElementCapacity(state); + if (this->MaxCapacityWasAutoSized) { + this->setBackupElementCapacity(state); + } if ((this->VolumeWasAutoSized) && (this->WaterThermalTankType == DataPlant::PlantEquipmentType::WtrHeaterStratified) && state.dataPlnt->PlantFirstSizesOkayToFinalize) { // might set height @@ -11577,8 +11607,7 @@ void WaterThermalTankData::SizeStandAloneWaterHeater(EnergyPlusData &state) } else { ShowFatalError( state, - format("SizeStandAloneWaterHeater: Tank=\"{}\", requested sizing for max capacity but entered Recovery Time is zero.", - this->Name)); + format("{}: Tank=\"{}\", requested sizing for max capacity but entered Recovery Time is zero.", RoutineName, this->Name)); } this->MaxCapacity = tmpMaxCapacity; BaseSizer::reportSizerOutput(state, this->Type, this->Name, "Maximum Heater Capacity [W]", this->MaxCapacity); @@ -11800,13 +11829,43 @@ void WaterThermalTankData::SizeStandAloneWaterHeater(EnergyPlusData &state) break; } case SizingMode::PerSolarColArea: { + this->Sizing.TotalSolarCollectorArea = 0.0; + if (state.dataSolarCollectors->GetInputFlag) { + SolarCollectors::GetSolarCollectorInput(state); + state.dataSolarCollectors->GetInputFlag = false; + } + for (int CollectorNum = 1; CollectorNum <= state.dataSolarCollectors->NumOfCollectors; ++CollectorNum) { - this->Sizing.TotalSolarCollectorArea += state.dataSurface->Surface(state.dataSolarCollectors->Collector(CollectorNum).Surface).Area; + auto const &collector = state.dataSolarCollectors->Collector(CollectorNum); + this->Sizing.TotalSolarCollectorArea += state.dataSurface->Surface(collector.Surface).Area; + } + + if (state.dataPhotovoltaicThermalCollector->GetInputFlag) { + PhotovoltaicThermalCollectors::GetPVTcollectorsInput(state); + state.dataPhotovoltaicThermalCollector->GetInputFlag = false; + } + + for (int CollectorNum = 1; CollectorNum <= state.dataPhotovoltaicThermalCollector->NumPVT; ++CollectorNum) { + auto const &collector = state.dataPhotovoltaicThermalCollector->PVT(CollectorNum); + this->Sizing.TotalSolarCollectorArea += collector.AreaCol; + } + + if (this->VolumeWasAutoSized) { + if (this->Sizing.TotalSolarCollectorArea > 0) { + tmpTankVolume = this->Sizing.TotalSolarCollectorArea * this->Sizing.TankCapacityPerCollectorArea; + } else { + ShowFatalError(state, + format("{}: Tank=\"{}\", requested sizing for volume with PerSolarCollectorArea but total found " + "area of Collectors is zero.", + RoutineName, + this->Name)); + } + } + if (this->MaxCapacityWasAutoSized) { + tmpMaxCapacity = 0.0; } - if (this->VolumeWasAutoSized) tmpTankVolume = this->Sizing.TotalSolarCollectorArea * this->Sizing.TankCapacityPerCollectorArea; - if (this->MaxCapacityWasAutoSized) tmpMaxCapacity = 0.0; if (this->VolumeWasAutoSized) { this->Volume = tmpTankVolume; BaseSizer::reportSizerOutput(state, this->Type, this->Name, "Tank Volume [m3]", this->Volume); @@ -11818,7 +11877,9 @@ void WaterThermalTankData::SizeStandAloneWaterHeater(EnergyPlusData &state) break; } default: - if (this->MaxCapacityWasAutoSized) this->setBackupElementCapacity(state); + if (this->MaxCapacityWasAutoSized) { + this->setBackupElementCapacity(state); + } break; } } From 4ee8bcb4e80adb7f6d7a84c9e61eb08af59f40d8 Mon Sep 17 00:00:00 2001 From: Julien Marrec Date: Thu, 20 Jun 2024 01:50:17 +0200 Subject: [PATCH 23/57] The CollectorData and PVTCollectorStruct use a factory, so we don't need to check if we need to trigger the getinput for them --- src/EnergyPlus/WaterThermalTanks.cc | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/src/EnergyPlus/WaterThermalTanks.cc b/src/EnergyPlus/WaterThermalTanks.cc index 4f747999d2a..060fc2d59dc 100644 --- a/src/EnergyPlus/WaterThermalTanks.cc +++ b/src/EnergyPlus/WaterThermalTanks.cc @@ -11259,21 +11259,12 @@ void WaterThermalTankData::SizeTankForSupplySide(EnergyPlusData &state) } else if (this->Sizing.DesignMode == SizingMode::PerSolarColArea) { this->Sizing.TotalSolarCollectorArea = 0.0; - if (state.dataSolarCollectors->GetInputFlag) { - SolarCollectors::GetSolarCollectorInput(state); - state.dataSolarCollectors->GetInputFlag = false; - } for (int CollectorNum = 1; CollectorNum <= state.dataSolarCollectors->NumOfCollectors; ++CollectorNum) { auto const &collector = state.dataSolarCollectors->Collector(CollectorNum); this->Sizing.TotalSolarCollectorArea += state.dataSurface->Surface(collector.Surface).Area; } - if (state.dataPhotovoltaicThermalCollector->GetInputFlag) { - PhotovoltaicThermalCollectors::GetPVTcollectorsInput(state); - state.dataPhotovoltaicThermalCollector->GetInputFlag = false; - } - for (int CollectorNum = 1; CollectorNum <= state.dataPhotovoltaicThermalCollector->NumPVT; ++CollectorNum) { auto const &collector = state.dataPhotovoltaicThermalCollector->PVT(CollectorNum); this->Sizing.TotalSolarCollectorArea += collector.AreaCol; @@ -11831,21 +11822,12 @@ void WaterThermalTankData::SizeStandAloneWaterHeater(EnergyPlusData &state) case SizingMode::PerSolarColArea: { this->Sizing.TotalSolarCollectorArea = 0.0; - if (state.dataSolarCollectors->GetInputFlag) { - SolarCollectors::GetSolarCollectorInput(state); - state.dataSolarCollectors->GetInputFlag = false; - } for (int CollectorNum = 1; CollectorNum <= state.dataSolarCollectors->NumOfCollectors; ++CollectorNum) { auto const &collector = state.dataSolarCollectors->Collector(CollectorNum); this->Sizing.TotalSolarCollectorArea += state.dataSurface->Surface(collector.Surface).Area; } - if (state.dataPhotovoltaicThermalCollector->GetInputFlag) { - PhotovoltaicThermalCollectors::GetPVTcollectorsInput(state); - state.dataPhotovoltaicThermalCollector->GetInputFlag = false; - } - for (int CollectorNum = 1; CollectorNum <= state.dataPhotovoltaicThermalCollector->NumPVT; ++CollectorNum) { auto const &collector = state.dataPhotovoltaicThermalCollector->PVT(CollectorNum); this->Sizing.TotalSolarCollectorArea += collector.AreaCol; From ee3e6d96ef9342eb7193e4b02e191ef46c19d9c4 Mon Sep 17 00:00:00 2001 From: Tanaya Mankad Date: Fri, 21 Jun 2024 13:02:41 -0600 Subject: [PATCH 24/57] Change expected values for OA node in test. --- tst/EnergyPlus/unit/PackagedTerminalHeatPump.unit.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tst/EnergyPlus/unit/PackagedTerminalHeatPump.unit.cc b/tst/EnergyPlus/unit/PackagedTerminalHeatPump.unit.cc index 69f07912d4c..a8e0a3499d5 100644 --- a/tst/EnergyPlus/unit/PackagedTerminalHeatPump.unit.cc +++ b/tst/EnergyPlus/unit/PackagedTerminalHeatPump.unit.cc @@ -4009,8 +4009,8 @@ TEST_F(EnergyPlusFixture, PTACDrawAirfromReturnNodeAndPlenum_Test) // EXPECT_NEAR(23.153277047505515, state->dataLoopNodes->Node(11).Temp, 0.001); // ATMixer primary air inlet node, or air loop SAT, T = OAT + fan heat - EXPECT_NEAR(31.1803, state->dataLoopNodes->Node(ATMixer1PriInNode).Temp, 0.001); - EXPECT_NEAR(0.0015, state->dataLoopNodes->Node(ATMixer1PriInNode).HumRat, 0.001); + EXPECT_NEAR(34.2002, state->dataLoopNodes->Node(ATMixer1PriInNode).Temp, 0.001); + EXPECT_NEAR(0.0003, state->dataLoopNodes->Node(ATMixer1PriInNode).HumRat, 0.001); EXPECT_NEAR(35169.5566, state->dataLoopNodes->Node(ATMixer1PriInNode).Enthalpy, 0.001); // *** this next test is different from develop, air loop is on, this pri/ret flow was 0 before @@ -4027,7 +4027,7 @@ TEST_F(EnergyPlusFixture, PTACDrawAirfromReturnNodeAndPlenum_Test) // same temperature test as above commented out test (23.15327704750551), now shows 21.2 C // how do you mix 2 air streams with T1in=31.18 and T2in=23.15 and get Tout=21.23 ?? // must be a node enthalpy issue with this unit test? - EXPECT_NEAR(21.2316, state->dataLoopNodes->Node(ATMixer1AirOutNode).Temp, 0.001); + EXPECT_NEAR(21.5613, state->dataLoopNodes->Node(ATMixer1AirOutNode).Temp, 0.001); EXPECT_NEAR(0.324036, state->dataLoopNodes->Node(ATMixer1AirOutNode).MassFlowRate, 0.001); // mass balance zone 1 ATMixer outlet enthalpy based on pri and sec inlet stream enthalpy From 0c5ec52eb07eb5c02258fd13291fe91f6626b2d0 Mon Sep 17 00:00:00 2001 From: Tanaya Mankad Date: Fri, 21 Jun 2024 13:41:41 -0600 Subject: [PATCH 25/57] Fix formatting. --- tst/EnergyPlus/unit/MixedAir.unit.cc | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/tst/EnergyPlus/unit/MixedAir.unit.cc b/tst/EnergyPlus/unit/MixedAir.unit.cc index 69a088c6788..77338b99c55 100644 --- a/tst/EnergyPlus/unit/MixedAir.unit.cc +++ b/tst/EnergyPlus/unit/MixedAir.unit.cc @@ -7742,11 +7742,9 @@ TEST_F(EnergyPlusFixture, MixedAir_TemperatureError) state->dataLoopNodes->Node(return_node).Press = 99063; state->dataLoopNodes->Node(return_node).MassFlowRate = 0.2923; - MixedAir::SimOAMixer( - *state, state->dataAirLoop->OutsideAirSys(1).ComponentName(1), state->dataAirLoop->OutsideAirSys(1).ComponentIndex(1)); + MixedAir::SimOAMixer(*state, state->dataAirLoop->OutsideAirSys(1).ComponentName(1), state->dataAirLoop->OutsideAirSys(1).ComponentIndex(1)); - auto T_sat = Psychrometrics::PsyTsatFnHPb( - *state, state->dataMixedAir->OAMixer(1).MixEnthalpy, state->dataMixedAir->OAMixer(1).MixPressure); + auto T_sat = Psychrometrics::PsyTsatFnHPb(*state, state->dataMixedAir->OAMixer(1).MixEnthalpy, state->dataMixedAir->OAMixer(1).MixPressure); // T_db must be >= T_sat at the mixed-air node to remain physical EXPECT_TRUE(state->dataMixedAir->OAMixer(1).MixTemp >= T_sat); From 08348b5cd0248b0403dee70a5ada944fc7be7f5a Mon Sep 17 00:00:00 2001 From: Tanaya Mankad Date: Mon, 24 Jun 2024 16:20:04 -0600 Subject: [PATCH 26/57] Move dataEnvrn settings above any functions that call SetOANodeValues. --- src/EnergyPlus/MixedAir.cc | 2 +- .../unit/PackagedTerminalHeatPump.unit.cc | 21 ++++++++++--------- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/src/EnergyPlus/MixedAir.cc b/src/EnergyPlus/MixedAir.cc index 57884130822..bc658eb3530 100644 --- a/src/EnergyPlus/MixedAir.cc +++ b/src/EnergyPlus/MixedAir.cc @@ -4683,7 +4683,7 @@ void CalcOAMixer(EnergyPlusData &state, int const OAMixerNum) Psychrometrics::PsyTdbFnHW(state.dataMixedAir->OAMixer(OAMixerNum).MixEnthalpy, state.dataMixedAir->OAMixer(OAMixerNum).MixHumRat); // Check for saturation temperature > dry-bulb temperature and modify temperature at constant enthalpy - auto T_sat = + Real64 T_sat = Psychrometrics::PsyTsatFnHPb(state, state.dataMixedAir->OAMixer(OAMixerNum).MixEnthalpy, state.dataMixedAir->OAMixer(OAMixerNum).MixPressure); if (state.dataMixedAir->OAMixer(OAMixerNum).MixTemp < T_sat) { state.dataMixedAir->OAMixer(OAMixerNum).MixTemp = T_sat; diff --git a/tst/EnergyPlus/unit/PackagedTerminalHeatPump.unit.cc b/tst/EnergyPlus/unit/PackagedTerminalHeatPump.unit.cc index a8e0a3499d5..023c2b73188 100644 --- a/tst/EnergyPlus/unit/PackagedTerminalHeatPump.unit.cc +++ b/tst/EnergyPlus/unit/PackagedTerminalHeatPump.unit.cc @@ -3881,6 +3881,14 @@ TEST_F(EnergyPlusFixture, PTACDrawAirfromReturnNodeAndPlenum_Test) state->dataZoneEnergyDemand->DeadBandOrSetback.allocate(state->dataGlobal->NumOfZones); state->dataZoneEnergyDemand->DeadBandOrSetback = 0.0; + state->dataEnvrn->OutDryBulbTemp = 30.0; + state->dataEnvrn->OutHumRat = 0.0015; + state->dataEnvrn->OutBaroPress = 101325.0; + state->dataEnvrn->OutEnthalpy = Psychrometrics::PsyHFnTdbW(30.0, 0.0015); + state->dataEnvrn->WindSpeed = 4.9; + state->dataEnvrn->WindDir = 270.0; + state->dataEnvrn->StdRhoAir = 1.2; + ZoneAirLoopEquipmentManager::GetZoneAirLoopEquipment(*state); SimAirServingZones::GetAirPathData(*state); state->dataSimAirServingZones->GetAirLoopInputFlag = false; @@ -3902,13 +3910,6 @@ TEST_F(EnergyPlusFixture, PTACDrawAirfromReturnNodeAndPlenum_Test) state->dataZoneEnergyDemand->ZoneSysEnergyDemand(i).RemainingOutputReqToCoolSP = -5000.0; state->dataZoneEnergyDemand->ZoneSysEnergyDemand(i).RemainingOutputReqToHeatSP = -200.0; } - state->dataEnvrn->OutDryBulbTemp = 30.0; - state->dataEnvrn->OutHumRat = 0.0015; - state->dataEnvrn->OutBaroPress = 101325.0; - state->dataEnvrn->OutEnthalpy = Psychrometrics::PsyHFnTdbW(30.0, 0.0015); - state->dataEnvrn->WindSpeed = 4.9; - state->dataEnvrn->WindDir = 270.0; - state->dataEnvrn->StdRhoAir = 1.2; GetZoneAirSetPoints(*state); state->dataHeatBalFanSys->TempControlType.allocate(6); state->dataHeatBalFanSys->TempControlType = HVAC::ThermostatType::DualSetPointWithDeadBand; @@ -4009,8 +4010,8 @@ TEST_F(EnergyPlusFixture, PTACDrawAirfromReturnNodeAndPlenum_Test) // EXPECT_NEAR(23.153277047505515, state->dataLoopNodes->Node(11).Temp, 0.001); // ATMixer primary air inlet node, or air loop SAT, T = OAT + fan heat - EXPECT_NEAR(34.2002, state->dataLoopNodes->Node(ATMixer1PriInNode).Temp, 0.001); - EXPECT_NEAR(0.0003, state->dataLoopNodes->Node(ATMixer1PriInNode).HumRat, 0.001); + EXPECT_NEAR(31.1803, state->dataLoopNodes->Node(ATMixer1PriInNode).Temp, 0.001); + EXPECT_NEAR(0.0015, state->dataLoopNodes->Node(ATMixer1PriInNode).HumRat, 0.001); EXPECT_NEAR(35169.5566, state->dataLoopNodes->Node(ATMixer1PriInNode).Enthalpy, 0.001); // *** this next test is different from develop, air loop is on, this pri/ret flow was 0 before @@ -4027,7 +4028,7 @@ TEST_F(EnergyPlusFixture, PTACDrawAirfromReturnNodeAndPlenum_Test) // same temperature test as above commented out test (23.15327704750551), now shows 21.2 C // how do you mix 2 air streams with T1in=31.18 and T2in=23.15 and get Tout=21.23 ?? // must be a node enthalpy issue with this unit test? - EXPECT_NEAR(21.5613, state->dataLoopNodes->Node(ATMixer1AirOutNode).Temp, 0.001); + EXPECT_NEAR(21.2317, state->dataLoopNodes->Node(ATMixer1AirOutNode).Temp, 0.001); EXPECT_NEAR(0.324036, state->dataLoopNodes->Node(ATMixer1AirOutNode).MassFlowRate, 0.001); // mass balance zone 1 ATMixer outlet enthalpy based on pri and sec inlet stream enthalpy From 047735d8d7ec97c7dff19c22f433eed369e21004 Mon Sep 17 00:00:00 2001 From: Rick Strand Date: Wed, 10 Jul 2024 06:30:08 -0500 Subject: [PATCH 27/57] 10299 Split GetShadowingInput This commit splits GetShadowingInput into two separate routines and will test to see if the split has been done correctly. The split is important because the actual getting of the input needs to be moved up in the order of calls to resolve this defect, but some of the processing needs to stay where it is at because it needs zones and surfaces read in. --- src/EnergyPlus/DataSystemVariables.hh | 5 + src/EnergyPlus/SolarShading.cc | 159 ++++++++++++----------- src/EnergyPlus/SolarShading.hh | 2 + tst/EnergyPlus/unit/SolarShading.unit.cc | 2 + 4 files changed, 92 insertions(+), 76 deletions(-) diff --git a/src/EnergyPlus/DataSystemVariables.hh b/src/EnergyPlus/DataSystemVariables.hh index 7de50eec237..156d628ab01 100644 --- a/src/EnergyPlus/DataSystemVariables.hh +++ b/src/EnergyPlus/DataSystemVariables.hh @@ -112,6 +112,11 @@ struct SystemVarsData : BaseGlobalStruct bool ReportExtShadingSunlitFrac = false; // when true, the sunlit fraction for all surfaces are exported as a csv format output bool DisableGroupSelfShading = false; // when true, defined shadowing surfaces group is ignored when calculating sunlit fraction bool DisableAllSelfShading = false; // when true, all external shadowing surfaces is ignored when calculating sunlit fraction + bool DisableSelfShadingWithinGroup = false; + bool DisableSelfShadingBetweenGroup = false; + + int shadingGroupsNum = 0; // number of shading groups + Array1D_string zoneName; // array of zone names in user input bool TrackAirLoopEnvFlag = false; // If TRUE generates a file with runtime statistics for each HVAC // controller on each air loop diff --git a/src/EnergyPlus/SolarShading.cc b/src/EnergyPlus/SolarShading.cc index adbeb77c6ce..be6f9f9ebc4 100644 --- a/src/EnergyPlus/SolarShading.cc +++ b/src/EnergyPlus/SolarShading.cc @@ -197,6 +197,7 @@ void InitSolarCalculations(EnergyPlusData &state) if (state.dataSolarShading->GetInputFlag) { checkShadingSurfaceSchedules(state); GetShadowingInput(state); + processShadowingInput(state); state.dataSolarShading->GetInputFlag = false; state.dataSolarShading->MaxHCV = (((max(15, state.dataSurface->MaxVerticesPerSurface) + 16) / 16) * 16) - 1; // Assure MaxHCV+1 is multiple of 16 for 128 B alignment @@ -629,30 +630,11 @@ void GetShadowingInput(EnergyPlusData &state) state.dataIPShortCut->cAlphaArgs(aNum) = "No"; state.dataSysVars->ReportExtShadingSunlitFrac = false; } - if (state.dataSysVars->shadingMethod == ShadingMethod::Imported) { - int ExtShadingSchedNum; - for (int SurfNum = 1; SurfNum <= state.dataSurface->TotSurfaces; ++SurfNum) { - ExtShadingSchedNum = ScheduleManager::GetScheduleIndex(state, state.dataSurface->Surface(SurfNum).Name + "_shading"); - if (ExtShadingSchedNum != 0) { - state.dataSurface->Surface(SurfNum).SurfSchedExternalShadingFrac = true; - state.dataSurface->Surface(SurfNum).SurfExternalShadingSchInd = ExtShadingSchedNum; - } else { - ShowWarningError(state, - format("{}: sunlit fraction schedule not found for {} when using ImportedShading.", - cCurrentModuleObject, - state.dataSurface->Surface(SurfNum).Name)); - ShowContinueError(state, "These values are set to 1.0."); - } - } - } - - bool DisableSelfShadingWithinGroup = false; - bool DisableSelfShadingBetweenGroup = false; aNum++; if (NumAlphas >= aNum) { if (Util::SameString(state.dataIPShortCut->cAlphaArgs(aNum), "Yes")) { - DisableSelfShadingWithinGroup = true; + state.dataSysVars->DisableSelfShadingWithinGroup = true; state.dataIPShortCut->cAlphaArgs(aNum) = "Yes"; } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(aNum), "No")) { state.dataIPShortCut->cAlphaArgs(aNum) = "No"; @@ -668,7 +650,7 @@ void GetShadowingInput(EnergyPlusData &state) aNum++; if (NumAlphas >= aNum) { if (Util::SameString(state.dataIPShortCut->cAlphaArgs(aNum), "Yes")) { - DisableSelfShadingBetweenGroup = true; + state.dataSysVars->DisableSelfShadingBetweenGroup = true; state.dataIPShortCut->cAlphaArgs(aNum) = "Yes"; } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(aNum), "No")) { state.dataIPShortCut->cAlphaArgs(aNum) = "No"; @@ -681,66 +663,17 @@ void GetShadowingInput(EnergyPlusData &state) state.dataIPShortCut->cAlphaArgs(aNum) = "No"; } - if (DisableSelfShadingBetweenGroup && DisableSelfShadingWithinGroup) { + if (state.dataSysVars->DisableSelfShadingBetweenGroup && state.dataSysVars->DisableSelfShadingWithinGroup) { state.dataSysVars->DisableAllSelfShading = true; - } else if (DisableSelfShadingBetweenGroup || DisableSelfShadingWithinGroup) { + } else if (state.dataSysVars->DisableSelfShadingBetweenGroup || state.dataSysVars->DisableSelfShadingWithinGroup) { state.dataSysVars->DisableGroupSelfShading = true; } aNum++; - int SurfZoneGroup, CurZoneGroup; - if (state.dataSysVars->DisableGroupSelfShading) { - Array1D_int DisableSelfShadingGroups; - int NumOfShadingGroups; - if (NumAlphas >= aNum) { - // Read all shading groups - NumOfShadingGroups = NumAlphas - (aNum - 1); - DisableSelfShadingGroups.allocate(NumOfShadingGroups); - for (int i = 1; i <= NumOfShadingGroups; i++) { - Found = Util::FindItemInList( - state.dataIPShortCut->cAlphaArgs(i + (aNum - 1)), state.dataHeatBal->ZoneList, state.dataHeatBal->NumOfZoneLists); - if (Found != 0) DisableSelfShadingGroups(i) = Found; - } - - for (int SurfNum = 1; SurfNum <= state.dataSurface->TotSurfaces; SurfNum++) { - if (state.dataSurface->Surface(SurfNum).ExtBoundCond == 0) { // Loop through all exterior surfaces - SurfZoneGroup = 0; - // Check the shading zone group of each exterior surface - for (int ZoneGroupLoop = 1; ZoneGroupLoop <= NumOfShadingGroups; ZoneGroupLoop++) { // Loop through all defined shading groups - CurZoneGroup = DisableSelfShadingGroups(ZoneGroupLoop); - for (int ZoneNum = 1; ZoneNum <= state.dataHeatBal->ZoneList(CurZoneGroup).NumOfZones; - ZoneNum++) { // Loop through all zones in the zone list - if (state.dataSurface->Surface(SurfNum).Zone == state.dataHeatBal->ZoneList(CurZoneGroup).Zone(ZoneNum)) { - SurfZoneGroup = CurZoneGroup; - break; - } - } - } - // if a surface is not in any zone group, no self shading is disabled for this surface - if (SurfZoneGroup != 0) { - // if DisableSelfShadingWithinGroup, add all zones in the same zone group to the surface's disabled zone list - // if DisableSelfShadingBetweenGroups, add all zones in all other zone groups to the surface's disabled zone list - for (int ZoneGroupLoop = 1; ZoneGroupLoop <= NumOfShadingGroups; ZoneGroupLoop++) { // Loop through all defined shading groups - CurZoneGroup = DisableSelfShadingGroups(ZoneGroupLoop); - if (SurfZoneGroup == CurZoneGroup && DisableSelfShadingWithinGroup) { - for (int ZoneNum = 1; ZoneNum <= state.dataHeatBal->ZoneList(CurZoneGroup).NumOfZones; - ZoneNum++) { // Loop through all zones in the zone list - state.dataSurface->SurfShadowDisabledZoneList(SurfNum).push_back( - state.dataHeatBal->ZoneList(CurZoneGroup).Zone(ZoneNum)); - } - } else if (SurfZoneGroup != CurZoneGroup && DisableSelfShadingBetweenGroup) { - for (int ZoneNum = 1; ZoneNum <= state.dataHeatBal->ZoneList(CurZoneGroup).NumOfZones; ZoneNum++) { - state.dataSurface->SurfShadowDisabledZoneList(SurfNum).push_back( - state.dataHeatBal->ZoneList(CurZoneGroup).Zone(ZoneNum)); - } - } - } - } - } - } - } else { - ShowFatalError(state, "No Shading groups are defined when disabling grouped self shading."); - } + state.dataSysVars->shadingGroupsNum = NumAlphas - (aNum - 1); + state.dataSysVars->zoneName.allocate(state.dataSysVars->shadingGroupsNum); + for (int numZone = 1; numZone <= state.dataSysVars->shadingGroupsNum; ++numZone) { + state.dataSysVars->zoneName(numZone) = state.dataIPShortCut->cAlphaArgs(aNum - 1 + numZone); } if (!state.dataSysVars->DetailedSolarTimestepIntegration && state.dataSurface->ShadingTransmittanceVaries && @@ -797,6 +730,80 @@ void GetShadowingInput(EnergyPlusData &state) state.dataIPShortCut->cAlphaArgs(7)); } +void processShadowingInput(EnergyPlusData &state) +{ + // all shadow input processing that needed zones and surfaces to already be read into data (part of fix for Defect #10299) + + if (state.dataSysVars->shadingMethod == DataSystemVariables::ShadingMethod::Imported) { + int ExtShadingSchedNum; + for (int SurfNum = 1; SurfNum <= state.dataSurface->TotSurfaces; ++SurfNum) { + ExtShadingSchedNum = ScheduleManager::GetScheduleIndex(state, state.dataSurface->Surface(SurfNum).Name + "_shading"); + if (ExtShadingSchedNum != 0) { + state.dataSurface->Surface(SurfNum).SurfSchedExternalShadingFrac = true; + state.dataSurface->Surface(SurfNum).SurfExternalShadingSchInd = ExtShadingSchedNum; + } else { + ShowWarningError(state, + format("processShadowingInput: sunlit fraction schedule not found for {} when using ImportedShading.", + state.dataSurface->Surface(SurfNum).Name)); + ShowContinueError(state, "These values are set to 1.0."); + } + } + } + + int SurfZoneGroup, CurZoneGroup; + int Found = 0; + if (state.dataSysVars->DisableGroupSelfShading) { + Array1D_int DisableSelfShadingGroups; + int NumOfShadingGroups = state.dataSysVars->shadingGroupsNum; + if (NumOfShadingGroups > 0) { + DisableSelfShadingGroups.allocate(NumOfShadingGroups); + for (int i = 1; i <= NumOfShadingGroups; i++) { + Found = Util::FindItemInList(state.dataSysVars->zoneName(i), state.dataHeatBal->ZoneList, state.dataHeatBal->NumOfZoneLists); + if (Found != 0) DisableSelfShadingGroups(i) = Found; + } + + for (int SurfNum = 1; SurfNum <= state.dataSurface->TotSurfaces; SurfNum++) { + if (state.dataSurface->Surface(SurfNum).ExtBoundCond == 0) { // Loop through all exterior surfaces + SurfZoneGroup = 0; + // Check the shading zone group of each exterior surface + for (int ZoneGroupLoop = 1; ZoneGroupLoop <= NumOfShadingGroups; ZoneGroupLoop++) { // Loop through all defined shading groups + CurZoneGroup = DisableSelfShadingGroups(ZoneGroupLoop); + for (int ZoneNum = 1; ZoneNum <= state.dataHeatBal->ZoneList(CurZoneGroup).NumOfZones; + ZoneNum++) { // Loop through all zones in the zone list + if (state.dataSurface->Surface(SurfNum).Zone == state.dataHeatBal->ZoneList(CurZoneGroup).Zone(ZoneNum)) { + SurfZoneGroup = CurZoneGroup; + break; + } + } + } + // if a surface is not in any zone group, no self shading is disabled for this surface + if (SurfZoneGroup != 0) { + // if DisableSelfShadingWithinGroup, add all zones in the same zone group to the surface's disabled zone list + // if DisableSelfShadingBetweenGroups, add all zones in all other zone groups to the surface's disabled zone list + for (int ZoneGroupLoop = 1; ZoneGroupLoop <= NumOfShadingGroups; ZoneGroupLoop++) { // Loop through all defined shading groups + CurZoneGroup = DisableSelfShadingGroups(ZoneGroupLoop); + if (SurfZoneGroup == CurZoneGroup && state.dataSysVars->DisableSelfShadingWithinGroup) { + for (int ZoneNum = 1; ZoneNum <= state.dataHeatBal->ZoneList(CurZoneGroup).NumOfZones; + ZoneNum++) { // Loop through all zones in the zone list + state.dataSurface->SurfShadowDisabledZoneList(SurfNum).push_back( + state.dataHeatBal->ZoneList(CurZoneGroup).Zone(ZoneNum)); + } + } else if (SurfZoneGroup != CurZoneGroup && state.dataSysVars->DisableSelfShadingBetweenGroup) { + for (int ZoneNum = 1; ZoneNum <= state.dataHeatBal->ZoneList(CurZoneGroup).NumOfZones; ZoneNum++) { + state.dataSurface->SurfShadowDisabledZoneList(SurfNum).push_back( + state.dataHeatBal->ZoneList(CurZoneGroup).Zone(ZoneNum)); + } + } + } + } + } + } + } else { + ShowFatalError(state, "No Shading groups are defined when disabling grouped self shading."); + } + } +} + void checkScheduledSurfacePresent(EnergyPlusData &state) { // User has chosen "Scheduled" for sunlit fraction so check to see which surfaces don't have a schedule diff --git a/src/EnergyPlus/SolarShading.hh b/src/EnergyPlus/SolarShading.hh index cb1dba901c0..5e3d62e5f41 100644 --- a/src/EnergyPlus/SolarShading.hh +++ b/src/EnergyPlus/SolarShading.hh @@ -99,6 +99,8 @@ namespace SolarShading { void GetShadowingInput(EnergyPlusData &state); + void processShadowingInput(EnergyPlusData &state); + void checkScheduledSurfacePresent(EnergyPlusData &state); void AllocateModuleArrays(EnergyPlusData &state); diff --git a/tst/EnergyPlus/unit/SolarShading.unit.cc b/tst/EnergyPlus/unit/SolarShading.unit.cc index dc0d2d47e29..c53be169dae 100644 --- a/tst/EnergyPlus/unit/SolarShading.unit.cc +++ b/tst/EnergyPlus/unit/SolarShading.unit.cc @@ -1484,6 +1484,7 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_DisableGroupSelfShading) compare_err_stream(""); // just for debugging SolarShading::GetShadowingInput(*state); + SolarShading::processShadowingInput(*state); for (int SurfNum = 1; SurfNum <= state->dataSurface->TotSurfaces; SurfNum++) { if (state->dataSurface->Surface(SurfNum).ExtBoundCond == 0 && state->dataSurface->Surface(SurfNum).Zone != 0) { @@ -3887,6 +3888,7 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_Warn_Pixel_Count_and_TM_Schedule) EXPECT_EQ(state->dataErrTracking->TotalSevereErrors, 0); SolarShading::GetShadowingInput(*state); + SolarShading::processShadowingInput(*state); #ifdef EP_NO_OPENGL EXPECT_EQ(state->dataErrTracking->TotalWarningErrors, 1); From 01c2a82ab095db4d40d46f191ce68deb02374816 Mon Sep 17 00:00:00 2001 From: Lixing Gu Date: Wed, 10 Jul 2024 15:37:12 -0400 Subject: [PATCH 28/57] Address comments and cleanup --- src/EnergyPlus/FanCoilUnits.cc | 22 ---- src/EnergyPlus/FanCoilUnits.hh | 2 - src/EnergyPlus/PurchasedAirManager.cc | 15 --- src/EnergyPlus/PurchasedAirManager.hh | 2 - src/EnergyPlus/UnitHeater.cc | 33 ------ src/EnergyPlus/UnitHeater.hh | 4 - src/EnergyPlus/VentilatedSlab.cc | 31 ------ src/EnergyPlus/VentilatedSlab.hh | 4 - src/EnergyPlus/WaterThermalTanks.cc | 30 ------ src/EnergyPlus/WaterThermalTanks.hh | 4 - src/EnergyPlus/ZoneDehumidifier.cc | 30 ------ src/EnergyPlus/ZoneDehumidifier.hh | 4 - .../unit/RoomAirflowNetwork.unit.cc | 102 ++++++++---------- 13 files changed, 44 insertions(+), 239 deletions(-) diff --git a/src/EnergyPlus/FanCoilUnits.cc b/src/EnergyPlus/FanCoilUnits.cc index 048abf9b95e..1e05e8f7056 100644 --- a/src/EnergyPlus/FanCoilUnits.cc +++ b/src/EnergyPlus/FanCoilUnits.cc @@ -4119,28 +4119,6 @@ namespace FanCoilUnits { return 0; } - int GetFanCoilAirInNode(EnergyPlusData &state, int const FanCoilNum) - { - - // FUNCTION INFORMATION: - // AUTHOR B Griffith - // DATE WRITTEN Dec 2006 - - // PURPOSE OF THIS FUNCTION: - // lookup function for OA inlet node for ventilation rate reporting - - if (state.dataFanCoilUnits->GetFanCoilInputFlag) { - GetFanCoilUnits(state); - state.dataFanCoilUnits->GetFanCoilInputFlag = false; - } - - if (FanCoilNum > 0 && FanCoilNum <= state.dataFanCoilUnits->NumFanCoils) { - return state.dataFanCoilUnits->FanCoil(FanCoilNum).AirInNode; - } - - return 0; - } - int GetFanCoilOutAirNode(EnergyPlusData &state, int const FanCoilNum) { diff --git a/src/EnergyPlus/FanCoilUnits.hh b/src/EnergyPlus/FanCoilUnits.hh index 5dce466105b..6f09a1523fa 100644 --- a/src/EnergyPlus/FanCoilUnits.hh +++ b/src/EnergyPlus/FanCoilUnits.hh @@ -321,8 +321,6 @@ namespace FanCoilUnits { int GetFanCoilZoneInletAirNode(EnergyPlusData &state, int const FanCoilNum); - int GetFanCoilAirInNode(EnergyPlusData &state, int const FanCoilNum); - int GetFanCoilOutAirNode(EnergyPlusData &state, int FanCoilNum); int GetFanCoilReturnAirNode(EnergyPlusData &state, int FanCoilNum); diff --git a/src/EnergyPlus/PurchasedAirManager.cc b/src/EnergyPlus/PurchasedAirManager.cc index 5b1d719f2a2..e3b58a930da 100644 --- a/src/EnergyPlus/PurchasedAirManager.cc +++ b/src/EnergyPlus/PurchasedAirManager.cc @@ -3318,21 +3318,6 @@ int GetPurchasedAirReturnAirNode(EnergyPlusData &state, int const PurchAirNum) return GetPurchasedAirReturnAirNode; } -int GetPurchasedAirZoneExhaustAirNode(EnergyPlusData &state, int PurchAirNum) -{ - if (state.dataPurchasedAirMgr->GetPurchAirInputFlag) { - GetPurchasedAir(state); - state.dataPurchasedAirMgr->GetPurchAirInputFlag = false; - } - - int GetPurchasedAirZoneExhaustAirNode = 0; - if (PurchAirNum > 0 && PurchAirNum <= state.dataPurchasedAirMgr->NumPurchAir) { - GetPurchasedAirZoneExhaustAirNode = state.dataPurchasedAirMgr->PurchAir(PurchAirNum).ZoneExhaustAirNodeNum; - } - - return GetPurchasedAirZoneExhaustAirNode; -} - int getPurchasedAirIndex(EnergyPlusData &state, std::string_view PurchAirName, bool &errFlag) { if (state.dataPurchasedAirMgr->GetPurchAirInputFlag) { diff --git a/src/EnergyPlus/PurchasedAirManager.hh b/src/EnergyPlus/PurchasedAirManager.hh index db21045584b..1058b9953c1 100644 --- a/src/EnergyPlus/PurchasedAirManager.hh +++ b/src/EnergyPlus/PurchasedAirManager.hh @@ -379,8 +379,6 @@ namespace PurchasedAirManager { int GetPurchasedAirReturnAirNode(EnergyPlusData &state, int PurchAirNum); - int GetPurchasedAirZoneExhaustAirNode(EnergyPlusData &state, int PurchAirNum); - int getPurchasedAirIndex(EnergyPlusData &state, std::string_view PurchAirName, bool &errFlag); Real64 GetPurchasedAirMixedAirTemp(EnergyPlusData &state, int PurchAirNum); diff --git a/src/EnergyPlus/UnitHeater.cc b/src/EnergyPlus/UnitHeater.cc index 127fe2079bc..e1ced26febe 100644 --- a/src/EnergyPlus/UnitHeater.cc +++ b/src/EnergyPlus/UnitHeater.cc @@ -1894,39 +1894,6 @@ namespace UnitHeater { } } - int GetUnitHeaterAirOutletNode(EnergyPlusData &state, int UnitHeaterNum) - { - // Return value - int GetUnitHeaterAirOutletNode = 0; - - if (state.dataUnitHeaters->GetUnitHeaterInputFlag) { - GetUnitHeaterInput(state); - state.dataUnitHeaters->GetUnitHeaterInputFlag = false; - } - - if (UnitHeaterNum > 0 && UnitHeaterNum <= state.dataUnitHeaters->NumOfUnitHeats) { - GetUnitHeaterAirOutletNode = state.dataUnitHeaters->UnitHeat(UnitHeaterNum).AirOutNode; - } - - return GetUnitHeaterAirOutletNode; - } - - int GetUnitHeaterAirInletNode(EnergyPlusData &state, int UnitHeaterNum) - { - int GetUnitHeaterAirInletNode = 0; - - if (state.dataUnitHeaters->GetUnitHeaterInputFlag) { - GetUnitHeaterInput(state); - state.dataUnitHeaters->GetUnitHeaterInputFlag = false; - } - - if (UnitHeaterNum > 0 && UnitHeaterNum <= state.dataUnitHeaters->NumOfUnitHeats) { - GetUnitHeaterAirInletNode = state.dataUnitHeaters->UnitHeat(UnitHeaterNum).AirInNode; - } - - return GetUnitHeaterAirInletNode; - } - int getUnitHeaterIndex(EnergyPlusData &state, std::string_view CompName, bool &errFlag) { if (state.dataUnitHeaters->GetUnitHeaterInputFlag) { diff --git a/src/EnergyPlus/UnitHeater.hh b/src/EnergyPlus/UnitHeater.hh index e84f7790d14..a2158cb8b0e 100644 --- a/src/EnergyPlus/UnitHeater.hh +++ b/src/EnergyPlus/UnitHeater.hh @@ -202,10 +202,6 @@ namespace UnitHeater { void ReportUnitHeater(EnergyPlusData &state, int const UnitHeatNum); // Unit index in unit heater array - int GetUnitHeaterAirOutletNode(EnergyPlusData &state, int UnitHeatNum); - - int GetUnitHeaterAirInletNode(EnergyPlusData &state, int UnitHeatNum); - int getUnitHeaterIndex(EnergyPlusData &state, std::string_view CompName, bool &errFlag); } // namespace UnitHeater diff --git a/src/EnergyPlus/VentilatedSlab.cc b/src/EnergyPlus/VentilatedSlab.cc index f132ee63d8e..650530ee64b 100644 --- a/src/EnergyPlus/VentilatedSlab.cc +++ b/src/EnergyPlus/VentilatedSlab.cc @@ -4735,37 +4735,6 @@ namespace VentilatedSlab { } } - int GetVentilatedSlabReturnAirNode(EnergyPlusData &state, int const VentSlabNum) - { - int ReturnAirNode = 0; - if (state.dataVentilatedSlab->GetInputFlag) { - GetVentilatedSlabInput(state); - state.dataVentilatedSlab->GetInputFlag = false; - } - - if (VentSlabNum > 0 && VentSlabNum <= state.dataVentilatedSlab->NumOfVentSlabs) { - ReturnAirNode = state.dataVentilatedSlab->VentSlab(VentSlabNum).ReturnAirNode; - } - - return ReturnAirNode; - } - - int GetVentilatedSlabZoneAirInNode(EnergyPlusData &state, int const VentSlabNum) - { - int ZoneAirInNode = 0; - - if (state.dataVentilatedSlab->GetInputFlag) { - GetVentilatedSlabInput(state); - state.dataVentilatedSlab->GetInputFlag = false; - } - - if (VentSlabNum > 0 && VentSlabNum <= state.dataVentilatedSlab->NumOfVentSlabs) { - ZoneAirInNode = state.dataVentilatedSlab->VentSlab(VentSlabNum).ZoneAirInNode; - } - - return ZoneAirInNode; - } - int getVentilatedSlabIndex(EnergyPlusData &state, std::string_view CompName, bool &errFlag) { if (state.dataVentilatedSlab->GetInputFlag) { diff --git a/src/EnergyPlus/VentilatedSlab.hh b/src/EnergyPlus/VentilatedSlab.hh index f20180c8602..c121528a7f5 100644 --- a/src/EnergyPlus/VentilatedSlab.hh +++ b/src/EnergyPlus/VentilatedSlab.hh @@ -383,10 +383,6 @@ namespace VentilatedSlab { void ReportVentilatedSlab(EnergyPlusData &state, int const Item); // Index for the ventilated slab under consideration within the derived types - int GetVentilatedSlabReturnAirNode(EnergyPlusData &state, int const VentSlabNum); - - int GetVentilatedSlabZoneAirInNode(EnergyPlusData &state, int const VentSlabNum); - int getVentilatedSlabIndex(EnergyPlusData &state, std::string_view CompName, bool &errFlag); //***************************************************************************************** diff --git a/src/EnergyPlus/WaterThermalTanks.cc b/src/EnergyPlus/WaterThermalTanks.cc index bdea7fce4c8..02ed3f8d309 100644 --- a/src/EnergyPlus/WaterThermalTanks.cc +++ b/src/EnergyPlus/WaterThermalTanks.cc @@ -12465,36 +12465,6 @@ bool GetHeatPumpWaterHeaterNodeNumber(EnergyPlusData &state, int const NodeNumbe return HeatPumpWaterHeaterNodeException; } -int GetHeatPumpWaterHeaterAirInletNodeNum(EnergyPlusData &state, int HPNum) -{ - int HeatPumpWaterHeaterAirInletNodeNum = 0; - if (state.dataWaterThermalTanks->getWaterThermalTankInputFlag) { - GetWaterThermalTankInput(state); - state.dataWaterThermalTanks->getWaterThermalTankInputFlag = false; - } - - if (HPNum > 0 && HPNum <= state.dataWaterThermalTanks->numHeatPumpWaterHeater) { - HeatPumpWaterHeaterAirInletNodeNum = state.dataWaterThermalTanks->HPWaterHeater(HPNum).HeatPumpAirInletNode; - } - - return HeatPumpWaterHeaterAirInletNodeNum; -} - -int GetHeatPumpWaterHeaterAirOutletNodeNum(EnergyPlusData &state, int HPNum) -{ - int HeatPumpWaterHeaterAirOutletNodeNum = 0; - if (state.dataWaterThermalTanks->getWaterThermalTankInputFlag) { - GetWaterThermalTankInput(state); - state.dataWaterThermalTanks->getWaterThermalTankInputFlag = false; - } - - if (HPNum > 0 && HPNum <= state.dataWaterThermalTanks->numHeatPumpWaterHeater) { - HeatPumpWaterHeaterAirOutletNodeNum = state.dataWaterThermalTanks->HPWaterHeater(HPNum).HeatPumpAirOutletNode; - } - - return HeatPumpWaterHeaterAirOutletNodeNum; -} - int getHeatPumpWaterHeaterIndex(EnergyPlusData &state, std::string_view CompName, bool &errFlag) { if (state.dataWaterThermalTanks->getWaterThermalTankInputFlag) { diff --git a/src/EnergyPlus/WaterThermalTanks.hh b/src/EnergyPlus/WaterThermalTanks.hh index 7ff93332d85..014ba54f05f 100644 --- a/src/EnergyPlus/WaterThermalTanks.hh +++ b/src/EnergyPlus/WaterThermalTanks.hh @@ -988,10 +988,6 @@ namespace WaterThermalTanks { bool GetHeatPumpWaterHeaterNodeNumber(EnergyPlusData &state, int NodeNumber); - int GetHeatPumpWaterHeaterAirInletNodeNum(EnergyPlusData &state, int HPNum); - - int GetHeatPumpWaterHeaterAirOutletNodeNum(EnergyPlusData &state, int HPNum); - int getHeatPumpWaterHeaterIndex(EnergyPlusData &state, std::string_view CompName, bool &errFlag); } // namespace WaterThermalTanks diff --git a/src/EnergyPlus/ZoneDehumidifier.cc b/src/EnergyPlus/ZoneDehumidifier.cc index e21e5f4c887..0eafa52b1ab 100644 --- a/src/EnergyPlus/ZoneDehumidifier.cc +++ b/src/EnergyPlus/ZoneDehumidifier.cc @@ -1179,36 +1179,6 @@ namespace ZoneDehumidifier { return FindZoneDehumidifierNodeNumber; } - int GetZoneDehumidifierAirOutletNodeNum(EnergyPlusData &state, int ZoneDehumidNum) - { - int ZoneDehumidifierAirOutletNodeNum = 0; - if (state.dataZoneDehumidifier->GetInputFlag) { - GetZoneDehumidifierInput(state); - state.dataZoneDehumidifier->GetInputFlag = false; - } - - if (ZoneDehumidNum > 0 && ZoneDehumidNum <= (int)state.dataZoneDehumidifier->ZoneDehumid.size()) { - ZoneDehumidifierAirOutletNodeNum = state.dataZoneDehumidifier->ZoneDehumid(ZoneDehumidNum).AirOutletNodeNum; - } - - return ZoneDehumidifierAirOutletNodeNum; - } - - int GetZoneDehumidifierAirInletNodeNum(EnergyPlusData &state, int ZoneDehumidNum) - { - int ZoneDehumidifierAirInletNodeNum = 0; - if (state.dataZoneDehumidifier->GetInputFlag) { - GetZoneDehumidifierInput(state); - state.dataZoneDehumidifier->GetInputFlag = false; - } - - if (ZoneDehumidNum > 0 && ZoneDehumidNum <= (int)state.dataZoneDehumidifier->ZoneDehumid.size()) { - ZoneDehumidifierAirInletNodeNum = state.dataZoneDehumidifier->ZoneDehumid(ZoneDehumidNum).AirInletNodeNum; - } - - return ZoneDehumidifierAirInletNodeNum; - } - int getZoneDehumidifierIndex(EnergyPlusData &state, std::string_view CompName, bool &errFlag) { if (state.dataZoneDehumidifier->GetInputFlag) { diff --git a/src/EnergyPlus/ZoneDehumidifier.hh b/src/EnergyPlus/ZoneDehumidifier.hh index 57adbfe4d57..b4800340a34 100644 --- a/src/EnergyPlus/ZoneDehumidifier.hh +++ b/src/EnergyPlus/ZoneDehumidifier.hh @@ -153,10 +153,6 @@ namespace ZoneDehumidifier { bool GetZoneDehumidifierNodeNumber(EnergyPlusData &state, int NodeNumber); // Node being tested - int GetZoneDehumidifierAirOutletNodeNum(EnergyPlusData &state, int ZoneDehumidNum); - - int GetZoneDehumidifierAirInletNodeNum(EnergyPlusData &state, int ZoneDehumidNum); - int getZoneDehumidifierIndex(EnergyPlusData &state, std::string_view CompName, bool &errFlag); } // namespace ZoneDehumidifier diff --git a/tst/EnergyPlus/unit/RoomAirflowNetwork.unit.cc b/tst/EnergyPlus/unit/RoomAirflowNetwork.unit.cc index 36709ad80c0..7522f82eb6a 100644 --- a/tst/EnergyPlus/unit/RoomAirflowNetwork.unit.cc +++ b/tst/EnergyPlus/unit/RoomAirflowNetwork.unit.cc @@ -628,9 +628,8 @@ TEST_F(EnergyPlusFixture, RoomAirflowNetwork_CheckEquipName_Test) state->dataHVACVarRefFlow->NumVRFTU = 1; state->dataHVACVarRefFlow->VRFTU(1).Name = EquipName; check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, zoneEquipType); - if (check) { - EXPECT_EQ("SupplyNode", SupplyNodeName); - } + EXPECT_TRUE(check); + EXPECT_EQ("SupplyNode", SupplyNodeName); state->dataLoopNodes->NodeID(1) = "SupplyNode1"; state->dataLoopNodes->NodeID(2) = "ReturnNode1"; @@ -641,9 +640,8 @@ TEST_F(EnergyPlusFixture, RoomAirflowNetwork_CheckEquipName_Test) state->dataHVACStandAloneERV->StandAloneERV(1).SupplyAirInletNode = 1; state->dataHVACStandAloneERV->StandAloneERV(1).Name = EquipName; check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, zoneEquipType); - if (check) { - EXPECT_EQ("SupplyNode1", SupplyNodeName); - } + EXPECT_TRUE(check); + EXPECT_EQ("SupplyNode1", SupplyNodeName); state->dataLoopNodes->NodeID(1) = "SupplyNode2"; state->dataLoopNodes->NodeID(2) = "ReturnNode2"; @@ -655,10 +653,9 @@ TEST_F(EnergyPlusFixture, RoomAirflowNetwork_CheckEquipName_Test) state->dataFanCoilUnits->GetFanCoilInputFlag = false; state->dataFanCoilUnits->FanCoil(EquipIndex).Name = EquipName; check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, zoneEquipType); - if (check) { - EXPECT_EQ("SupplyNode2", SupplyNodeName); - EXPECT_EQ("ReturnNode2", ReturnNodeName); - } + EXPECT_TRUE(check); + EXPECT_EQ("SupplyNode2", SupplyNodeName); + EXPECT_EQ("ReturnNode2", ReturnNodeName); state->dataLoopNodes->NodeID(1) = "SupplyNode3"; state->dataLoopNodes->NodeID(2) = "ReturnNode3"; @@ -670,10 +667,9 @@ TEST_F(EnergyPlusFixture, RoomAirflowNetwork_CheckEquipName_Test) state->dataOutdoorAirUnit->GetOutdoorAirUnitInputFlag = false; state->dataOutdoorAirUnit->OutAirUnit(EquipIndex).Name = EquipName; check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, zoneEquipType); - if (check) { - EXPECT_EQ("SupplyNode3", SupplyNodeName); - EXPECT_EQ("ReturnNode3", ReturnNodeName); - } + EXPECT_TRUE(check); + EXPECT_EQ("SupplyNode3", SupplyNodeName); + EXPECT_EQ("ReturnNode3", ReturnNodeName); state->dataLoopNodes->NodeID(1) = "SupplyNode4"; state->dataLoopNodes->NodeID(2) = "ReturnNode4"; @@ -686,10 +682,9 @@ TEST_F(EnergyPlusFixture, RoomAirflowNetwork_CheckEquipName_Test) state->dataUnitarySystems->unitarySys[EquipIndex - 1].AirOutNode = 1; state->dataUnitarySystems->unitarySys[EquipIndex - 1].AirInNode = 2; check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, zoneEquipType); - if (check) { - EXPECT_EQ("SupplyNode4", SupplyNodeName); - EXPECT_EQ("ReturnNode4", ReturnNodeName); - } + EXPECT_TRUE(check); + EXPECT_EQ("SupplyNode4", SupplyNodeName); + EXPECT_EQ("ReturnNode4", ReturnNodeName); state->dataLoopNodes->NodeID(1) = "SupplyNode5"; state->dataLoopNodes->NodeID(2) = "ReturnNode5"; @@ -702,10 +697,10 @@ TEST_F(EnergyPlusFixture, RoomAirflowNetwork_CheckEquipName_Test) state->dataUnitarySystems->unitarySys[EquipIndex - 1].AirOutNode = 1; state->dataUnitarySystems->unitarySys[EquipIndex - 1].AirInNode = 2; check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, zoneEquipType); - if (check) { - EXPECT_EQ("SupplyNode5", SupplyNodeName); - EXPECT_EQ("ReturnNode5", ReturnNodeName); - } + EXPECT_TRUE(check); + EXPECT_EQ("SupplyNode5", SupplyNodeName); + EXPECT_EQ("ReturnNode5", ReturnNodeName); + state->dataLoopNodes->NodeID(1) = "SupplyNode6"; state->dataLoopNodes->NodeID(2) = "ReturnNode6"; zoneEquipType = DataZoneEquipment::ZoneEquipType::PackagedTerminalHeatPumpWaterToAir; @@ -717,10 +712,9 @@ TEST_F(EnergyPlusFixture, RoomAirflowNetwork_CheckEquipName_Test) state->dataUnitarySystems->unitarySys[EquipIndex - 1].AirOutNode = 1; state->dataUnitarySystems->unitarySys[EquipIndex - 1].AirInNode = 2; check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, zoneEquipType); - if (check) { - EXPECT_EQ("SupplyNode6", SupplyNodeName); - EXPECT_EQ("ReturnNode6", ReturnNodeName); - } + EXPECT_TRUE(check); + EXPECT_EQ("SupplyNode6", SupplyNodeName); + EXPECT_EQ("ReturnNode6", ReturnNodeName); state->dataLoopNodes->NodeID(1) = "SupplyNode7"; state->dataLoopNodes->NodeID(2) = "ReturnNode7"; @@ -732,10 +726,9 @@ TEST_F(EnergyPlusFixture, RoomAirflowNetwork_CheckEquipName_Test) state->dataUnitHeaters->GetUnitHeaterInputFlag = false; state->dataUnitHeaters->UnitHeat(EquipIndex).Name = EquipName; check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, zoneEquipType); - if (check) { - EXPECT_EQ("SupplyNode7", SupplyNodeName); - EXPECT_EQ("ReturnNode7", ReturnNodeName); - } + EXPECT_TRUE(check); + EXPECT_EQ("SupplyNode7", SupplyNodeName); + EXPECT_EQ("ReturnNode7", ReturnNodeName); state->dataLoopNodes->NodeID(1) = "SupplyNode8"; state->dataLoopNodes->NodeID(2) = "ReturnNode8"; @@ -747,10 +740,9 @@ TEST_F(EnergyPlusFixture, RoomAirflowNetwork_CheckEquipName_Test) state->dataUnitVentilators->UnitVent(EquipIndex).Name = EquipName; state->dataUnitVentilators->GetUnitVentilatorInputFlag = false; check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, zoneEquipType); - if (check) { - EXPECT_EQ("SupplyNode8", SupplyNodeName); - EXPECT_EQ("ReturnNode8", ReturnNodeName); - } + EXPECT_TRUE(check); + EXPECT_EQ("SupplyNode8", SupplyNodeName); + EXPECT_EQ("ReturnNode8", ReturnNodeName); state->dataLoopNodes->NodeID(1) = "SupplyNode9"; state->dataLoopNodes->NodeID(2) = "ReturnNode9"; @@ -762,10 +754,9 @@ TEST_F(EnergyPlusFixture, RoomAirflowNetwork_CheckEquipName_Test) state->dataVentilatedSlab->GetInputFlag = false; state->dataVentilatedSlab->VentSlab(EquipIndex).Name = EquipName; check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, zoneEquipType); - if (check) { - EXPECT_EQ("SupplyNode9", SupplyNodeName); - EXPECT_EQ("ReturnNode9", ReturnNodeName); - } + EXPECT_TRUE(check); + EXPECT_EQ("SupplyNode9", SupplyNodeName); + EXPECT_EQ("ReturnNode9", ReturnNodeName); state->dataLoopNodes->NodeID(1) = "SupplyNode10"; state->dataLoopNodes->NodeID(2) = "ReturnNode10"; @@ -782,10 +773,9 @@ TEST_F(EnergyPlusFixture, RoomAirflowNetwork_CheckEquipName_Test) state->dataWindowAC->WindAC(EquipIndex).Name = EquipName; state->dataMixedAir->GetOAMixerInputFlag = false; check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, zoneEquipType); - if (check) { - EXPECT_EQ("SupplyNode10", SupplyNodeName); - EXPECT_EQ("ReturnNode10", ReturnNodeName); - } + EXPECT_TRUE(check); + EXPECT_EQ("SupplyNode10", SupplyNodeName); + EXPECT_EQ("ReturnNode10", ReturnNodeName); state->dataLoopNodes->NodeID(1) = "SupplyNode11"; state->dataLoopNodes->NodeID(2) = "ReturnNode11"; @@ -796,10 +786,9 @@ TEST_F(EnergyPlusFixture, RoomAirflowNetwork_CheckEquipName_Test) state->dataZoneDehumidifier->ZoneDehumid(EquipIndex).Name = EquipName; state->dataZoneDehumidifier->GetInputFlag = false; check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, zoneEquipType); - if (check) { - EXPECT_EQ("SupplyNode11", SupplyNodeName); - EXPECT_EQ("ReturnNode11", ReturnNodeName); - } + EXPECT_TRUE(check); + EXPECT_EQ("SupplyNode11", SupplyNodeName); + EXPECT_EQ("ReturnNode11", ReturnNodeName); state->dataLoopNodes->NodeID(1) = "SupplyNode12"; state->dataLoopNodes->NodeID(2) = "ReturnNode12"; @@ -811,10 +800,9 @@ TEST_F(EnergyPlusFixture, RoomAirflowNetwork_CheckEquipName_Test) state->dataPurchasedAirMgr->PurchAir(EquipIndex).Name = EquipName; state->dataPurchasedAirMgr->GetPurchAirInputFlag = false; check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, zoneEquipType); - if (check) { - EXPECT_EQ("SupplyNode12", SupplyNodeName); - EXPECT_EQ("ReturnNode12", ReturnNodeName); - } + EXPECT_TRUE(check); + EXPECT_EQ("SupplyNode12", SupplyNodeName); + EXPECT_EQ("ReturnNode12", ReturnNodeName); state->dataLoopNodes->NodeID(1) = "SupplyNode13"; state->dataLoopNodes->NodeID(2) = "ReturnNode13"; @@ -826,10 +814,9 @@ TEST_F(EnergyPlusFixture, RoomAirflowNetwork_CheckEquipName_Test) state->dataHybridUnitaryAC->ZoneHybridUnitaryAirConditioner(EquipIndex).Name = EquipName; state->dataHybridUnitaryAC->GetInputZoneHybridEvap = false; check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, zoneEquipType); - if (check) { - EXPECT_EQ("SupplyNode13", SupplyNodeName); - EXPECT_EQ("ReturnNode13", ReturnNodeName); - } + EXPECT_TRUE(check); + EXPECT_EQ("SupplyNode13", SupplyNodeName); + EXPECT_EQ("ReturnNode13", ReturnNodeName); state->dataLoopNodes->NodeID(1) = "SupplyNode14"; state->dataLoopNodes->NodeID(2) = "ReturnNode14"; @@ -841,8 +828,7 @@ TEST_F(EnergyPlusFixture, RoomAirflowNetwork_CheckEquipName_Test) state->dataWaterThermalTanks->HPWaterHeater(EquipIndex).Name = EquipName; state->dataWaterThermalTanks->getWaterThermalTankInputFlag = false; check = CheckEquipName(*state, EquipName, SupplyNodeName, ReturnNodeName, zoneEquipType); - if (check) { - EXPECT_EQ("SupplyNode14", SupplyNodeName); - EXPECT_EQ("ReturnNode14", ReturnNodeName); - } + EXPECT_TRUE(check); + EXPECT_EQ("SupplyNode14", SupplyNodeName); + EXPECT_EQ("ReturnNode14", ReturnNodeName); } From c5f39452edc4734dce7aec7d5e12c89aa1ea536c Mon Sep 17 00:00:00 2001 From: Rick Strand Date: Wed, 10 Jul 2024 16:16:29 -0500 Subject: [PATCH 29/57] 10299 Separation of Get and Process The previous version of GetShadowingInput obtained the ShadowCalculation input but then also did some processing. In order to solve #10299, these needed to be separated so that when surfaces are read in that it knows the ShadowCalculation input and thus can produce error messages appropriately. This commit separates the two parts of the previous routine into two routines which are now called at the appropriate places. The next step will be to implement the solution and create a unit test. --- src/EnergyPlus/HeatBalanceManager.cc | 2 ++ src/EnergyPlus/SolarShading.cc | 6 +++++- src/EnergyPlus/SolarShading.hh | 1 + tst/EnergyPlus/unit/SolarShading.unit.cc | 27 ++++++++++++------------ 4 files changed, 21 insertions(+), 15 deletions(-) diff --git a/src/EnergyPlus/HeatBalanceManager.cc b/src/EnergyPlus/HeatBalanceManager.cc index 1791b5b2895..b569d688d90 100644 --- a/src/EnergyPlus/HeatBalanceManager.cc +++ b/src/EnergyPlus/HeatBalanceManager.cc @@ -1967,6 +1967,8 @@ namespace HeatBalanceManager { // METHODOLOGY EMPLOYED: // The GetObjectItem routines are employed to retrieve the data. + SolarShading::GetShadowingInput(state); + GetZoneData(state, ErrorsFound); // Read Zone data from input file SurfaceGeometry::SetupZoneGeometry(state, ErrorsFound); diff --git a/src/EnergyPlus/SolarShading.cc b/src/EnergyPlus/SolarShading.cc index be6f9f9ebc4..4d2776e0156 100644 --- a/src/EnergyPlus/SolarShading.cc +++ b/src/EnergyPlus/SolarShading.cc @@ -196,7 +196,6 @@ void InitSolarCalculations(EnergyPlusData &state) if (state.dataSolarShading->GetInputFlag) { checkShadingSurfaceSchedules(state); - GetShadowingInput(state); processShadowingInput(state); state.dataSolarShading->GetInputFlag = false; state.dataSolarShading->MaxHCV = @@ -412,6 +411,11 @@ void GetShadowingInput(EnergyPlusData &state) using DataSystemVariables::ShadingMethod; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: + if (state.dataSolarShading->getShadowingCalculationInput) { + state.dataSolarShading->getShadowingCalculationInput = false; + } else { + return; + } int NumItems; int NumNumbers; int NumAlphas; diff --git a/src/EnergyPlus/SolarShading.hh b/src/EnergyPlus/SolarShading.hh index 5e3d62e5f41..bd466b327bf 100644 --- a/src/EnergyPlus/SolarShading.hh +++ b/src/EnergyPlus/SolarShading.hh @@ -437,6 +437,7 @@ struct SolarShadingData : BaseGlobalStruct #endif bool GetInputFlag = true; + bool getShadowingCalculationInput = true; bool anyScheduledShadingSurface = false; bool firstTime = true; bool debugging = false; diff --git a/tst/EnergyPlus/unit/SolarShading.unit.cc b/tst/EnergyPlus/unit/SolarShading.unit.cc index 7b168088659..d25e609a388 100644 --- a/tst/EnergyPlus/unit/SolarShading.unit.cc +++ b/tst/EnergyPlus/unit/SolarShading.unit.cc @@ -1461,6 +1461,8 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_DisableGroupSelfShading) HeatBalanceManager::GetConstructData(*state, FoundError); EXPECT_FALSE(FoundError); + SolarShading::GetShadowingInput(*state); + HeatBalanceManager::GetZoneData(*state, FoundError); // Read Zone data from input file EXPECT_FALSE(FoundError); @@ -1483,7 +1485,6 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_DisableGroupSelfShading) compare_err_stream(""); // just for debugging - SolarShading::GetShadowingInput(*state); SolarShading::processShadowingInput(*state); for (int SurfNum = 1; SurfNum <= state->dataSurface->TotSurfaces; SurfNum++) { @@ -3868,6 +3869,8 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_Warn_Pixel_Count_and_TM_Schedule) HeatBalanceManager::GetConstructData(*state, FoundError); EXPECT_FALSE(FoundError); + SolarShading::GetShadowingInput(*state); + HeatBalanceManager::GetZoneData(*state, FoundError); EXPECT_FALSE(FoundError); @@ -3890,11 +3893,11 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_Warn_Pixel_Count_and_TM_Schedule) EXPECT_EQ(state->dataSolarShading->anyScheduledShadingSurface, true); EXPECT_EQ(state->dataErrTracking->AskForSurfacesReport, true); - EXPECT_EQ(state->dataErrTracking->TotalWarningErrors, 0); + EXPECT_EQ(state->dataErrTracking->TotalWarningErrors, + 1); // with the rearrangement of code, one warning now gets produced in the shadow calculations // Expect no severe errors at this point EXPECT_EQ(state->dataErrTracking->TotalSevereErrors, 0); - SolarShading::GetShadowingInput(*state); SolarShading::processShadowingInput(*state); #ifdef EP_NO_OPENGL @@ -3902,17 +3905,9 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_Warn_Pixel_Count_and_TM_Schedule) EXPECT_EQ(state->dataErrTracking->TotalSevereErrors, 0); EXPECT_EQ(state->dataErrTracking->LastSevereError, ""); #else - if (!Penumbra::Penumbra::is_valid_context()) { - EXPECT_EQ(state->dataErrTracking->TotalWarningErrors, 1); - EXPECT_EQ(state->dataErrTracking->TotalSevereErrors, 0); - EXPECT_EQ(state->dataErrTracking->LastSevereError, ""); - } else { - EXPECT_EQ(state->dataErrTracking->TotalWarningErrors, 0); - // Now expect one severe error from GetShadowInput() - EXPECT_EQ(state->dataErrTracking->TotalSevereErrors, 1); - // There should be a severe warning reported about the PixelCounting and the scheduled shading surface tm values > 0.0 combination. - EXPECT_EQ(state->dataErrTracking->LastSevereError, "The Shading Calculation Method of choice is \"PixelCounting\"; "); - } + EXPECT_EQ(state->dataErrTracking->TotalWarningErrors, 1); + EXPECT_EQ(state->dataErrTracking->TotalSevereErrors, 0); + EXPECT_EQ(state->dataErrTracking->LastSevereError, ""); #endif } @@ -4180,6 +4175,8 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_PolygonOverlap) HeatBalanceManager::GetConstructData(*state, FoundError); EXPECT_FALSE(FoundError); + SolarShading::GetShadowingInput(*state); + HeatBalanceManager::GetZoneData(*state, FoundError); // Read Zone data from input file EXPECT_FALSE(FoundError); @@ -4202,6 +4199,8 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_PolygonOverlap) SurfaceGeometry::GetSurfaceData(*state, FoundError); // setup zone geometry and get zone data EXPECT_FALSE(FoundError); // expect no errors + SolarShading::processShadowingInput(*state); + // compare_err_stream( "" ); // just for debugging SurfaceGeometry::SetupZoneGeometry(*state, FoundError); // this calls GetSurfaceData() From eaf73f99d8cc6c94b160c0679e49f6f480e4f474 Mon Sep 17 00:00:00 2001 From: Rick Strand Date: Fri, 12 Jul 2024 14:21:39 -0500 Subject: [PATCH 30/57] 10299 Fix and Reverse Old Unit Fix to the problem. Testing reveals that the code now does what it is supposed to do. Also, reversed some changes to an existing unit test as the changes were causing some issues in the test suite. Hopefully this makes those issues disappear. --- src/EnergyPlus/SurfaceGeometry.cc | 7 ++++--- tst/EnergyPlus/unit/SolarShading.unit.cc | 14 ++++++++++---- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/src/EnergyPlus/SurfaceGeometry.cc b/src/EnergyPlus/SurfaceGeometry.cc index c8191fa36c2..09b60d6a98f 100644 --- a/src/EnergyPlus/SurfaceGeometry.cc +++ b/src/EnergyPlus/SurfaceGeometry.cc @@ -68,6 +68,7 @@ #include #include #include +#include #include #include #include @@ -15680,9 +15681,9 @@ namespace SurfaceGeometry { if (SignFlag != PrevSignFlag) { if (state.dataGlobal->DisplayExtraWarnings && surfaceTmp.ExtSolar && - (state.dataHeatBal->SolarDistribution != DataHeatBalance::Shadowing::Minimal) && - // Warn only once - surfaceTmp.IsConvex) { + (state.dataHeatBal->SolarDistribution != DataHeatBalance::Shadowing::Minimal) && surfaceTmp.IsConvex && + !state.dataSysVars->SutherlandHodgman && + (state.dataSysVars->shadingMethod == DataSystemVariables::ShadingMethod::PolygonClipping)) { ShowWarningError(state, format("CheckConvexity: Zone=\"{}\", Surface=\"{}\" is non-convex.", state.dataHeatBal->Zone(surfaceTmp.Zone).Name, diff --git a/tst/EnergyPlus/unit/SolarShading.unit.cc b/tst/EnergyPlus/unit/SolarShading.unit.cc index d25e609a388..20591d52914 100644 --- a/tst/EnergyPlus/unit/SolarShading.unit.cc +++ b/tst/EnergyPlus/unit/SolarShading.unit.cc @@ -3901,13 +3901,19 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_Warn_Pixel_Count_and_TM_Schedule) SolarShading::processShadowingInput(*state); #ifdef EP_NO_OPENGL - EXPECT_EQ(state->dataErrTracking->TotalWarningErrors, 1); + EXPECT_EQ(state->dataErrTracking->TotalWarningErrors, 2); EXPECT_EQ(state->dataErrTracking->TotalSevereErrors, 0); EXPECT_EQ(state->dataErrTracking->LastSevereError, ""); #else - EXPECT_EQ(state->dataErrTracking->TotalWarningErrors, 1); - EXPECT_EQ(state->dataErrTracking->TotalSevereErrors, 0); - EXPECT_EQ(state->dataErrTracking->LastSevereError, ""); + if (!Penumbra::Penumbra::is_valid_context()) { + EXPECT_EQ(state->dataErrTracking->TotalWarningErrors, 2); + EXPECT_EQ(state->dataErrTracking->TotalSevereErrors, 0); + EXPECT_EQ(state->dataErrTracking->LastSevereError, ""); + } else { + EXPECT_EQ(state->dataErrTracking->TotalWarningErrors, 1); + EXPECT_EQ(state->dataErrTracking->TotalSevereErrors, 0); + EXPECT_EQ(state->dataErrTracking->LastSevereError, ""); + } #endif } From 4a504167e2f50bb0474b932bfd575fb1f20da5dc Mon Sep 17 00:00:00 2001 From: Rick Strand Date: Fri, 12 Jul 2024 18:31:17 -0500 Subject: [PATCH 31/57] 10299 Unit Test and Fixes Addition of new unit tests and fixes to the one that doesn't work properly for Windows (experimental solution based on surrounding code). If this works, this is a potential pull request version. --- tst/EnergyPlus/unit/SolarShading.unit.cc | 214 ++++++++++++++++++++++- 1 file changed, 212 insertions(+), 2 deletions(-) diff --git a/tst/EnergyPlus/unit/SolarShading.unit.cc b/tst/EnergyPlus/unit/SolarShading.unit.cc index 20591d52914..68f5b573a56 100644 --- a/tst/EnergyPlus/unit/SolarShading.unit.cc +++ b/tst/EnergyPlus/unit/SolarShading.unit.cc @@ -3893,11 +3893,19 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_Warn_Pixel_Count_and_TM_Schedule) EXPECT_EQ(state->dataSolarShading->anyScheduledShadingSurface, true); EXPECT_EQ(state->dataErrTracking->AskForSurfacesReport, true); - EXPECT_EQ(state->dataErrTracking->TotalWarningErrors, - 1); // with the rearrangement of code, one warning now gets produced in the shadow calculations // Expect no severe errors at this point EXPECT_EQ(state->dataErrTracking->TotalSevereErrors, 0); +#ifdef EP_NO_OPENGL + EXPECT_EQ(state->dataErrTracking->TotalWarningErrors, 2); +#else + if (!Penumbra::Penumbra::is_valid_context()) { + EXPECT_EQ(state->dataErrTracking->TotalWarningErrors, 2); + } else { + EXPECT_EQ(state->dataErrTracking->TotalWarningErrors, 1); + } +#endif + SolarShading::processShadowingInput(*state); #ifdef EP_NO_OPENGL @@ -5954,3 +5962,205 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_CalcInteriorSolarDistribution_EQL) EXPECT_NEAR(0.0, state->dataHeatBalSurf->SurfWinInitialDifSolInTrans(windowSurfNum), 0.01); EXPECT_NEAR(1.4736, state->dataHeatBalSurf->SurfWinInitialDifSolInTrans(windowSurfNum2), 0.01); } + +TEST_F(EnergyPlusFixture, SolarShadingTest_GetShadowingInputTest1) +{ + // Tests for Defect #10299: Test GetShadowingInput for various combinations of input + // with a focus put on the correct setting of variables associated with calculation + // method and polygon clipping algorithm + std::string const idf_objects = delimited_string({ + " ShadowCalculation,", + " PolygonClipping, !- Shading Calculation Method", + " Timestep, !- Shading Calculation Update Frequency Method", + " 1, !- Shading Calculation Update Frequency", + " 200, !- Maximum Figures in Shadow Overlap Calculations", + " ConvexWeilerAtherton, !- Polygon Clipping Algorithm", + " 512.0, !- Pixel Counting Resolution", + " DetailedSkyDiffuseModeling; !- Sky Diffuse Modeling Algorithm", + }); + + ASSERT_TRUE(process_idf(idf_objects)); + + state->dataSolarShading->anyScheduledShadingSurface = false; + + // Test 1 of 6: Polygon Clipping and ConvexWeilerAtherton + SolarShading::GetShadowingInput(*state); + int expectedFrequency = 1; + int expectedOverlaps = 200; + EXPECT_TRUE(state->dataSysVars->DetailedSkyDiffuseAlgorithm); + EXPECT_TRUE(state->dataSysVars->DetailedSolarTimestepIntegration); + EXPECT_EQ(expectedFrequency, state->dataSolarShading->ShadowingCalcFrequency); + EXPECT_EQ(expectedOverlaps, state->dataSolarShading->MaxHCS); + EXPECT_FALSE(state->dataSysVars->SutherlandHodgman); + EXPECT_FALSE(state->dataSysVars->SlaterBarsky); + EXPECT_EQ(state->dataSysVars->shadingMethod, ShadingMethod::PolygonClipping); +} + +TEST_F(EnergyPlusFixture, SolarShadingTest_GetShadowingInputTest2) +{ + // Tests for Defect #10299: Test GetShadowingInput for various combinations of input + // with a focus put on the correct setting of variables associated with calculation + // method and polygon clipping algorithm + std::string const idf_objects = delimited_string({ + " ShadowCalculation,", + " PolygonClipping, !- Shading Calculation Method", + " Periodic, !- Shading Calculation Update Frequency Method", + " 10, !- Shading Calculation Update Frequency", + " 2000, !- Maximum Figures in Shadow Overlap Calculations", + " SutherlandHodgman, !- Polygon Clipping Algorithm", + " 512.0, !- Pixel Counting Resolution", + " SimpleSkyDiffuseModeling; !- Sky Diffuse Modeling Algorithm", + }); + + ASSERT_TRUE(process_idf(idf_objects)); + + state->dataSolarShading->anyScheduledShadingSurface = false; + + // Test 2 of 6: Polygon Clipping and SutherlandHodgman + SolarShading::GetShadowingInput(*state); + int expectedFrequency = 10; + int expectedOverlaps = 2000; + EXPECT_FALSE(state->dataSysVars->DetailedSkyDiffuseAlgorithm); + EXPECT_FALSE(state->dataSysVars->DetailedSolarTimestepIntegration); + EXPECT_EQ(expectedFrequency, state->dataSolarShading->ShadowingCalcFrequency); + EXPECT_EQ(expectedOverlaps, state->dataSolarShading->MaxHCS); + EXPECT_TRUE(state->dataSysVars->SutherlandHodgman); + EXPECT_FALSE(state->dataSysVars->SlaterBarsky); + EXPECT_EQ(state->dataSysVars->shadingMethod, ShadingMethod::PolygonClipping); +} + +TEST_F(EnergyPlusFixture, SolarShadingTest_GetShadowingInputTest3) +{ + // Tests for Defect #10299: Test GetShadowingInput for various combinations of input + // with a focus put on the correct setting of variables associated with calculation + // method and polygon clipping algorithm + std::string const idf_objects = delimited_string({ + " ShadowCalculation,", + " PolygonClipping, !- Shading Calculation Method", + " Timestep, !- Shading Calculation Update Frequency Method", + " 30, !- Shading Calculation Update Frequency", + " 15000, !- Maximum Figures in Shadow Overlap Calculations", + " SlaterBarskyandSutherlandHodgman, !- Polygon Clipping Algorithm", + " 512.0, !- Pixel Counting Resolution", + " DetailedSkyDiffuseModeling; !- Sky Diffuse Modeling Algorithm", + }); + + ASSERT_TRUE(process_idf(idf_objects)); + + state->dataSolarShading->anyScheduledShadingSurface = false; + + // Test 3 of 6: Polygon Clipping and SlaterBarskyandSutherlandHodgman + SolarShading::GetShadowingInput(*state); + int expectedFrequency = 30; + int expectedOverlaps = 15000; + EXPECT_TRUE(state->dataSysVars->DetailedSkyDiffuseAlgorithm); + EXPECT_TRUE(state->dataSysVars->DetailedSolarTimestepIntegration); + EXPECT_EQ(expectedFrequency, state->dataSolarShading->ShadowingCalcFrequency); + EXPECT_EQ(expectedOverlaps, state->dataSolarShading->MaxHCS); + EXPECT_TRUE(state->dataSysVars->SutherlandHodgman); + EXPECT_TRUE(state->dataSysVars->SlaterBarsky); + EXPECT_EQ(state->dataSysVars->shadingMethod, ShadingMethod::PolygonClipping); +} + +TEST_F(EnergyPlusFixture, SolarShadingTest_GetShadowingInputTest4) +{ + // Tests for Defect #10299: Test GetShadowingInput for various combinations of input + // with a focus put on the correct setting of variables associated with calculation + // method and polygon clipping algorithm + std::string const idf_objects = delimited_string({ + " ShadowCalculation,", + " PixelCounting, !- Shading Calculation Method", + " Periodic, !- Shading Calculation Update Frequency Method", + " 1, !- Shading Calculation Update Frequency", + " 200, !- Maximum Figures in Shadow Overlap Calculations", + " ConvexWeilerAtherton, !- Polygon Clipping Algorithm", + " 512.0, !- Pixel Counting Resolution", + " DetailedSkyDiffuseModeling; !- Sky Diffuse Modeling Algorithm", + }); + + ASSERT_TRUE(process_idf(idf_objects)); + + state->dataSolarShading->anyScheduledShadingSurface = false; + + // Test 4 of 6: Pixel Counting and ConvexWeilerAtherton + SolarShading::GetShadowingInput(*state); + int expectedFrequency = 1; + int expectedOverlaps = 200; + EXPECT_TRUE(state->dataSysVars->DetailedSkyDiffuseAlgorithm); + EXPECT_FALSE(state->dataSysVars->DetailedSolarTimestepIntegration); + EXPECT_EQ(expectedFrequency, state->dataSolarShading->ShadowingCalcFrequency); + EXPECT_EQ(expectedOverlaps, state->dataSolarShading->MaxHCS); + EXPECT_FALSE(state->dataSysVars->SutherlandHodgman); + EXPECT_FALSE(state->dataSysVars->SlaterBarsky); + EXPECT_EQ(state->dataSysVars->shadingMethod, ShadingMethod::PixelCounting); +} + +TEST_F(EnergyPlusFixture, SolarShadingTest_GetShadowingInputTest5) +{ + // Tests for Defect #10299: Test GetShadowingInput for various combinations of input + // with a focus put on the correct setting of variables associated with calculation + // method and polygon clipping algorithm + std::string const idf_objects = delimited_string({ + " ShadowCalculation,", + " PixelCounting, !- Shading Calculation Method", + " Periodic, !- Shading Calculation Update Frequency Method", + " 10, !- Shading Calculation Update Frequency", + " 2000, !- Maximum Figures in Shadow Overlap Calculations", + " SutherlandHodgman, !- Polygon Clipping Algorithm", + " 512.0, !- Pixel Counting Resolution", + " DetailedSkyDiffuseModeling; !- Sky Diffuse Modeling Algorithm", + }); + + ASSERT_TRUE(process_idf(idf_objects)); + + state->dataSolarShading->anyScheduledShadingSurface = false; + + // Test 5 of 6: Pixel Counting and SutherlandHodgman + SolarShading::GetShadowingInput(*state); + int expectedFrequency = 10; + int expectedOverlaps = 2000; + EXPECT_TRUE(state->dataSysVars->DetailedSkyDiffuseAlgorithm); + EXPECT_FALSE(state->dataSysVars->DetailedSolarTimestepIntegration); + EXPECT_EQ(expectedFrequency, state->dataSolarShading->ShadowingCalcFrequency); + EXPECT_EQ(expectedOverlaps, state->dataSolarShading->MaxHCS); + EXPECT_TRUE(state->dataSysVars->SutherlandHodgman); + EXPECT_FALSE(state->dataSysVars->SlaterBarsky); + EXPECT_EQ(state->dataSysVars->shadingMethod, ShadingMethod::PixelCounting); +} + +TEST_F(EnergyPlusFixture, SolarShadingTest_GetShadowingInputTest6) +{ + // Tests for Defect #10299: Test GetShadowingInput for various combinations of input + // with a focus put on the correct setting of variables associated with calculation + // method and polygon clipping algorithm + std::string const idf_objects = delimited_string({ + " ShadowCalculation,", + " PixelCounting, !- Shading Calculation Method", + " Periodic, !- Shading Calculation Update Frequency Method", + " 56, !- Shading Calculation Update Frequency", + " 1234, !- Maximum Figures in Shadow Overlap Calculations", + " SlaterBarskyandSutherlandHodgman, !- Polygon Clipping Algorithm", + " 512.0, !- Pixel Counting Resolution", + " SimpleSkyDiffuseModeling; !- Sky Diffuse Modeling Algorithm", + }); + + ASSERT_TRUE(process_idf(idf_objects)); + + state->dataSolarShading->anyScheduledShadingSurface = false; + + // Test 36of 6: Pixel Counting and SlaterBarskyandSutherlandHodgman + SolarShading::GetShadowingInput(*state); + + int expectedFrequency = 56; + int expectedOverlaps = 1234; + EXPECT_FALSE(state->dataSysVars->DetailedSkyDiffuseAlgorithm); + EXPECT_FALSE(state->dataSysVars->DetailedSolarTimestepIntegration); + EXPECT_EQ(expectedFrequency, state->dataSolarShading->ShadowingCalcFrequency); + EXPECT_EQ(expectedOverlaps, state->dataSolarShading->MaxHCS); + EXPECT_TRUE(state->dataSysVars->SutherlandHodgman); + EXPECT_TRUE(state->dataSysVars->SlaterBarsky); + EXPECT_EQ(state->dataSysVars->shadingMethod, ShadingMethod::PixelCounting); + std::string const error_string = delimited_string({" ** Warning ** ShadowCalculation: suspect Shading Calculation Update Frequency", + " ** ~~~ ** Value entered=[56], Shadowing Calculations will be inaccurate."}); + EXPECT_TRUE(compare_err_stream(error_string, true)); +} From 608530e8fd40fb6a79e8dfc0f5ef508db9ea261a Mon Sep 17 00:00:00 2001 From: Rick Strand Date: Fri, 12 Jul 2024 21:55:21 -0500 Subject: [PATCH 32/57] 10299 Unit Test Change Backup Backed out something that was tried but resulted in more issues. --- tst/EnergyPlus/unit/SolarShading.unit.cc | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/tst/EnergyPlus/unit/SolarShading.unit.cc b/tst/EnergyPlus/unit/SolarShading.unit.cc index 68f5b573a56..123369cd2d7 100644 --- a/tst/EnergyPlus/unit/SolarShading.unit.cc +++ b/tst/EnergyPlus/unit/SolarShading.unit.cc @@ -3893,19 +3893,10 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_Warn_Pixel_Count_and_TM_Schedule) EXPECT_EQ(state->dataSolarShading->anyScheduledShadingSurface, true); EXPECT_EQ(state->dataErrTracking->AskForSurfacesReport, true); + EXPECT_EQ(state->dataErrTracking->TotalWarningErrors, 1); // Expect no severe errors at this point EXPECT_EQ(state->dataErrTracking->TotalSevereErrors, 0); -#ifdef EP_NO_OPENGL - EXPECT_EQ(state->dataErrTracking->TotalWarningErrors, 2); -#else - if (!Penumbra::Penumbra::is_valid_context()) { - EXPECT_EQ(state->dataErrTracking->TotalWarningErrors, 2); - } else { - EXPECT_EQ(state->dataErrTracking->TotalWarningErrors, 1); - } -#endif - SolarShading::processShadowingInput(*state); #ifdef EP_NO_OPENGL From 0719aba796923e4253fe7edfa625ff9cbc600308 Mon Sep 17 00:00:00 2001 From: Lixing Gu Date: Mon, 15 Jul 2024 09:48:19 -0400 Subject: [PATCH 33/57] Revise GetIndex functions --- src/EnergyPlus/FanCoilUnits.cc | 8 ++-- src/EnergyPlus/FanCoilUnits.hh | 2 +- src/EnergyPlus/HVACStandAloneERV.cc | 9 ++-- src/EnergyPlus/HVACStandAloneERV.hh | 2 +- src/EnergyPlus/HVACVariableRefrigerantFlow.cc | 9 ++-- src/EnergyPlus/HVACVariableRefrigerantFlow.hh | 2 +- .../HybridUnitaryAirConditioners.cc | 9 ++-- .../HybridUnitaryAirConditioners.hh | 2 +- src/EnergyPlus/OutdoorAirUnit.cc | 8 ++-- src/EnergyPlus/OutdoorAirUnit.hh | 2 +- src/EnergyPlus/PurchasedAirManager.cc | 8 ++-- src/EnergyPlus/PurchasedAirManager.hh | 2 +- src/EnergyPlus/RoomAirModelManager.cc | 45 ++++++++++++------- src/EnergyPlus/UnitHeater.cc | 9 ++-- src/EnergyPlus/UnitHeater.hh | 2 +- src/EnergyPlus/UnitVentilator.cc | 8 ++-- src/EnergyPlus/UnitVentilator.hh | 2 +- src/EnergyPlus/UnitarySystem.cc | 10 ++--- src/EnergyPlus/UnitarySystem.hh | 1 - src/EnergyPlus/VentilatedSlab.cc | 8 ++-- src/EnergyPlus/VentilatedSlab.hh | 2 +- src/EnergyPlus/WaterThermalTanks.cc | 8 ++-- src/EnergyPlus/WaterThermalTanks.hh | 2 +- src/EnergyPlus/WindowAC.cc | 8 ++-- src/EnergyPlus/WindowAC.hh | 2 +- src/EnergyPlus/ZoneDehumidifier.cc | 8 ++-- src/EnergyPlus/ZoneDehumidifier.hh | 2 +- 27 files changed, 83 insertions(+), 97 deletions(-) diff --git a/src/EnergyPlus/FanCoilUnits.cc b/src/EnergyPlus/FanCoilUnits.cc index 1e05e8f7056..7c27178d74f 100644 --- a/src/EnergyPlus/FanCoilUnits.cc +++ b/src/EnergyPlus/FanCoilUnits.cc @@ -4419,23 +4419,21 @@ namespace FanCoilUnits { } } - int getEqIndex(EnergyPlusData &state, std::string_view CompName, bool &errFlag) + int getEqIndex(EnergyPlusData &state, std::string_view CompName) { if (state.dataFanCoilUnits->GetFanCoilInputFlag) { GetFanCoilUnits(state); state.dataFanCoilUnits->GetFanCoilInputFlag = false; } - int EquipIndex = 0; for (int FanCoilIndex = 1; FanCoilIndex <= state.dataFanCoilUnits->NumFanCoils; ++FanCoilIndex) { auto &fanCoil = state.dataFanCoilUnits->FanCoil(FanCoilIndex); if (Util::SameString(fanCoil.Name, CompName)) { - EquipIndex = FanCoilIndex; + return FanCoilIndex; } } - if (EquipIndex == 0) errFlag = true; - return EquipIndex; + return 0; } } // namespace FanCoilUnits diff --git a/src/EnergyPlus/FanCoilUnits.hh b/src/EnergyPlus/FanCoilUnits.hh index 29027338d5e..68983667875 100644 --- a/src/EnergyPlus/FanCoilUnits.hh +++ b/src/EnergyPlus/FanCoilUnits.hh @@ -380,7 +380,7 @@ namespace FanCoilUnits { int WaterControlNode, Real64 MinWaterFlow); - int getEqIndex(EnergyPlusData &state, std::string_view CompName, bool &errFlag); + int getEqIndex(EnergyPlusData &state, std::string_view CompName); } // namespace FanCoilUnits struct FanCoilUnitsData : BaseGlobalStruct diff --git a/src/EnergyPlus/HVACStandAloneERV.cc b/src/EnergyPlus/HVACStandAloneERV.cc index 70a45717c66..15438f65487 100644 --- a/src/EnergyPlus/HVACStandAloneERV.cc +++ b/src/EnergyPlus/HVACStandAloneERV.cc @@ -1685,23 +1685,20 @@ bool GetStandAloneERVNodeNumber(EnergyPlusData &state, int const NodeNumber) return false; } -int getEqIndex(EnergyPlusData &state, std::string_view CompName, bool &errFlag) +int getEqIndex(EnergyPlusData &state, std::string_view CompName) { if (state.dataHVACStandAloneERV->GetERVInputFlag) { GetStandAloneERV(state); state.dataHVACStandAloneERV->GetERVInputFlag = false; } - int EqIndex = 0; - for (int StandAloneERVNum = 1; StandAloneERVNum <= state.dataHVACStandAloneERV->NumStandAloneERVs; StandAloneERVNum++) { if (Util::SameString(CompName, state.dataHVACStandAloneERV->StandAloneERV(StandAloneERVNum).Name)) { - EqIndex = StandAloneERVNum; + return StandAloneERVNum; break; } } - if (EqIndex == 0) errFlag = true; - return EqIndex; + return 0; } } // namespace EnergyPlus::HVACStandAloneERV diff --git a/src/EnergyPlus/HVACStandAloneERV.hh b/src/EnergyPlus/HVACStandAloneERV.hh index 665ae2f00fb..382cbea51bb 100644 --- a/src/EnergyPlus/HVACStandAloneERV.hh +++ b/src/EnergyPlus/HVACStandAloneERV.hh @@ -186,7 +186,7 @@ namespace HVACStandAloneERV { bool GetStandAloneERVNodeNumber(EnergyPlusData &state, int NodeNumber); - int getEqIndex(EnergyPlusData &state, std::string_view CompName, bool &errFlag); + int getEqIndex(EnergyPlusData &state, std::string_view CompName); } // namespace HVACStandAloneERV diff --git a/src/EnergyPlus/HVACVariableRefrigerantFlow.cc b/src/EnergyPlus/HVACVariableRefrigerantFlow.cc index 9e2dbe24869..6199ffb605a 100644 --- a/src/EnergyPlus/HVACVariableRefrigerantFlow.cc +++ b/src/EnergyPlus/HVACVariableRefrigerantFlow.cc @@ -10761,22 +10761,19 @@ int GetVRFTUReturnAirNode(EnergyPlusData &state, int const VRFTUNum) } } -int getEqIndex(EnergyPlusData &state, std::string_view VRFTUName, bool &errFlag) +int getEqIndex(EnergyPlusData &state, std::string_view VRFTUName) { if (state.dataHVACVarRefFlow->GetVRFInputFlag) { GetVRFInput(state); state.dataHVACVarRefFlow->GetVRFInputFlag = false; } - int EqIndex = 0; for (int VRFTUNum = 1; VRFTUNum <= state.dataHVACVarRefFlow->NumVRFTU; VRFTUNum++) { if (Util::SameString(VRFTUName, state.dataHVACVarRefFlow->VRFTU(VRFTUNum).Name)) { - EqIndex = VRFTUNum; - break; + return VRFTUNum; } } - if (EqIndex == 0) errFlag = true; - return EqIndex; + return 0; } void getVRFTUZoneLoad( diff --git a/src/EnergyPlus/HVACVariableRefrigerantFlow.hh b/src/EnergyPlus/HVACVariableRefrigerantFlow.hh index bfef04ef8ed..71e60fa8ea7 100644 --- a/src/EnergyPlus/HVACVariableRefrigerantFlow.hh +++ b/src/EnergyPlus/HVACVariableRefrigerantFlow.hh @@ -974,7 +974,7 @@ namespace HVACVariableRefrigerantFlow { Real64 const T_suc // Compressor suction temperature Te' [C] ); - int getEqIndex(EnergyPlusData &state, std::string_view VRFTUName, bool &errFlag); + int getEqIndex(EnergyPlusData &state, std::string_view VRFTUName); } // namespace HVACVariableRefrigerantFlow diff --git a/src/EnergyPlus/HybridUnitaryAirConditioners.cc b/src/EnergyPlus/HybridUnitaryAirConditioners.cc index 50069e27aee..53b21ca0716 100644 --- a/src/EnergyPlus/HybridUnitaryAirConditioners.cc +++ b/src/EnergyPlus/HybridUnitaryAirConditioners.cc @@ -1366,22 +1366,21 @@ int GetHybridUnitaryACReturnAirNode(EnergyPlusData &state, int const CompNum) return GetHybridUnitaryACReturnAirNode; } -int getHybridUnitaryACIndex(EnergyPlusData &state, std::string_view CompName, bool &errFlag) +int getHybridUnitaryACIndex(EnergyPlusData &state, std::string_view CompName) { + bool errFlag = false; if (state.dataHybridUnitaryAC->GetInputZoneHybridEvap) { GetInputZoneHybridUnitaryAirConditioners(state, errFlag); state.dataHybridUnitaryAC->GetInputZoneHybridEvap = false; } - int EquipIndex = 0; for (int UnitLoop = 1; UnitLoop <= state.dataHybridUnitaryAC->NumZoneHybridEvap; ++UnitLoop) { if (Util::SameString(state.dataHybridUnitaryAC->ZoneHybridUnitaryAirConditioner(UnitLoop).Name, CompName)) { - EquipIndex = UnitLoop; + return UnitLoop; } } - if (EquipIndex == 0) errFlag = true; - return EquipIndex; + return 0; } //***************************************************************************************** diff --git a/src/EnergyPlus/HybridUnitaryAirConditioners.hh b/src/EnergyPlus/HybridUnitaryAirConditioners.hh index 1ba96080b7d..c93210bcff9 100644 --- a/src/EnergyPlus/HybridUnitaryAirConditioners.hh +++ b/src/EnergyPlus/HybridUnitaryAirConditioners.hh @@ -98,7 +98,7 @@ namespace HybridUnitaryAirConditioners { int GetHybridUnitaryACReturnAirNode(EnergyPlusData &state, int UnitNum); - int getHybridUnitaryACIndex(EnergyPlusData &state, std::string_view CompName, bool &errFlag); + int getHybridUnitaryACIndex(EnergyPlusData &state, std::string_view CompName); } // namespace HybridUnitaryAirConditioners diff --git a/src/EnergyPlus/OutdoorAirUnit.cc b/src/EnergyPlus/OutdoorAirUnit.cc index 4d993fdde39..153fa01875b 100644 --- a/src/EnergyPlus/OutdoorAirUnit.cc +++ b/src/EnergyPlus/OutdoorAirUnit.cc @@ -2471,22 +2471,20 @@ namespace OutdoorAirUnit { return GetOutdoorAirUnitReturnAirNode; } - int getOutdoorAirUnitEqIndex(EnergyPlusData &state, std::string_view EquipName, bool &errFlag) + int getOutdoorAirUnitEqIndex(EnergyPlusData &state, std::string_view EquipName) { if (state.dataOutdoorAirUnit->GetOutdoorAirUnitInputFlag) { OutdoorAirUnit::GetOutdoorAirUnitInputs(state); state.dataOutdoorAirUnit->GetOutdoorAirUnitInputFlag = false; } - int EquipIndex = 0; for (int OAUnitNum = 1; OAUnitNum <= state.dataOutdoorAirUnit->NumOfOAUnits; ++OAUnitNum) { if (Util::SameString(state.dataOutdoorAirUnit->OutAirUnit(OAUnitNum).Name, EquipName)) { - EquipIndex = OAUnitNum; + return OAUnitNum; } } - if (EquipIndex == 0) errFlag = true; - return EquipIndex; + return 0; } } // namespace OutdoorAirUnit diff --git a/src/EnergyPlus/OutdoorAirUnit.hh b/src/EnergyPlus/OutdoorAirUnit.hh index 2115f4c770b..977c9c4f3fc 100644 --- a/src/EnergyPlus/OutdoorAirUnit.hh +++ b/src/EnergyPlus/OutdoorAirUnit.hh @@ -310,7 +310,7 @@ namespace OutdoorAirUnit { int GetOutdoorAirUnitReturnAirNode(EnergyPlusData &state, int OAUnitNum); - int getOutdoorAirUnitEqIndex(EnergyPlusData &state, std::string_view EquipName, bool &errFlag); + int getOutdoorAirUnitEqIndex(EnergyPlusData &state, std::string_view EquipName); } // namespace OutdoorAirUnit struct OutdoorAirUnitData : BaseGlobalStruct diff --git a/src/EnergyPlus/PurchasedAirManager.cc b/src/EnergyPlus/PurchasedAirManager.cc index e3b58a930da..3fd4bf0c89d 100644 --- a/src/EnergyPlus/PurchasedAirManager.cc +++ b/src/EnergyPlus/PurchasedAirManager.cc @@ -3318,22 +3318,20 @@ int GetPurchasedAirReturnAirNode(EnergyPlusData &state, int const PurchAirNum) return GetPurchasedAirReturnAirNode; } -int getPurchasedAirIndex(EnergyPlusData &state, std::string_view PurchAirName, bool &errFlag) +int getPurchasedAirIndex(EnergyPlusData &state, std::string_view PurchAirName) { if (state.dataPurchasedAirMgr->GetPurchAirInputFlag) { GetPurchasedAir(state); state.dataPurchasedAirMgr->GetPurchAirInputFlag = false; } - int EquipIndex = 0; for (int PurchAirNum = 1; PurchAirNum <= state.dataPurchasedAirMgr->NumPurchAir; ++PurchAirNum) { if (Util::SameString(state.dataPurchasedAirMgr->PurchAir(PurchAirNum).Name, PurchAirName)) { - EquipIndex = PurchAirNum; + return PurchAirNum; } } - if (EquipIndex == 0) errFlag = true; - return EquipIndex; + return 0; } Real64 GetPurchasedAirMixedAirTemp(EnergyPlusData &state, int const PurchAirNum) diff --git a/src/EnergyPlus/PurchasedAirManager.hh b/src/EnergyPlus/PurchasedAirManager.hh index a3abb8f515c..d8c7ee1c36d 100644 --- a/src/EnergyPlus/PurchasedAirManager.hh +++ b/src/EnergyPlus/PurchasedAirManager.hh @@ -379,7 +379,7 @@ namespace PurchasedAirManager { int GetPurchasedAirReturnAirNode(EnergyPlusData &state, int PurchAirNum); - int getPurchasedAirIndex(EnergyPlusData &state, std::string_view PurchAirName, bool &errFlag); + int getPurchasedAirIndex(EnergyPlusData &state, std::string_view PurchAirName); Real64 GetPurchasedAirMixedAirTemp(EnergyPlusData &state, int PurchAirNum); diff --git a/src/EnergyPlus/RoomAirModelManager.cc b/src/EnergyPlus/RoomAirModelManager.cc index 7b8c40f8ed6..8c890593867 100644 --- a/src/EnergyPlus/RoomAirModelManager.cc +++ b/src/EnergyPlus/RoomAirModelManager.cc @@ -2723,55 +2723,66 @@ namespace RoomAir { switch (zoneEquipType) { case DataZoneEquipment::ZoneEquipType::VariableRefrigerantFlowTerminal: { // ZoneHVAC:TerminalUnit : VariableRefrigerantFlow - EquipIndex = HVACVariableRefrigerantFlow::getEqIndex(state, EquipName, errorfound); + EquipIndex = HVACVariableRefrigerantFlow::getEqIndex(state, EquipName); + if (EquipIndex == 0) return EquipFind; SupplyNodeNum = state.dataHVACVarRefFlow->VRFTU(EquipIndex).VRFTUOutletNodeNum; } break; case DataZoneEquipment::ZoneEquipType::EnergyRecoveryVentilator: { // ZoneHVAC : EnergyRecoveryVentilator - EquipIndex = HVACStandAloneERV::getEqIndex(state, EquipName, errorfound); + EquipIndex = HVACStandAloneERV::getEqIndex(state, EquipName); + if (EquipIndex == 0) return EquipFind; SupplyNodeNum = state.dataHVACStandAloneERV->StandAloneERV(EquipIndex).SupplyAirInletNode; } break; case DataZoneEquipment::ZoneEquipType::FourPipeFanCoil: { // ZoneHVAC : FourPipeFanCoil - EquipIndex = FanCoilUnits::getEqIndex(state, EquipName, errorfound); + EquipIndex = FanCoilUnits::getEqIndex(state, EquipName); + if (EquipIndex == 0) return EquipFind; SupplyNodeNum = state.dataFanCoilUnits->FanCoil(EquipIndex).AirOutNode; ReturnNodeNum = state.dataFanCoilUnits->FanCoil(EquipIndex).AirInNode; } break; case DataZoneEquipment::ZoneEquipType::OutdoorAirUnit: { // ZoneHVAC : OutdoorAirUnit - EquipIndex = OutdoorAirUnit::getOutdoorAirUnitEqIndex(state, EquipName, errorfound); + EquipIndex = OutdoorAirUnit::getOutdoorAirUnitEqIndex(state, EquipName); + if (EquipIndex == 0) return EquipFind; SupplyNodeNum = state.dataOutdoorAirUnit->OutAirUnit(EquipIndex).AirOutletNode; ReturnNodeNum = state.dataOutdoorAirUnit->OutAirUnit(EquipIndex).AirInletNode; } break; case DataZoneEquipment::ZoneEquipType::PackagedTerminalAirConditioner: { // ZoneHVAC : PackagedTerminalAirConditioner - EquipIndex = UnitarySystems::getZoneEqIndex(state, EquipName, zoneEquipType, errorfound); + EquipIndex = UnitarySystems::getZoneEqIndex(state, EquipName, zoneEquipType); + if (EquipIndex == -1) return EquipFind; SupplyNodeNum = state.dataUnitarySystems->unitarySys[EquipIndex].AirOutNode; ReturnNodeNum = state.dataUnitarySystems->unitarySys[EquipIndex].AirInNode; } break; case DataZoneEquipment::ZoneEquipType::PackagedTerminalHeatPump: { // ZoneHVAC : PackagedTerminalHeatPump - EquipIndex = UnitarySystems::getZoneEqIndex(state, EquipName, zoneEquipType, errorfound); + EquipIndex = UnitarySystems::getZoneEqIndex(state, EquipName, zoneEquipType); + if (EquipIndex == -1) return EquipFind; SupplyNodeNum = state.dataUnitarySystems->unitarySys[EquipIndex].AirOutNode; ReturnNodeNum = state.dataUnitarySystems->unitarySys[EquipIndex].AirInNode; } break; case DataZoneEquipment::ZoneEquipType::UnitHeater: { // ZoneHVAC : UnitHeater - EquipIndex = UnitHeater::getUnitHeaterIndex(state, EquipName, errorfound); + EquipIndex = UnitHeater::getUnitHeaterIndex(state, EquipName); + if (EquipIndex == 0) return EquipFind; ReturnNodeNum = state.dataUnitHeaters->UnitHeat(EquipIndex).AirInNode; SupplyNodeNum = state.dataUnitHeaters->UnitHeat(EquipIndex).AirOutNode; } break; case DataZoneEquipment::ZoneEquipType::UnitVentilator: { // ZoneHVAC : UnitVentilator - EquipIndex = UnitVentilator::getUnitVentilatorIndex(state, EquipName, errorfound); + EquipIndex = UnitVentilator::getUnitVentilatorIndex(state, EquipName); + if (EquipIndex == 0) return EquipFind; ReturnNodeNum = state.dataUnitVentilators->UnitVent(EquipIndex).AirInNode; SupplyNodeNum = state.dataUnitVentilators->UnitVent(EquipIndex).AirOutNode; } break; case DataZoneEquipment::ZoneEquipType::VentilatedSlab: { // ZoneHVAC : VentilatedSlab - EquipIndex = VentilatedSlab::getVentilatedSlabIndex(state, EquipName, errorfound); + EquipIndex = VentilatedSlab::getVentilatedSlabIndex(state, EquipName); + if (EquipIndex == 0) return EquipFind; ReturnNodeNum = state.dataVentilatedSlab->VentSlab(EquipIndex).ReturnAirNode; SupplyNodeNum = state.dataVentilatedSlab->VentSlab(EquipIndex).ZoneAirInNode; } break; case DataZoneEquipment::ZoneEquipType::PackagedTerminalHeatPumpWaterToAir: { // ZoneHVAC : WaterToAirHeatPump - EquipIndex = UnitarySystems::getZoneEqIndex(state, EquipName, zoneEquipType, errorfound); + EquipIndex = UnitarySystems::getZoneEqIndex(state, EquipName, zoneEquipType); + if (EquipIndex == -1) return EquipFind; SupplyNodeNum = state.dataUnitarySystems->unitarySys[EquipIndex].AirOutNode; ReturnNodeNum = state.dataUnitarySystems->unitarySys[EquipIndex].AirInNode; } break; case DataZoneEquipment::ZoneEquipType::WindowAirConditioner: { // ZoneHVAC : WindowAirConditioner - EquipIndex = WindowAC::getWindowACIndex(state, EquipName, errorfound); + EquipIndex = WindowAC::getWindowACIndex(state, EquipName); + if (EquipIndex == 0) return EquipFind; ReturnNodeNum = state.dataWindowAC->WindAC(EquipIndex).AirInNode; SupplyNodeNum = state.dataWindowAC->WindAC(EquipIndex).AirOutNode; } break; @@ -2800,12 +2811,14 @@ namespace RoomAir { SupplyNodeName = ""; } break; case DataZoneEquipment::ZoneEquipType::DehumidifierDX: { // ZoneHVAC : Dehumidifier : DX - EquipIndex = ZoneDehumidifier::getZoneDehumidifierIndex(state, EquipName, errorfound); + EquipIndex = ZoneDehumidifier::getZoneDehumidifierIndex(state, EquipName); + if (EquipIndex == 0) return EquipFind; ReturnNodeNum = state.dataZoneDehumidifier->ZoneDehumid(EquipIndex).AirInletNodeNum; SupplyNodeNum = state.dataZoneDehumidifier->ZoneDehumid(EquipIndex).AirOutletNodeNum; } break; case DataZoneEquipment::ZoneEquipType::PurchasedAir: { // ZoneHVAC : IdealLoadsAirSystem - EquipIndex = PurchasedAirManager::getPurchasedAirIndex(state, EquipName, errorfound); + EquipIndex = PurchasedAirManager::getPurchasedAirIndex(state, EquipName); + if (EquipIndex == 0) return EquipFind; ReturnNodeNum = state.dataPurchasedAirMgr->PurchAir(EquipIndex).ZoneExhaustAirNodeNum; SupplyNodeNum = state.dataPurchasedAirMgr->PurchAir(EquipIndex).ZoneSupplyAirNodeNum; } break; @@ -2815,7 +2828,8 @@ namespace RoomAir { // ReturnNodeName = Alphas(4); } break; case DataZoneEquipment::ZoneEquipType::HybridEvaporativeCooler: { // ZoneHVAC : HybridUnitaryAirConditioners - EquipIndex = HybridUnitaryAirConditioners::getHybridUnitaryACIndex(state, EquipName, errorfound); + EquipIndex = HybridUnitaryAirConditioners::getHybridUnitaryACIndex(state, EquipName); + if (EquipIndex == 0) return EquipFind; ReturnNodeNum = state.dataHybridUnitaryAC->ZoneHybridUnitaryAirConditioner(EquipIndex).InletNode; SupplyNodeNum = state.dataHybridUnitaryAC->ZoneHybridUnitaryAirConditioner(EquipIndex).OutletNode; } break; @@ -2824,7 +2838,8 @@ namespace RoomAir { // SupplyNodeName = ""; // ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? May not use } break; case DataZoneEquipment::ZoneEquipType::HeatPumpWaterHeater: { // WaterHeater : HeatPump - EquipIndex = WaterThermalTanks::getHeatPumpWaterHeaterIndex(state, EquipName, errorfound); + EquipIndex = WaterThermalTanks::getHeatPumpWaterHeaterIndex(state, EquipName); + if (EquipIndex == 0) return EquipFind; ReturnNodeNum = state.dataWaterThermalTanks->HPWaterHeater(EquipIndex).HeatPumpAirInletNode; SupplyNodeNum = state.dataWaterThermalTanks->HPWaterHeater(EquipIndex).HeatPumpAirOutletNode; // For AirTerminals, find matching return node later diff --git a/src/EnergyPlus/UnitHeater.cc b/src/EnergyPlus/UnitHeater.cc index e1ced26febe..ab65383c24d 100644 --- a/src/EnergyPlus/UnitHeater.cc +++ b/src/EnergyPlus/UnitHeater.cc @@ -1894,21 +1894,20 @@ namespace UnitHeater { } } - int getUnitHeaterIndex(EnergyPlusData &state, std::string_view CompName, bool &errFlag) + int getUnitHeaterIndex(EnergyPlusData &state, std::string_view CompName) { if (state.dataUnitHeaters->GetUnitHeaterInputFlag) { GetUnitHeaterInput(state); state.dataUnitHeaters->GetUnitHeaterInputFlag = false; } - int EquipIndex = 0; + for (int UnitHeatNum = 1; UnitHeatNum <= state.dataUnitHeaters->NumOfUnitHeats; ++UnitHeatNum) { if (Util::SameString(state.dataUnitHeaters->UnitHeat(UnitHeatNum).Name, CompName)) { - EquipIndex = UnitHeatNum; + return UnitHeatNum; } } - if (EquipIndex == 0) errFlag = true; - return EquipIndex; + return 0; } } // namespace UnitHeater diff --git a/src/EnergyPlus/UnitHeater.hh b/src/EnergyPlus/UnitHeater.hh index cdba6ccda1e..d0a95f1011e 100644 --- a/src/EnergyPlus/UnitHeater.hh +++ b/src/EnergyPlus/UnitHeater.hh @@ -202,7 +202,7 @@ namespace UnitHeater { void ReportUnitHeater(EnergyPlusData &state, int const UnitHeatNum); // Unit index in unit heater array - int getUnitHeaterIndex(EnergyPlusData &state, std::string_view CompName, bool &errFlag); + int getUnitHeaterIndex(EnergyPlusData &state, std::string_view CompName); } // namespace UnitHeater struct UnitHeatersData : BaseGlobalStruct diff --git a/src/EnergyPlus/UnitVentilator.cc b/src/EnergyPlus/UnitVentilator.cc index e12e922e7a4..3d9352d8a1a 100644 --- a/src/EnergyPlus/UnitVentilator.cc +++ b/src/EnergyPlus/UnitVentilator.cc @@ -3365,21 +3365,19 @@ namespace UnitVentilator { return GetUnitVentilatorReturnAirNode; } - int getUnitVentilatorIndex(EnergyPlusData &state, std::string_view CompName, bool &errFlag) + int getUnitVentilatorIndex(EnergyPlusData &state, std::string_view CompName) { if (state.dataUnitVentilators->GetUnitVentilatorInputFlag) { GetUnitVentilatorInput(state); state.dataUnitVentilators->GetUnitVentilatorInputFlag = false; } - int EquipIndex = 0; for (int UnitVentNum = 1; UnitVentNum <= state.dataUnitVentilators->NumOfUnitVents; ++UnitVentNum) { if (Util::SameString(state.dataUnitVentilators->UnitVent(UnitVentNum).Name, CompName)) { - EquipIndex = UnitVentNum; + return UnitVentNum; } } - if (EquipIndex == 0) errFlag = true; - return EquipIndex; + return 0; } Real64 SetOAMassFlowRateForCoolingVariablePercent(EnergyPlusData &state, diff --git a/src/EnergyPlus/UnitVentilator.hh b/src/EnergyPlus/UnitVentilator.hh index 97822f24d09..2dada2c6b8f 100644 --- a/src/EnergyPlus/UnitVentilator.hh +++ b/src/EnergyPlus/UnitVentilator.hh @@ -262,7 +262,7 @@ namespace UnitVentilator { int GetUnitVentilatorReturnAirNode(EnergyPlusData &state, int const UnitVentNum); - int getUnitVentilatorIndex(EnergyPlusData &state, std::string_view CompName, bool &errFlag); + int getUnitVentilatorIndex(EnergyPlusData &state, std::string_view CompName); Real64 SetOAMassFlowRateForCoolingVariablePercent(EnergyPlusData &state, int const UnitVentNum, // Unit Ventilator index number diff --git a/src/EnergyPlus/UnitarySystem.cc b/src/EnergyPlus/UnitarySystem.cc index 3feee353b20..22f8ca3c664 100644 --- a/src/EnergyPlus/UnitarySystem.cc +++ b/src/EnergyPlus/UnitarySystem.cc @@ -16574,8 +16574,7 @@ namespace UnitarySystems { return airNode; } - int getZoneEqIndex( - EnergyPlusData &state, std::string const &UnitarySysName, DataZoneEquipment::ZoneEquipType zoneEquipType, bool &errFlag, int const OAUnitNum) + int getZoneEqIndex(EnergyPlusData &state, std::string const &UnitarySysName, DataZoneEquipment::ZoneEquipType zoneEquipType, int const OAUnitNum) { if (state.dataUnitarySystems->getInputOnceFlag) { @@ -16583,20 +16582,17 @@ namespace UnitarySystems { state.dataUnitarySystems->getInputOnceFlag = false; } - int EquipIndex = -1; 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 || zoneEquipType == DataZoneEquipment::ZoneEquipType::UnitarySystem) { - EquipIndex = UnitarySysNum; - break; + return UnitarySysNum; } } } - if (EquipIndex < 0) errFlag = true; - return EquipIndex; + return -1; } int UnitarySys::getAirOutNode(EnergyPlusData &state, std::string_view UnitarySysName, int const ZoneOAUnitNum, bool &errFlag) diff --git a/src/EnergyPlus/UnitarySystem.hh b/src/EnergyPlus/UnitarySystem.hh index 7572c556e4b..d1036eef855 100644 --- a/src/EnergyPlus/UnitarySystem.hh +++ b/src/EnergyPlus/UnitarySystem.hh @@ -969,7 +969,6 @@ namespace UnitarySystems { int getZoneEqIndex(EnergyPlusData &state, std::string const &UnitarySysName, DataZoneEquipment::ZoneEquipType zoneEquipType, - bool &errFlag, int const OAUnitNum = 0); } // namespace UnitarySystems diff --git a/src/EnergyPlus/VentilatedSlab.cc b/src/EnergyPlus/VentilatedSlab.cc index 1de17f5c2e0..396d604b928 100644 --- a/src/EnergyPlus/VentilatedSlab.cc +++ b/src/EnergyPlus/VentilatedSlab.cc @@ -4762,22 +4762,20 @@ namespace VentilatedSlab { } } - int getVentilatedSlabIndex(EnergyPlusData &state, std::string_view CompName, bool &errFlag) + int getVentilatedSlabIndex(EnergyPlusData &state, std::string_view CompName) { if (state.dataVentilatedSlab->GetInputFlag) { GetVentilatedSlabInput(state); state.dataVentilatedSlab->GetInputFlag = false; } - int EquipIndex = 0; for (int VentSlabNum = 1; VentSlabNum <= state.dataVentilatedSlab->NumOfVentSlabs; ++VentSlabNum) { if (Util::SameString(state.dataVentilatedSlab->VentSlab(VentSlabNum).Name, CompName)) { - EquipIndex = VentSlabNum; + return VentSlabNum; } } - if (EquipIndex == 0) errFlag = true; - return EquipIndex; + return 0; } //***************************************************************************************** diff --git a/src/EnergyPlus/VentilatedSlab.hh b/src/EnergyPlus/VentilatedSlab.hh index 43dcf328ba5..7d2437567aa 100644 --- a/src/EnergyPlus/VentilatedSlab.hh +++ b/src/EnergyPlus/VentilatedSlab.hh @@ -383,7 +383,7 @@ namespace VentilatedSlab { void ReportVentilatedSlab(EnergyPlusData &state, int const Item); // Index for the ventilated slab under consideration within the derived types - int getVentilatedSlabIndex(EnergyPlusData &state, std::string_view CompName, bool &errFlag); + int getVentilatedSlabIndex(EnergyPlusData &state, std::string_view CompName); //***************************************************************************************** } // namespace VentilatedSlab diff --git a/src/EnergyPlus/WaterThermalTanks.cc b/src/EnergyPlus/WaterThermalTanks.cc index e0b2b075c45..797bf7b5e14 100644 --- a/src/EnergyPlus/WaterThermalTanks.cc +++ b/src/EnergyPlus/WaterThermalTanks.cc @@ -12464,22 +12464,20 @@ bool GetHeatPumpWaterHeaterNodeNumber(EnergyPlusData &state, int const NodeNumbe return HeatPumpWaterHeaterNodeException; } -int getHeatPumpWaterHeaterIndex(EnergyPlusData &state, std::string_view CompName, bool &errFlag) +int getHeatPumpWaterHeaterIndex(EnergyPlusData &state, std::string_view CompName) { if (state.dataWaterThermalTanks->getWaterThermalTankInputFlag) { GetWaterThermalTankInput(state); state.dataWaterThermalTanks->getWaterThermalTankInputFlag = false; } - int EquipIndex = 0; for (int HPNum = 1; HPNum <= state.dataWaterThermalTanks->numHeatPumpWaterHeater; ++HPNum) { if (Util::SameString(state.dataWaterThermalTanks->HPWaterHeater(HPNum).Name, CompName)) { - EquipIndex = HPNum; + return HPNum; } } - if (EquipIndex == 0) errFlag = true; - return EquipIndex; + return 0; } } // namespace EnergyPlus::WaterThermalTanks diff --git a/src/EnergyPlus/WaterThermalTanks.hh b/src/EnergyPlus/WaterThermalTanks.hh index a64c6c46e16..db9657f0809 100644 --- a/src/EnergyPlus/WaterThermalTanks.hh +++ b/src/EnergyPlus/WaterThermalTanks.hh @@ -991,7 +991,7 @@ namespace WaterThermalTanks { bool GetHeatPumpWaterHeaterNodeNumber(EnergyPlusData &state, int NodeNumber); - int getHeatPumpWaterHeaterIndex(EnergyPlusData &state, std::string_view CompName, bool &errFlag); + int getHeatPumpWaterHeaterIndex(EnergyPlusData &state, std::string_view CompName); } // namespace WaterThermalTanks diff --git a/src/EnergyPlus/WindowAC.cc b/src/EnergyPlus/WindowAC.cc index 9d405e13750..29d26ebe298 100644 --- a/src/EnergyPlus/WindowAC.cc +++ b/src/EnergyPlus/WindowAC.cc @@ -1619,22 +1619,20 @@ namespace WindowAC { return GetWindowACMixedAirNode; } - int getWindowACIndex(EnergyPlusData &state, std::string_view CompName, bool &errFlag) + int getWindowACIndex(EnergyPlusData &state, std::string_view CompName) { if (state.dataWindowAC->GetWindowACInputFlag) { GetWindowAC(state); state.dataWindowAC->GetWindowACInputFlag = false; } - int EquipIndex = 0; for (int WindACIndex = 1; WindACIndex <= state.dataWindowAC->NumWindAC; ++WindACIndex) { if (Util::SameString(state.dataWindowAC->WindAC(WindACIndex).Name, CompName)) { - EquipIndex = WindACIndex; + return WindACIndex; } } - if (EquipIndex == 0) errFlag = true; - return EquipIndex; + return 0; } } // namespace WindowAC diff --git a/src/EnergyPlus/WindowAC.hh b/src/EnergyPlus/WindowAC.hh index 4a61d04e164..81db5207b14 100644 --- a/src/EnergyPlus/WindowAC.hh +++ b/src/EnergyPlus/WindowAC.hh @@ -205,7 +205,7 @@ namespace WindowAC { int GetWindowACMixedAirNode(EnergyPlusData &state, int const WindACNum); - int getWindowACIndex(EnergyPlusData &state, std::string_view CompName, bool &errFlag); + int getWindowACIndex(EnergyPlusData &state, std::string_view CompName); } // namespace WindowAC diff --git a/src/EnergyPlus/ZoneDehumidifier.cc b/src/EnergyPlus/ZoneDehumidifier.cc index 0eafa52b1ab..95ec5aa25d2 100644 --- a/src/EnergyPlus/ZoneDehumidifier.cc +++ b/src/EnergyPlus/ZoneDehumidifier.cc @@ -1179,22 +1179,20 @@ namespace ZoneDehumidifier { return FindZoneDehumidifierNodeNumber; } - int getZoneDehumidifierIndex(EnergyPlusData &state, std::string_view CompName, bool &errFlag) + int getZoneDehumidifierIndex(EnergyPlusData &state, std::string_view CompName) { if (state.dataZoneDehumidifier->GetInputFlag) { GetZoneDehumidifierInput(state); state.dataZoneDehumidifier->GetInputFlag = false; } - int EquipIndex = 0; for (int ZoneDehumidNum = 1; ZoneDehumidNum <= (int)state.dataZoneDehumidifier->ZoneDehumid.size(); ++ZoneDehumidNum) { if (Util::SameString(state.dataZoneDehumidifier->ZoneDehumid(ZoneDehumidNum).Name, CompName)) { - EquipIndex = ZoneDehumidNum; + return ZoneDehumidNum; } } - if (EquipIndex == 0) errFlag = true; - return EquipIndex; + return 0; } } // namespace ZoneDehumidifier diff --git a/src/EnergyPlus/ZoneDehumidifier.hh b/src/EnergyPlus/ZoneDehumidifier.hh index 7232d040b29..1e62add786d 100644 --- a/src/EnergyPlus/ZoneDehumidifier.hh +++ b/src/EnergyPlus/ZoneDehumidifier.hh @@ -153,7 +153,7 @@ namespace ZoneDehumidifier { bool GetZoneDehumidifierNodeNumber(EnergyPlusData &state, int NodeNumber); // Node being tested - int getZoneDehumidifierIndex(EnergyPlusData &state, std::string_view CompName, bool &errFlag); + int getZoneDehumidifierIndex(EnergyPlusData &state, std::string_view CompName); } // namespace ZoneDehumidifier From 5059ae9cabf2ec07eb8f59111b6a2f5b7b1259c5 Mon Sep 17 00:00:00 2001 From: Lixing Gu Date: Mon, 15 Jul 2024 10:30:44 -0400 Subject: [PATCH 34/57] Clang format --- src/EnergyPlus/UnitarySystem.hh | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/EnergyPlus/UnitarySystem.hh b/src/EnergyPlus/UnitarySystem.hh index d1036eef855..287bd57cac3 100644 --- a/src/EnergyPlus/UnitarySystem.hh +++ b/src/EnergyPlus/UnitarySystem.hh @@ -966,10 +966,8 @@ namespace UnitarySystems { void setupAllOutputVars(EnergyPlusData &state, int const numAllSystemTypes); void isWaterCoilHeatRecoveryType(EnergyPlusData const &state, int const waterCoilNodeNum, bool &nodeNotFound); - int getZoneEqIndex(EnergyPlusData &state, - std::string const &UnitarySysName, - DataZoneEquipment::ZoneEquipType zoneEquipType, - int const OAUnitNum = 0); + int + getZoneEqIndex(EnergyPlusData &state, std::string const &UnitarySysName, DataZoneEquipment::ZoneEquipType zoneEquipType, int const OAUnitNum = 0); } // namespace UnitarySystems struct UnitarySystemsData : BaseGlobalStruct From a9572ac3fdacb0778e704e85592d152174e54c63 Mon Sep 17 00:00:00 2001 From: Edwin Lee Date: Mon, 15 Jul 2024 12:01:02 -0500 Subject: [PATCH 35/57] Refactor some mixer code into methods --- src/EnergyPlus/MixedAir.cc | 142 +++++++++++++++++-------------------- src/EnergyPlus/MixedAir.hh | 133 ++++++++++++---------------------- 2 files changed, 113 insertions(+), 162 deletions(-) diff --git a/src/EnergyPlus/MixedAir.cc b/src/EnergyPlus/MixedAir.cc index 5d01eff5164..79d6c26c6df 100644 --- a/src/EnergyPlus/MixedAir.cc +++ b/src/EnergyPlus/MixedAir.cc @@ -758,11 +758,13 @@ void SimOAMixer(EnergyPlusData &state, std::string const &CompName, int &CompInd OAMixerNum = CompIndex; } - InitOAMixer(state, OAMixerNum); + auto &mixer = state.dataMixedAir->OAMixer(OAMixerNum); - CalcOAMixer(state, OAMixerNum); + mixer.InitOAMixer(state); - UpdateOAMixer(state, OAMixerNum); + mixer.CalcOAMixer(state); + + mixer.UpdateOAMixer(state); } void SimOAController(EnergyPlusData &state, std::string const &CtrlName, int &CtrlIndex, bool const FirstHVACIteration, int const AirLoopNum) @@ -3291,7 +3293,7 @@ void InitOAController(EnergyPlusData &state, int const OAControllerNum, bool con } } // namespace MixedAir -void InitOAMixer(EnergyPlusData &state, int const OAMixerNum) +void OAMixerProps::InitOAMixer(EnergyPlusData &state) { // SUBROUTINE INFORMATION: // AUTHOR Fred Buhl @@ -3300,24 +3302,24 @@ void InitOAMixer(EnergyPlusData &state, int const OAMixerNum) // PURPOSE OF THIS SUBROUTINE // Initialize the OAMixer data structure with input node data - int RetNode = state.dataMixedAir->OAMixer(OAMixerNum).RetNode; - int InletNode = state.dataMixedAir->OAMixer(OAMixerNum).InletNode; - int RelNode = state.dataMixedAir->OAMixer(OAMixerNum).RelNode; + int RetNode = this->RetNode; + int InletNode = this->InletNode; + int RelNode = this->RelNode; // Return air stream data - state.dataMixedAir->OAMixer(OAMixerNum).RetTemp = state.dataLoopNodes->Node(RetNode).Temp; - state.dataMixedAir->OAMixer(OAMixerNum).RetHumRat = state.dataLoopNodes->Node(RetNode).HumRat; - state.dataMixedAir->OAMixer(OAMixerNum).RetEnthalpy = state.dataLoopNodes->Node(RetNode).Enthalpy; - state.dataMixedAir->OAMixer(OAMixerNum).RetPressure = state.dataLoopNodes->Node(RetNode).Press; - state.dataMixedAir->OAMixer(OAMixerNum).RetMassFlowRate = state.dataLoopNodes->Node(RetNode).MassFlowRate; + this->RetTemp = state.dataLoopNodes->Node(RetNode).Temp; + this->RetHumRat = state.dataLoopNodes->Node(RetNode).HumRat; + this->RetEnthalpy = state.dataLoopNodes->Node(RetNode).Enthalpy; + this->RetPressure = state.dataLoopNodes->Node(RetNode).Press; + this->RetMassFlowRate = state.dataLoopNodes->Node(RetNode).MassFlowRate; // Outside air stream data - state.dataMixedAir->OAMixer(OAMixerNum).OATemp = state.dataLoopNodes->Node(InletNode).Temp; - state.dataMixedAir->OAMixer(OAMixerNum).OAHumRat = state.dataLoopNodes->Node(InletNode).HumRat; - state.dataMixedAir->OAMixer(OAMixerNum).OAEnthalpy = state.dataLoopNodes->Node(InletNode).Enthalpy; - state.dataMixedAir->OAMixer(OAMixerNum).OAPressure = state.dataLoopNodes->Node(InletNode).Press; - state.dataMixedAir->OAMixer(OAMixerNum).OAMassFlowRate = state.dataLoopNodes->Node(InletNode).MassFlowRate; + this->OATemp = state.dataLoopNodes->Node(InletNode).Temp; + this->OAHumRat = state.dataLoopNodes->Node(InletNode).HumRat; + this->OAEnthalpy = state.dataLoopNodes->Node(InletNode).Enthalpy; + this->OAPressure = state.dataLoopNodes->Node(InletNode).Press; + this->OAMassFlowRate = state.dataLoopNodes->Node(InletNode).MassFlowRate; // Relief air data - state.dataMixedAir->OAMixer(OAMixerNum).RelMassFlowRate = state.dataLoopNodes->Node(RelNode).MassFlowRate; + this->RelMassFlowRate = state.dataLoopNodes->Node(RelNode).MassFlowRate; } void OAControllerProps::CalcOAController(EnergyPlusData &state, int const AirLoopNum, bool const FirstHVACIteration) @@ -4630,7 +4632,8 @@ void OAControllerProps::CalcOAEconomizer(EnergyPlusData &state, this->HighHumCtrlActive = false; } } -void CalcOAMixer(EnergyPlusData &state, int const OAMixerNum) + +void OAMixerProps::CalcOAMixer(EnergyPlusData &state) { // SUBROUTINE INFORMATION: @@ -4641,56 +4644,45 @@ void CalcOAMixer(EnergyPlusData &state, int const OAMixerNum) // Calculate the mixed air flow and conditions // Define a recirculation mass flow rate - Real64 RecircMassFlowRate = state.dataMixedAir->OAMixer(OAMixerNum).RetMassFlowRate - state.dataMixedAir->OAMixer(OAMixerNum).RelMassFlowRate; + Real64 RecircMassFlowRate = this->RetMassFlowRate - this->RelMassFlowRate; // In certain low flow conditions the return air mass flow rate can be below the outside air value established // by the user. This check will ensure that this condition does not result in unphysical air properties. if (RecircMassFlowRate < 0.0) { RecircMassFlowRate = 0.0; - state.dataMixedAir->OAMixer(OAMixerNum).RelMassFlowRate = state.dataMixedAir->OAMixer(OAMixerNum).RetMassFlowRate; + this->RelMassFlowRate = this->RetMassFlowRate; } // Pass through the return air conditions to the relief air stream. The return air is "split" to // the relief air and the recirculation air. - state.dataMixedAir->OAMixer(OAMixerNum).RelTemp = state.dataMixedAir->OAMixer(OAMixerNum).RetTemp; - state.dataMixedAir->OAMixer(OAMixerNum).RelHumRat = state.dataMixedAir->OAMixer(OAMixerNum).RetHumRat; - state.dataMixedAir->OAMixer(OAMixerNum).RelEnthalpy = state.dataMixedAir->OAMixer(OAMixerNum).RetEnthalpy; - state.dataMixedAir->OAMixer(OAMixerNum).RelPressure = state.dataMixedAir->OAMixer(OAMixerNum).RetPressure; - Real64 RecircPressure = state.dataMixedAir->OAMixer(OAMixerNum).RetPressure; - Real64 RecircEnthalpy = state.dataMixedAir->OAMixer(OAMixerNum).RetEnthalpy; - Real64 RecircHumRat = state.dataMixedAir->OAMixer(OAMixerNum).RetHumRat; + this->RelTemp = this->RetTemp; + this->RelHumRat = this->RetHumRat; + this->RelEnthalpy = this->RetEnthalpy; + this->RelPressure = this->RetPressure; + Real64 RecircPressure = this->RetPressure; + Real64 RecircEnthalpy = this->RetEnthalpy; + Real64 RecircHumRat = this->RetHumRat; // The recirculation air and the outside air are mixed to form the mixed air stream - state.dataMixedAir->OAMixer(OAMixerNum).MixMassFlowRate = state.dataMixedAir->OAMixer(OAMixerNum).OAMassFlowRate + RecircMassFlowRate; + this->MixMassFlowRate = this->OAMassFlowRate + RecircMassFlowRate; // Check for zero flow - if (state.dataMixedAir->OAMixer(OAMixerNum).MixMassFlowRate <= HVAC::VerySmallMassFlow) { - state.dataMixedAir->OAMixer(OAMixerNum).MixEnthalpy = state.dataMixedAir->OAMixer(OAMixerNum).RetEnthalpy; - state.dataMixedAir->OAMixer(OAMixerNum).MixHumRat = state.dataMixedAir->OAMixer(OAMixerNum).RetHumRat; - state.dataMixedAir->OAMixer(OAMixerNum).MixPressure = state.dataMixedAir->OAMixer(OAMixerNum).RetPressure; - state.dataMixedAir->OAMixer(OAMixerNum).MixTemp = state.dataMixedAir->OAMixer(OAMixerNum).RetTemp; + if (this->MixMassFlowRate <= HVAC::VerySmallMassFlow) { + this->MixEnthalpy = this->RetEnthalpy; + this->MixHumRat = this->RetHumRat; + this->MixPressure = this->RetPressure; + this->MixTemp = this->RetTemp; return; } - state.dataMixedAir->OAMixer(OAMixerNum).MixEnthalpy = - (RecircMassFlowRate * RecircEnthalpy + - state.dataMixedAir->OAMixer(OAMixerNum).OAMassFlowRate * state.dataMixedAir->OAMixer(OAMixerNum).OAEnthalpy) / - state.dataMixedAir->OAMixer(OAMixerNum).MixMassFlowRate; - state.dataMixedAir->OAMixer(OAMixerNum).MixHumRat = (RecircMassFlowRate * RecircHumRat + state.dataMixedAir->OAMixer(OAMixerNum).OAMassFlowRate * - state.dataMixedAir->OAMixer(OAMixerNum).OAHumRat) / - state.dataMixedAir->OAMixer(OAMixerNum).MixMassFlowRate; - state.dataMixedAir->OAMixer(OAMixerNum).MixPressure = - (RecircMassFlowRate * RecircPressure + - state.dataMixedAir->OAMixer(OAMixerNum).OAMassFlowRate * state.dataMixedAir->OAMixer(OAMixerNum).OAPressure) / - state.dataMixedAir->OAMixer(OAMixerNum).MixMassFlowRate; + this->MixEnthalpy = (RecircMassFlowRate * RecircEnthalpy + this->OAMassFlowRate * this->OAEnthalpy) / this->MixMassFlowRate; + this->MixHumRat = (RecircMassFlowRate * RecircHumRat + this->OAMassFlowRate * this->OAHumRat) / this->MixMassFlowRate; + this->MixPressure = (RecircMassFlowRate * RecircPressure + this->OAMassFlowRate * this->OAPressure) / this->MixMassFlowRate; // Mixed air temperature is calculated from the mixed air enthalpy and humidity ratio. - state.dataMixedAir->OAMixer(OAMixerNum).MixTemp = - Psychrometrics::PsyTdbFnHW(state.dataMixedAir->OAMixer(OAMixerNum).MixEnthalpy, state.dataMixedAir->OAMixer(OAMixerNum).MixHumRat); + this->MixTemp = Psychrometrics::PsyTdbFnHW(this->MixEnthalpy, this->MixHumRat); // Check for saturation temperature > dry-bulb temperature and modify temperature at constant enthalpy - Real64 T_sat = - Psychrometrics::PsyTsatFnHPb(state, state.dataMixedAir->OAMixer(OAMixerNum).MixEnthalpy, state.dataMixedAir->OAMixer(OAMixerNum).MixPressure); - if (state.dataMixedAir->OAMixer(OAMixerNum).MixTemp < T_sat) { - state.dataMixedAir->OAMixer(OAMixerNum).MixTemp = T_sat; - state.dataMixedAir->OAMixer(OAMixerNum).MixHumRat = - Psychrometrics::PsyWFnTdbH(state, T_sat, state.dataMixedAir->OAMixer(OAMixerNum).MixEnthalpy); + Real64 T_sat = Psychrometrics::PsyTsatFnHPb(state, this->MixEnthalpy, this->MixPressure); + if (this->MixTemp < T_sat) { + this->MixTemp = T_sat; + this->MixHumRat = Psychrometrics::PsyWFnTdbH(state, T_sat, this->MixEnthalpy); } } @@ -4880,7 +4872,7 @@ void OAControllerProps::UpdateOAController(EnergyPlusData &state) } } -void UpdateOAMixer(EnergyPlusData &state, int const OAMixerNum) +void OAMixerProps::UpdateOAMixer(EnergyPlusData &state) const { // SUBROUTINE INFORMATION: @@ -4891,47 +4883,47 @@ void UpdateOAMixer(EnergyPlusData &state, int const OAMixerNum) // Move the results of CalcOAMixer to the affected nodes // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - int MixNode = state.dataMixedAir->OAMixer(OAMixerNum).MixNode; - int RelNode = state.dataMixedAir->OAMixer(OAMixerNum).RelNode; - int RetNode = state.dataMixedAir->OAMixer(OAMixerNum).RetNode; + int MixNode = this->MixNode; + int RelNode = this->RelNode; + int RetNode = this->RetNode; // Move mixed air data to the mixed air node - state.dataLoopNodes->Node(MixNode).MassFlowRate = state.dataMixedAir->OAMixer(OAMixerNum).MixMassFlowRate; - state.dataLoopNodes->Node(MixNode).Temp = state.dataMixedAir->OAMixer(OAMixerNum).MixTemp; - state.dataLoopNodes->Node(MixNode).HumRat = state.dataMixedAir->OAMixer(OAMixerNum).MixHumRat; - state.dataLoopNodes->Node(MixNode).Enthalpy = state.dataMixedAir->OAMixer(OAMixerNum).MixEnthalpy; - state.dataLoopNodes->Node(MixNode).Press = state.dataMixedAir->OAMixer(OAMixerNum).MixPressure; - state.dataLoopNodes->Node(MixNode).MassFlowRateMaxAvail = state.dataMixedAir->OAMixer(OAMixerNum).MixMassFlowRate; + state.dataLoopNodes->Node(MixNode).MassFlowRate = this->MixMassFlowRate; + state.dataLoopNodes->Node(MixNode).Temp = this->MixTemp; + state.dataLoopNodes->Node(MixNode).HumRat = this->MixHumRat; + state.dataLoopNodes->Node(MixNode).Enthalpy = this->MixEnthalpy; + state.dataLoopNodes->Node(MixNode).Press = this->MixPressure; + state.dataLoopNodes->Node(MixNode).MassFlowRateMaxAvail = this->MixMassFlowRate; // Move the relief air data to the relief air node - state.dataLoopNodes->Node(RelNode).MassFlowRate = state.dataMixedAir->OAMixer(OAMixerNum).RelMassFlowRate; - state.dataLoopNodes->Node(RelNode).Temp = state.dataMixedAir->OAMixer(OAMixerNum).RelTemp; - state.dataLoopNodes->Node(RelNode).HumRat = state.dataMixedAir->OAMixer(OAMixerNum).RelHumRat; - state.dataLoopNodes->Node(RelNode).Enthalpy = state.dataMixedAir->OAMixer(OAMixerNum).RelEnthalpy; - state.dataLoopNodes->Node(RelNode).Press = state.dataMixedAir->OAMixer(OAMixerNum).RelPressure; - state.dataLoopNodes->Node(RelNode).MassFlowRateMaxAvail = state.dataMixedAir->OAMixer(OAMixerNum).RelMassFlowRate; + state.dataLoopNodes->Node(RelNode).MassFlowRate = this->RelMassFlowRate; + state.dataLoopNodes->Node(RelNode).Temp = this->RelTemp; + state.dataLoopNodes->Node(RelNode).HumRat = this->RelHumRat; + state.dataLoopNodes->Node(RelNode).Enthalpy = this->RelEnthalpy; + state.dataLoopNodes->Node(RelNode).Press = this->RelPressure; + state.dataLoopNodes->Node(RelNode).MassFlowRateMaxAvail = this->RelMassFlowRate; if (state.dataContaminantBalance->Contaminant.CO2Simulation) { state.dataLoopNodes->Node(RelNode).CO2 = state.dataLoopNodes->Node(RetNode).CO2; - if (state.dataMixedAir->OAMixer(OAMixerNum).MixMassFlowRate <= HVAC::VerySmallMassFlow) { + if (this->MixMassFlowRate <= HVAC::VerySmallMassFlow) { state.dataLoopNodes->Node(MixNode).CO2 = state.dataLoopNodes->Node(RetNode).CO2; } else { state.dataLoopNodes->Node(MixNode).CO2 = ((state.dataLoopNodes->Node(RetNode).MassFlowRate - state.dataLoopNodes->Node(RelNode).MassFlowRate) * state.dataLoopNodes->Node(RetNode).CO2 + - state.dataMixedAir->OAMixer(OAMixerNum).OAMassFlowRate * state.dataContaminantBalance->OutdoorCO2) / - state.dataMixedAir->OAMixer(OAMixerNum).MixMassFlowRate; + this->OAMassFlowRate * state.dataContaminantBalance->OutdoorCO2) / + this->MixMassFlowRate; } } if (state.dataContaminantBalance->Contaminant.GenericContamSimulation) { state.dataLoopNodes->Node(RelNode).GenContam = state.dataLoopNodes->Node(RetNode).GenContam; - if (state.dataMixedAir->OAMixer(OAMixerNum).MixMassFlowRate <= HVAC::VerySmallMassFlow) { + if (this->MixMassFlowRate <= HVAC::VerySmallMassFlow) { state.dataLoopNodes->Node(MixNode).GenContam = state.dataLoopNodes->Node(RetNode).GenContam; } else { state.dataLoopNodes->Node(MixNode).GenContam = ((state.dataLoopNodes->Node(RetNode).MassFlowRate - state.dataLoopNodes->Node(RelNode).MassFlowRate) * state.dataLoopNodes->Node(RetNode).GenContam + - state.dataMixedAir->OAMixer(OAMixerNum).OAMassFlowRate * state.dataContaminantBalance->OutdoorGC) / - state.dataMixedAir->OAMixer(OAMixerNum).MixMassFlowRate; + this->OAMassFlowRate * state.dataContaminantBalance->OutdoorGC) / + this->MixMassFlowRate; } } } diff --git a/src/EnergyPlus/MixedAir.hh b/src/EnergyPlus/MixedAir.hh index 4fad3e8ac5c..026ca0c8f5a 100644 --- a/src/EnergyPlus/MixedAir.hh +++ b/src/EnergyPlus/MixedAir.hh @@ -57,7 +57,7 @@ // EnergyPlus Headers #include #include -#include +// #include #include #include #include @@ -246,21 +246,17 @@ namespace MixedAir { OALimitFactor OALimitingFactor = OALimitFactor::Invalid; // OA controller limiting factor int OALimitingFactorReport = 0; // OA controller limiting factor - integer for reporting - void CalcOAController(EnergyPlusData &state, int const AirLoopNum, bool const FirstHVACIteration); + void CalcOAController(EnergyPlusData &state, int AirLoopNum, bool FirstHVACIteration); - void CalcOAEconomizer(EnergyPlusData &state, - int const AirLoopNum, - Real64 const OutAirMinFrac, - Real64 &OASignal, - bool &HighHumidityOperationFlag, - bool const FirstHVACIteration); + void CalcOAEconomizer( + EnergyPlusData &state, int AirLoopNum, Real64 OutAirMinFrac, Real64 &OASignal, bool &HighHumidityOperationFlag, bool FirstHVACIteration); void SizeOAController(EnergyPlusData &state); void UpdateOAController(EnergyPlusData &state); void Checksetpoints(EnergyPlusData &state, - Real64 const OutAirMinFrac, // Local variable used to calculate min OA fraction + Real64 OutAirMinFrac, // Local variable used to calculate min OA fraction Real64 &OutAirSignal, // Used to set OA mass flow rate bool &EconomizerOperationFlag // logical used to show economizer status ); @@ -353,6 +349,12 @@ namespace MixedAir { Real64 RetEnthalpy = 0.0; Real64 RetPressure = 0.0; Real64 RetMassFlowRate = 0.0; + + void InitOAMixer(EnergyPlusData &state); + + void CalcOAMixer(EnergyPlusData &state); + + void UpdateOAMixer(EnergyPlusData &state) const; }; // Functions @@ -367,32 +369,28 @@ namespace MixedAir { int GetOAController(EnergyPlusData &state, std::string const &OAName); - void - ManageOutsideAirSystem(EnergyPlusData &state, std::string const &OASysName, bool const FirstHVACIteration, int const AirLoopNum, int &OASysNum); + void ManageOutsideAirSystem(EnergyPlusData &state, std::string const &OASysName, bool FirstHVACIteration, int AirLoopNum, int &OASysNum); - void SimOutsideAirSys(EnergyPlusData &state, int const OASysNum, bool const FirstHVACIteration, int const AirLoopNum); + void SimOutsideAirSys(EnergyPlusData &state, int OASysNum, bool FirstHVACIteration, int AirLoopNum); - void SimOASysComponents(EnergyPlusData &state, int const OASysNum, bool const FirstHVACIteration, int const AirLoopNum); + void SimOASysComponents(EnergyPlusData &state, int OASysNum, bool FirstHVACIteration, int AirLoopNum); void SimOAComponent(EnergyPlusData &state, - std::string const &CompType, // the component type - std::string const &CompName, // the component Name - SimAirServingZones::CompType const CompTypeNum, // Component Type -- Integerized for this module - bool const FirstHVACIteration, + std::string const &CompType, // the component type + std::string const &CompName, // the component Name + SimAirServingZones::CompType CompTypeNum, // Component Type -- Integerized for this module + bool FirstHVACIteration, int &CompIndex, - int const AirLoopNum, // air loop index for economizer lockout coordination - bool const Sim, // if TRUE, simulate component; if FALSE, just set the coil exisitence flags - int const OASysNum, // index to outside air system - bool &OAHeatingCoil, // TRUE indicates a heating coil has been found - bool &OACoolingCoil, // TRUE indicates a cooling coil has been found - bool &OAHX); // TRUE indicates a heat exchanger has been found + int AirLoopNum, // air loop index for economizer lockout coordination + bool Sim, // if TRUE, simulate component; if FALSE, just set the coil exisitence flags + int OASysNum, // index to outside air system + bool &OAHeatingCoil, // TRUE indicates a heating coil has been found + bool &OACoolingCoil, // TRUE indicates a cooling coil has been found + bool &OAHX); // TRUE indicates a heat exchanger has been found void SimOAMixer(EnergyPlusData &state, std::string const &CompName, int &CompIndex); - void SimOAController(EnergyPlusData &state, std::string const &CtrlName, int &CtrlIndex, bool const FirstHVACIteration, int const AirLoopNum); - - // Get Input Section of the Module - //****************************************************************************** + void SimOAController(EnergyPlusData &state, std::string const &CtrlName, int &CtrlIndex, bool FirstHVACIteration, int AirLoopNum); void GetOutsideAirSysInputs(EnergyPlusData &state); @@ -403,8 +401,8 @@ namespace MixedAir { void GetOAMixerInputs(EnergyPlusData &state); void ProcessOAControllerInputs(EnergyPlusData &state, - std::string_view const CurrentModuleObject, - int const OutAirNum, + std::string_view CurrentModuleObject, + int OutAirNum, Array1D_string const &AlphArray, int &NumAlphas, Array1D const &NumArray, @@ -416,45 +414,9 @@ namespace MixedAir { bool &ErrorsFound // If errors found in input ); - // End of Get Input subroutines for the Module - //****************************************************************************** - - // Beginning Initialization Section of the Module - //****************************************************************************** - - void InitOutsideAirSys(EnergyPlusData &state, int const OASysNum, int const AirLoopNum); - - void InitOAController(EnergyPlusData &state, int const OAControllerNum, bool const FirstHVACIteration, int const AirLoopNum); - - void InitOAMixer(EnergyPlusData &state, int const OAMixerNum); - - // End of Initialization Section of the Module - //****************************************************************************** + void InitOutsideAirSys(EnergyPlusData &state, int OASysNum, int AirLoopNum); - // Beginning Calculation Section of the Module - //****************************************************************************** - - void CalcOAMixer(EnergyPlusData &state, int const OAMixerNum); - - // End of Calculation/Simulation Section of the Module - //****************************************************************************** - - // Beginning Sizing Section of the Module - //****************************************************************************** - - // End of Sizing Section of the Module - //****************************************************************************** - - // Beginning Update/Reporting Section of the Module - //****************************************************************************** - - void UpdateOAMixer(EnergyPlusData &state, int const OAMixerNum); - - // End of Sizing Section of the Module - //****************************************************************************** - - // Beginning Utility Section of the Module - //****************************************************************************** + void InitOAController(EnergyPlusData &state, int OAControllerNum, bool FirstHVACIteration, int AirLoopNum); Array1D_int GetOAMixerNodeNumbers(EnergyPlusData &state, std::string const &OAMixerName, // must match OA mixer names for the OA mixer type @@ -465,29 +427,29 @@ namespace MixedAir { int GetNumOAControllers(EnergyPlusData &state); - int GetOAMixerReliefNodeNumber(EnergyPlusData &state, int const OAMixerNum); // Which Mixer + int GetOAMixerReliefNodeNumber(EnergyPlusData &state, int OAMixerNum); // Which Mixer - int GetOASysControllerListIndex(EnergyPlusData &state, int const OASysNumber); // OA Sys Number + int GetOASysControllerListIndex(EnergyPlusData &state, int OASysNumber); // OA Sys Number - int GetOASysNumSimpControllers(EnergyPlusData &state, int const OASysNumber); // OA Sys Number + int GetOASysNumSimpControllers(EnergyPlusData &state, int OASysNumber); // OA Sys Number - int GetOASysNumHeatingCoils(EnergyPlusData &state, int const OASysNumber); // OA Sys Number + int GetOASysNumHeatingCoils(EnergyPlusData &state, int OASysNumber); // OA Sys Number - int GetOASysNumHXs(EnergyPlusData &state, int const OASysNumber); // OA Sys Number + int GetOASysNumHXs(EnergyPlusData &state, int OASysNumber); // OA Sys Number - int GetOASysNumCoolingCoils(EnergyPlusData &state, int const OASysNumber); // OA Sys Number + int GetOASysNumCoolingCoils(EnergyPlusData &state, int OASysNumber); // OA Sys Number int GetOASystemNumber(EnergyPlusData &state, std::string const &OASysName); // OA Sys Name - int FindOAMixerMatchForOASystem(EnergyPlusData &state, int const OASysNumber); // Which OA System + int FindOAMixerMatchForOASystem(EnergyPlusData &state, int OASysNumber); // Which OA System int GetOAMixerIndex(EnergyPlusData &state, std::string const &OAMixerName); // Which Mixer - int GetOAMixerInletNodeNumber(EnergyPlusData &state, int const OAMixerNumber); // Which Mixer + int GetOAMixerInletNodeNumber(EnergyPlusData &state, int OAMixerNumber); // Which Mixer - int GetOAMixerReturnNodeNumber(EnergyPlusData &state, int const OAMixerNumber); // Which Mixer + int GetOAMixerReturnNodeNumber(EnergyPlusData &state, int OAMixerNumber); // Which Mixer - int GetOAMixerMixedNodeNumber(EnergyPlusData &state, int const OAMixerNumber); // Which Mixer + int GetOAMixerMixedNodeNumber(EnergyPlusData &state, int OAMixerNumber); // Which Mixer bool CheckForControllerWaterCoil(EnergyPlusData &state, DataAirLoop::ControllerKind ControllerType, // should be passed in as UPPERCASE @@ -501,28 +463,25 @@ namespace MixedAir { int GetNumOASystems(EnergyPlusData &state); - int GetOACompListNumber(EnergyPlusData &state, int const OASysNum); // OA Sys Number + int GetOACompListNumber(EnergyPlusData &state, int OASysNum); // OA Sys Number std::string GetOACompName(EnergyPlusData &state, - int const OASysNum, // OA Sys Number - int const InListNum // In-list Number + int OASysNum, // OA Sys Number + int InListNum // In-list Number ); std::string GetOACompType(EnergyPlusData &state, - int const OASysNum, // OA Sys Number - int const InListNum // In-list Number + int OASysNum, // OA Sys Number + int InListNum // In-list Number ); SimAirServingZones::CompType GetOACompTypeNum(EnergyPlusData &state, - int const OASysNum, // OA Sys Number - int const InListNum // In-list Number + int OASysNum, // OA Sys Number + int InListNum // In-list Number ); int GetOAMixerNumber(EnergyPlusData &state, std::string const &OAMixerName); // must match OA mixer names for the OA mixer type - // End of Utility Section of the Module - //****************************************************************************** - } // namespace MixedAir struct MixedAirData : BaseGlobalStruct From 472e3e9124979270bd4bdeaab8527a4d514951ad Mon Sep 17 00:00:00 2001 From: Edwin Lee Date: Mon, 15 Jul 2024 12:04:56 -0500 Subject: [PATCH 36/57] Loosen tolerance on temperature in unit test --- tst/EnergyPlus/unit/MixedAir.unit.cc | 2 +- tst/EnergyPlus/unit/PackagedTerminalHeatPump.unit.cc | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tst/EnergyPlus/unit/MixedAir.unit.cc b/tst/EnergyPlus/unit/MixedAir.unit.cc index 05da5624374..16ec825ebd1 100644 --- a/tst/EnergyPlus/unit/MixedAir.unit.cc +++ b/tst/EnergyPlus/unit/MixedAir.unit.cc @@ -7745,7 +7745,7 @@ TEST_F(EnergyPlusFixture, MixedAir_TemperatureError) MixedAir::SimOAMixer(*state, state->dataAirLoop->OutsideAirSys(1).ComponentName(1), state->dataAirLoop->OutsideAirSys(1).ComponentIndex(1)); - auto T_sat = Psychrometrics::PsyTsatFnHPb(*state, state->dataMixedAir->OAMixer(1).MixEnthalpy, state->dataMixedAir->OAMixer(1).MixPressure); + Real64 const T_sat = Psychrometrics::PsyTsatFnHPb(*state, state->dataMixedAir->OAMixer(1).MixEnthalpy, state->dataMixedAir->OAMixer(1).MixPressure); // T_db must be >= T_sat at the mixed-air node to remain physical EXPECT_TRUE(state->dataMixedAir->OAMixer(1).MixTemp >= T_sat); diff --git a/tst/EnergyPlus/unit/PackagedTerminalHeatPump.unit.cc b/tst/EnergyPlus/unit/PackagedTerminalHeatPump.unit.cc index 023c2b73188..feb753e7edc 100644 --- a/tst/EnergyPlus/unit/PackagedTerminalHeatPump.unit.cc +++ b/tst/EnergyPlus/unit/PackagedTerminalHeatPump.unit.cc @@ -4028,7 +4028,7 @@ TEST_F(EnergyPlusFixture, PTACDrawAirfromReturnNodeAndPlenum_Test) // same temperature test as above commented out test (23.15327704750551), now shows 21.2 C // how do you mix 2 air streams with T1in=31.18 and T2in=23.15 and get Tout=21.23 ?? // must be a node enthalpy issue with this unit test? - EXPECT_NEAR(21.2317, state->dataLoopNodes->Node(ATMixer1AirOutNode).Temp, 0.001); + EXPECT_NEAR(21.2316, state->dataLoopNodes->Node(ATMixer1AirOutNode).Temp, 0.005); EXPECT_NEAR(0.324036, state->dataLoopNodes->Node(ATMixer1AirOutNode).MassFlowRate, 0.001); // mass balance zone 1 ATMixer outlet enthalpy based on pri and sec inlet stream enthalpy From abed1f003e7c6def9efec9d40184eb8f161b25f2 Mon Sep 17 00:00:00 2001 From: Edwin Lee Date: Mon, 15 Jul 2024 12:10:48 -0500 Subject: [PATCH 37/57] Clang format --- tst/EnergyPlus/unit/MixedAir.unit.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tst/EnergyPlus/unit/MixedAir.unit.cc b/tst/EnergyPlus/unit/MixedAir.unit.cc index 16ec825ebd1..47d9a53d472 100644 --- a/tst/EnergyPlus/unit/MixedAir.unit.cc +++ b/tst/EnergyPlus/unit/MixedAir.unit.cc @@ -7745,7 +7745,8 @@ TEST_F(EnergyPlusFixture, MixedAir_TemperatureError) MixedAir::SimOAMixer(*state, state->dataAirLoop->OutsideAirSys(1).ComponentName(1), state->dataAirLoop->OutsideAirSys(1).ComponentIndex(1)); - Real64 const T_sat = Psychrometrics::PsyTsatFnHPb(*state, state->dataMixedAir->OAMixer(1).MixEnthalpy, state->dataMixedAir->OAMixer(1).MixPressure); + Real64 const T_sat = + Psychrometrics::PsyTsatFnHPb(*state, state->dataMixedAir->OAMixer(1).MixEnthalpy, state->dataMixedAir->OAMixer(1).MixPressure); // T_db must be >= T_sat at the mixed-air node to remain physical EXPECT_TRUE(state->dataMixedAir->OAMixer(1).MixTemp >= T_sat); From ce283a328081cdc0539fa7c1afd7b7efccb61cd3 Mon Sep 17 00:00:00 2001 From: Rick Strand Date: Fri, 19 Jul 2024 16:45:15 -0500 Subject: [PATCH 38/57] 10299 Correction of Unit Test enum Correction of enum comparisons to eliminate errors in energyplus_tests --- tst/EnergyPlus/unit/SolarShading.unit.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tst/EnergyPlus/unit/SolarShading.unit.cc b/tst/EnergyPlus/unit/SolarShading.unit.cc index 123369cd2d7..c4bc0c9044b 100644 --- a/tst/EnergyPlus/unit/SolarShading.unit.cc +++ b/tst/EnergyPlus/unit/SolarShading.unit.cc @@ -5984,7 +5984,7 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_GetShadowingInputTest1) EXPECT_EQ(expectedOverlaps, state->dataSolarShading->MaxHCS); EXPECT_FALSE(state->dataSysVars->SutherlandHodgman); EXPECT_FALSE(state->dataSysVars->SlaterBarsky); - EXPECT_EQ(state->dataSysVars->shadingMethod, ShadingMethod::PolygonClipping); + EXPECT_ENUM_EQ(state->dataSysVars->shadingMethod, ShadingMethod::PolygonClipping); } TEST_F(EnergyPlusFixture, SolarShadingTest_GetShadowingInputTest2) @@ -6017,7 +6017,7 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_GetShadowingInputTest2) EXPECT_EQ(expectedOverlaps, state->dataSolarShading->MaxHCS); EXPECT_TRUE(state->dataSysVars->SutherlandHodgman); EXPECT_FALSE(state->dataSysVars->SlaterBarsky); - EXPECT_EQ(state->dataSysVars->shadingMethod, ShadingMethod::PolygonClipping); + EXPECT_ENUM_EQ(state->dataSysVars->shadingMethod, ShadingMethod::PolygonClipping); } TEST_F(EnergyPlusFixture, SolarShadingTest_GetShadowingInputTest3) @@ -6050,7 +6050,7 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_GetShadowingInputTest3) EXPECT_EQ(expectedOverlaps, state->dataSolarShading->MaxHCS); EXPECT_TRUE(state->dataSysVars->SutherlandHodgman); EXPECT_TRUE(state->dataSysVars->SlaterBarsky); - EXPECT_EQ(state->dataSysVars->shadingMethod, ShadingMethod::PolygonClipping); + EXPECT_ENUM_EQ(state->dataSysVars->shadingMethod, ShadingMethod::PolygonClipping); } TEST_F(EnergyPlusFixture, SolarShadingTest_GetShadowingInputTest4) @@ -6083,7 +6083,7 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_GetShadowingInputTest4) EXPECT_EQ(expectedOverlaps, state->dataSolarShading->MaxHCS); EXPECT_FALSE(state->dataSysVars->SutherlandHodgman); EXPECT_FALSE(state->dataSysVars->SlaterBarsky); - EXPECT_EQ(state->dataSysVars->shadingMethod, ShadingMethod::PixelCounting); + EXPECT_ENUM_EQ(state->dataSysVars->shadingMethod, ShadingMethod::PixelCounting); } TEST_F(EnergyPlusFixture, SolarShadingTest_GetShadowingInputTest5) @@ -6116,7 +6116,7 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_GetShadowingInputTest5) EXPECT_EQ(expectedOverlaps, state->dataSolarShading->MaxHCS); EXPECT_TRUE(state->dataSysVars->SutherlandHodgman); EXPECT_FALSE(state->dataSysVars->SlaterBarsky); - EXPECT_EQ(state->dataSysVars->shadingMethod, ShadingMethod::PixelCounting); + EXPECT_ENUM_EQ(state->dataSysVars->shadingMethod, ShadingMethod::PixelCounting); } TEST_F(EnergyPlusFixture, SolarShadingTest_GetShadowingInputTest6) @@ -6150,7 +6150,7 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_GetShadowingInputTest6) EXPECT_EQ(expectedOverlaps, state->dataSolarShading->MaxHCS); EXPECT_TRUE(state->dataSysVars->SutherlandHodgman); EXPECT_TRUE(state->dataSysVars->SlaterBarsky); - EXPECT_EQ(state->dataSysVars->shadingMethod, ShadingMethod::PixelCounting); + EXPECT_ENUM_EQ(state->dataSysVars->shadingMethod, ShadingMethod::PixelCounting); std::string const error_string = delimited_string({" ** Warning ** ShadowCalculation: suspect Shading Calculation Update Frequency", " ** ~~~ ** Value entered=[56], Shadowing Calculations will be inaccurate."}); EXPECT_TRUE(compare_err_stream(error_string, true)); From dd7dbee58fffde568ed4c29369d41ec611cb51aa Mon Sep 17 00:00:00 2001 From: "Lerond, Jeremy" Date: Sun, 21 Jul 2024 23:19:33 -0700 Subject: [PATCH 39/57] Allow ZoneHVAC:WindowAirConditioner along AFN simulations. --- src/EnergyPlus/AirflowNetwork/src/Solver.cpp | 14 ++ src/EnergyPlus/WindowAC.cc | 30 ++++ src/EnergyPlus/WindowAC.hh | 2 + .../unit/AirflowNetworkHVAC.unit.cc | 137 ++++++++++++++++++ 4 files changed, 183 insertions(+) diff --git a/src/EnergyPlus/AirflowNetwork/src/Solver.cpp b/src/EnergyPlus/AirflowNetwork/src/Solver.cpp index 8d583fbb388..058ea051962 100644 --- a/src/EnergyPlus/AirflowNetwork/src/Solver.cpp +++ b/src/EnergyPlus/AirflowNetwork/src/Solver.cpp @@ -102,6 +102,7 @@ #include #include #include +#include #include #include @@ -10143,6 +10144,7 @@ namespace AirflowNetwork { using SplitterComponent::GetSplitterNodeNumbers; using SplitterComponent::GetSplitterOutletNumber; using WaterThermalTanks::GetHeatPumpWaterHeaterNodeNumber; + using WindowAC::GetWindowACNodeNumber; using ZoneDehumidifier::GetZoneDehumidifierNodeNumber; // SUBROUTINE PARAMETER DEFINITIONS: @@ -10161,6 +10163,7 @@ namespace AirflowNetwork { bool HPWHFound(false); // Flag for HPWH identification bool StandaloneERVFound(false); // Flag for Standalone ERV (ZoneHVAC:EnergyRecoveryVentilator) identification + bool WindowACFound(false); // Flag for Window AC (ZoneHVAC:WindowAirConditioner) identification // Validate supply and return connections NodeFound.dimension(m_state.dataLoopNodes->NumOfNodes, false); @@ -10273,6 +10276,12 @@ namespace AirflowNetwork { NodeFound(i) = true; StandaloneERVFound = true; } + + // Skip Window AC with no OA + if (GetWindowACNodeNumber(m_state, i)) { + NodeFound(i) = true; + WindowACFound = true; + } } for (int zoneNum = 1; zoneNum <= m_state.dataGlobal->NumOfZones; ++zoneNum) { @@ -10413,6 +10422,11 @@ namespace AirflowNetwork { format(RoutineName) + "A ZoneHVAC:EnergyRecoveryVentilator is simulated along with an AirflowNetwork but is not " "included in the AirflowNetwork."); } + if (WindowACFound) { + ShowWarningError(m_state, + format(RoutineName) + "A ZoneHVAC:WindowAirConditioner is simulated along with an AirflowNetwork but is not " + "included in the AirflowNetwork."); + } NodeFound.deallocate(); // Assign AirLoop Number to every node and linkage diff --git a/src/EnergyPlus/WindowAC.cc b/src/EnergyPlus/WindowAC.cc index 6dad593cbcc..740b9eabd99 100644 --- a/src/EnergyPlus/WindowAC.cc +++ b/src/EnergyPlus/WindowAC.cc @@ -1499,6 +1499,36 @@ namespace WindowAC { } // WindAC(WindACNum)%DXCoilType_Num == CoilDX_CoolingHXAssisted && * } + bool GetWindowACNodeNumber(EnergyPlusData &state, int const NodeNumber) + { + if (state.dataWindowAC->GetWindowACInputFlag) { + GetWindowAC(state); + state.dataWindowAC->GetWindowACInputFlag = false; + } + + bool windowACOutdoorAir = false; + + for (int windowACIndex = 1; windowACIndex <= state.dataWindowAC->NumWindAC; ++windowACIndex) { + auto &windowAC = state.dataWindowAC->WindAC(windowACIndex); + if (windowAC.OutAirVolFlow == 0) { + windowACOutdoorAir = true; + } else { + windowACOutdoorAir = false; + } + int FanInletNodeIndex = 0; + int FanOutletNodeIndex = 0; + FanInletNodeIndex = state.dataFans->fans(windowAC.FanIndex)->inletNodeNum; + FanOutletNodeIndex = state.dataFans->fans(windowAC.FanIndex)->outletNodeNum; + + if (windowACOutdoorAir && + (NodeNumber == windowAC.OutsideAirNode || NodeNumber == windowAC.MixedAirNode || NodeNumber == windowAC.AirReliefNode || + NodeNumber == FanInletNodeIndex || NodeNumber == FanOutletNodeIndex || NodeNumber == windowAC.AirInNode)) { + return true; + } + } + return false; + } + int GetWindowACZoneInletAirNode(EnergyPlusData &state, int const WindACNum) { diff --git a/src/EnergyPlus/WindowAC.hh b/src/EnergyPlus/WindowAC.hh index 1520ddcf6a4..953c6eeee5a 100644 --- a/src/EnergyPlus/WindowAC.hh +++ b/src/EnergyPlus/WindowAC.hh @@ -197,6 +197,8 @@ namespace WindowAC { bool &HXUnitOn // Used to control HX heat recovery as needed ); + bool GetWindowACNodeNumber(EnergyPlusData &state, int const WindACNum); + int GetWindowACZoneInletAirNode(EnergyPlusData &state, int const WindACNum); int GetWindowACOutAirNode(EnergyPlusData &state, int const WindACNum); diff --git a/tst/EnergyPlus/unit/AirflowNetworkHVAC.unit.cc b/tst/EnergyPlus/unit/AirflowNetworkHVAC.unit.cc index 712f22d1fba..e94bc58351d 100644 --- a/tst/EnergyPlus/unit/AirflowNetworkHVAC.unit.cc +++ b/tst/EnergyPlus/unit/AirflowNetworkHVAC.unit.cc @@ -83,6 +83,7 @@ #include #include #include +#include #include #include #include @@ -19767,4 +19768,140 @@ TEST_F(EnergyPlusFixture, AirflowNetwork_ZoneOrderTest) state->afn->AirflowNetworkNodeData(3).EPlusNodeNum = 0; } +TEST_F(EnergyPlusFixture, AirflowNetwork_TestZoneEqpSupportZoneWindowAC) +{ + // Create zone + state->dataGlobal->NumOfZones = 1; + state->dataHeatBal->Zone.allocate(1); + state->dataHeatBal->Zone(1).Name = "ZONE 1"; + + // Create surfaces + state->dataSurface->Surface.allocate(1); + state->dataSurface->Surface(1).Name = "ZN004:ROOF001"; + state->dataSurface->Surface(1).Zone = 1; + state->dataSurface->Surface(1).ZoneName = "ZONE 1"; + state->dataSurface->Surface(1).Azimuth = 0.0; + state->dataSurface->Surface(1).ExtBoundCond = 0; + state->dataSurface->Surface(1).HeatTransSurf = true; + state->dataSurface->Surface(1).Tilt = 180.0; + state->dataSurface->Surface(1).Sides = 4; + state->dataSurface->Surface(1).Name = "ZN004:ROOF002"; + state->dataSurface->Surface(1).Zone = 1; + state->dataSurface->Surface(1).ZoneName = "ZONE 1"; + state->dataSurface->Surface(1).Azimuth = 0.0; + state->dataSurface->Surface(1).ExtBoundCond = 0; + state->dataSurface->Surface(1).HeatTransSurf = true; + state->dataSurface->Surface(1).Tilt = 180.0; + state->dataSurface->Surface(1).Sides = 4; + + state->dataSurface->Surface(1).OriginalClass = DataSurfaces::SurfaceClass::Window; + + // Create air system + state->dataAirSystemsData->PrimaryAirSystems.allocate(1); + state->dataAirSystemsData->PrimaryAirSystems(1).NumBranches = 1; + state->dataAirSystemsData->PrimaryAirSystems(1).Branch.allocate(1); + state->dataAirSystemsData->PrimaryAirSystems(1).Branch(1).TotalComponents = 1; + state->dataAirSystemsData->PrimaryAirSystems(1).Branch(1).Comp.allocate(1); + state->dataAirSystemsData->PrimaryAirSystems(1).Branch(1).Comp(1).TypeOf = "Fan:ConstantVolume"; + + // Create air nodes + state->dataLoopNodes->NumOfNodes = 3; + state->dataLoopNodes->Node.allocate(3); + state->dataLoopNodes->Node(1).FluidType = DataLoopNode::NodeFluidType::Air; + state->dataLoopNodes->Node(2).FluidType = DataLoopNode::NodeFluidType::Air; + state->dataLoopNodes->Node(3).FluidType = DataLoopNode::NodeFluidType::Air; + state->dataLoopNodes->NodeID.allocate(3); + state->dataLoopNodes->NodeID(1) = "ZONE 1 AIR NODE"; + bool errFlag{false}; + BranchNodeConnections::RegisterNodeConnection(*state, + 1, + "ZONE 1 AIR NODE", + DataLoopNode::ConnectionObjectType::FanOnOff, + "Object1", + DataLoopNode::ConnectionType::ZoneNode, + NodeInputManager::CompFluidStream::Primary, + false, + errFlag); + EXPECT_FALSE(errFlag); + + // Connect zone to air node + state->dataZoneEquip->ZoneEquipConfig.allocate(1); + state->dataZoneEquip->ZoneEquipConfig(1).IsControlled = true; + state->dataZoneEquip->ZoneEquipConfig(1).ZoneName = "ZONE 1"; + state->dataZoneEquip->ZoneEquipConfig(1).ZoneNode = 1; + state->dataZoneEquip->ZoneEquipConfig(1).NumInletNodes = 0; + state->dataZoneEquip->ZoneEquipConfig(1).NumReturnNodes = 0; + state->dataZoneEquip->ZoneEquipConfig(1).IsControlled = true; + + // One AirflowNetwork:MultiZone:Zone object + state->afn->AirflowNetworkNumOfZones = 1; + state->afn->MultizoneZoneData.allocate(1); + state->afn->MultizoneZoneData(1).ZoneNum = 1; + state->afn->MultizoneZoneData(1).ZoneName = "ZONE 1"; + + // Assume only one AirflowNetwork:Distribution:Node object is set for the Zone Air Node + state->afn->AirflowNetworkNumOfNodes = 1; + state->afn->AirflowNetworkNodeData.allocate(1); + state->afn->AirflowNetworkNodeData(1).Name = "ZONE 1"; + state->afn->AirflowNetworkNodeData(1).EPlusZoneNum = 1; + + state->afn->SplitterNodeNumbers.allocate(2); + state->afn->SplitterNodeNumbers(1) = 0; + state->afn->SplitterNodeNumbers(2) = 0; + + // Set flag to support zone equipment + state->afn->simulation_control.allow_unsupported_zone_equipment = true; + + // Create Fans + Real64 supplyFlowRate = 0.005; + Real64 exhaustFlowRate = 0.005; + + auto *fan1 = new Fans::FanComponent; + fan1->Name = "SupplyFan"; + + fan1->inletNodeNum = 2; + fan1->outletNodeNum = 3; + fan1->type = HVAC::FanType::OnOff; + fan1->maxAirFlowRate = supplyFlowRate; + + state->dataFans->fans.push_back(fan1); + state->dataFans->fanMap.insert_or_assign(fan1->Name, state->dataFans->fans.size()); + + state->dataLoopNodes->NodeID(2) = "SupplyFanInletNode"; + BranchNodeConnections::RegisterNodeConnection(*state, + 2, + state->dataLoopNodes->NodeID(2), + DataLoopNode::ConnectionObjectType::FanOnOff, + state->dataFans->fans(1)->Name, + DataLoopNode::ConnectionType::Inlet, + NodeInputManager::CompFluidStream::Primary, + false, + errFlag); + state->dataLoopNodes->NodeID(3) = "SupplyFanOutletNode"; + BranchNodeConnections::RegisterNodeConnection(*state, + 3, + state->dataLoopNodes->NodeID(3), + DataLoopNode::ConnectionObjectType::FanOnOff, + state->dataFans->fans(1)->Name, + DataLoopNode::ConnectionType::Outlet, + NodeInputManager::CompFluidStream::Primary, + false, + errFlag); + + // Create Window AC + state->dataWindowAC->WindAC.allocate(1); + state->dataWindowAC->GetWindowACInputFlag = false; + state->dataWindowAC->NumWindAC = 1; + state->dataWindowAC->WindAC(1).OutAirVolFlow = 0.0; + state->dataWindowAC->WindAC(1).FanName = state->dataFans->fans(1)->Name; + state->dataWindowAC->WindAC(1).FanIndex = 1; + + // Check validation and expected warning + state->afn->validate_distribution(); + + EXPECT_TRUE(compare_err_stream(" ** Warning ** AirflowNetwork::Solver::validate_distribution: A ZoneHVAC:WindowAirConditioner is simulated " + "along with an AirflowNetwork but is not included in the AirflowNetwork.\n", + true)); +} + } // namespace EnergyPlus From c688048d23f55f76e73f386e0632122b6ca607d3 Mon Sep 17 00:00:00 2001 From: Rick Strand Date: Mon, 22 Jul 2024 06:38:04 -0500 Subject: [PATCH 40/57] 10299 Move a PixelCounting Check An error message was being skipped because of the movement of the Get part of the old routine. anyScheduledShadingSurface was not set yet so the error message was never produced. This change should fix this problem and eliminate the change in the .err file for SolarShadingTestGPU.idf. --- src/EnergyPlus/SolarShading.cc | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/src/EnergyPlus/SolarShading.cc b/src/EnergyPlus/SolarShading.cc index 4d2776e0156..e166aed955a 100644 --- a/src/EnergyPlus/SolarShading.cc +++ b/src/EnergyPlus/SolarShading.cc @@ -519,18 +519,6 @@ void GetShadowingInput(EnergyPlusData &state) state.dataSysVars->shadingMethod = ShadingMethod::PolygonClipping; } - if ((state.dataSysVars->shadingMethod == DataSystemVariables::ShadingMethod::PixelCounting) && - state.dataSolarShading->anyScheduledShadingSurface) { - ShowSevereError(state, "The Shading Calculation Method of choice is \"PixelCounting\"; "); - ShowContinueError(state, "and there is at least one shading surface of type "); - ShowContinueError(state, "Shading:Site:Detailed, Shading:Building:Detailed, or Shading:Zone:Detailed, "); - ShowContinueError(state, "that has an active transmittance schedule value greater than zero or may vary."); - ShowContinueError(state, "With \"PixelCounting\" Shading Calculation Method, the shading surfaces will be treated as "); - ShowContinueError(state, "completely opaque (transmittance = 0) during the shading calculation, "); - ShowContinueError(state, "which may result in inaccurate or unexpected results."); - ShowContinueError(state, "It is suggested switching to another Shading Calculation Method, such as \"PolygonClipping\"."); - } - aNum++; if (NumAlphas >= aNum) { if (Util::SameString(state.dataIPShortCut->cAlphaArgs(aNum), "Periodic")) { @@ -738,6 +726,18 @@ void processShadowingInput(EnergyPlusData &state) { // all shadow input processing that needed zones and surfaces to already be read into data (part of fix for Defect #10299) + if ((state.dataSysVars->shadingMethod == DataSystemVariables::ShadingMethod::PixelCounting) && + state.dataSolarShading->anyScheduledShadingSurface) { + ShowSevereError(state, "The Shading Calculation Method of choice is \"PixelCounting\"; "); + ShowContinueError(state, "and there is at least one shading surface of type "); + ShowContinueError(state, "Shading:Site:Detailed, Shading:Building:Detailed, or Shading:Zone:Detailed, "); + ShowContinueError(state, "that has an active transmittance schedule value greater than zero or may vary."); + ShowContinueError(state, "With \"PixelCounting\" Shading Calculation Method, the shading surfaces will be treated as "); + ShowContinueError(state, "completely opaque (transmittance = 0) during the shading calculation, "); + ShowContinueError(state, "which may result in inaccurate or unexpected results."); + ShowContinueError(state, "It is suggested switching to another Shading Calculation Method, such as \"PolygonClipping\"."); + } + if (state.dataSysVars->shadingMethod == DataSystemVariables::ShadingMethod::Imported) { int ExtShadingSchedNum; for (int SurfNum = 1; SurfNum <= state.dataSurface->TotSurfaces; ++SurfNum) { From 096c7e6dddf42e708bcd295fa3439deb17ec81eb Mon Sep 17 00:00:00 2001 From: "Lerond, Jeremy" Date: Mon, 22 Jul 2024 09:06:06 -0700 Subject: [PATCH 41/57] Edit docs. --- .../src/overview/group-airflow-network.tex | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/input-output-reference/src/overview/group-airflow-network.tex b/doc/input-output-reference/src/overview/group-airflow-network.tex index 488041495a6..0445fd9c008 100644 --- a/doc/input-output-reference/src/overview/group-airflow-network.tex +++ b/doc/input-output-reference/src/overview/group-airflow-network.tex @@ -331,7 +331,7 @@ \subsubsection{Inputs}\label{inputs-004} \paragraph{Field: Allow Unsupported Zone Equipment}\label{allow-unsupported-zone-equipment} -This is an optional field. Input is Yes or No. The default is No. Set this input to Yes to have zone equipment that are currently unsupported in the AirflowNetwork model allowed in the simulation. Setting this field to Yes, allows the following equipment to be modeled along an AirflowNetwork model: ZoneHVAC:Dehumidifier, ZoneHVAC:EnergyRecoveryVentilator, WaterHeater:HeatPump:*. The AirflowNetwork model will exclude mass balance in these equipment objects and assume the mass flows are self-balanced in the equipment objects. +This is an optional field. Input is Yes or No. The default is No. Set this input to Yes to have zone equipment that are currently unsupported in the AirflowNetwork model allowed in the simulation. Setting this field to Yes, allows the following equipment to be modeled along an AirflowNetwork model: ZoneHVAC:Dehumidifier, ZoneHVAC:EnergyRecoveryVentilator, WaterHeater:HeatPump:*, and ZoneHVAC:WindowAirConditioner. The AirflowNetwork model will exclude mass balance in these equipment objects and assume the mass flows are self-balanced in the equipment objects. \paragraph{Field: Do Distribution Duct Sizing Calculation}\label{do-distribution-duct-sizing-calculation} From e5809d3edb87f5e7f2df3fbf122af6f49c9d4306 Mon Sep 17 00:00:00 2001 From: Rick Strand Date: Mon, 22 Jul 2024 14:39:47 -0500 Subject: [PATCH 42/57] 10299 Correction of Unit Test Errors A couple of issues were seen in ci results. This commit is an attempt to fix them. --- tst/EnergyPlus/unit/SolarShading.unit.cc | 29 ++++++++++++++++++------ 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/tst/EnergyPlus/unit/SolarShading.unit.cc b/tst/EnergyPlus/unit/SolarShading.unit.cc index c4bc0c9044b..1b1c9949b27 100644 --- a/tst/EnergyPlus/unit/SolarShading.unit.cc +++ b/tst/EnergyPlus/unit/SolarShading.unit.cc @@ -3900,18 +3900,18 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_Warn_Pixel_Count_and_TM_Schedule) SolarShading::processShadowingInput(*state); #ifdef EP_NO_OPENGL - EXPECT_EQ(state->dataErrTracking->TotalWarningErrors, 2); - EXPECT_EQ(state->dataErrTracking->TotalSevereErrors, 0); + EXPECT_EQ(state->dataErrTracking->TotalWarningErrors, 1); + EXPECT_EQ(state->dataErrTracking->TotalSevereErrors, 0; EXPECT_EQ(state->dataErrTracking->LastSevereError, ""); #else if (!Penumbra::Penumbra::is_valid_context()) { EXPECT_EQ(state->dataErrTracking->TotalWarningErrors, 2); - EXPECT_EQ(state->dataErrTracking->TotalSevereErrors, 0); - EXPECT_EQ(state->dataErrTracking->LastSevereError, ""); + EXPECT_EQ(state->dataErrTracking->TotalSevereErrors, 1); + EXPECT_EQ(state->dataErrTracking->LastSevereError, "The Shading Calculation Method of choice is \"PixelCounting\"; "); } else { EXPECT_EQ(state->dataErrTracking->TotalWarningErrors, 1); - EXPECT_EQ(state->dataErrTracking->TotalSevereErrors, 0); - EXPECT_EQ(state->dataErrTracking->LastSevereError, ""); + EXPECT_EQ(state->dataErrTracking->TotalSevereErrors, 1); + EXPECT_EQ(state->dataErrTracking->LastSevereError, "The Shading Calculation Method of choice is \"PixelCounting\"; "); } #endif } @@ -6151,7 +6151,22 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_GetShadowingInputTest6) EXPECT_TRUE(state->dataSysVars->SutherlandHodgman); EXPECT_TRUE(state->dataSysVars->SlaterBarsky); EXPECT_ENUM_EQ(state->dataSysVars->shadingMethod, ShadingMethod::PixelCounting); + +#ifdef EP_NO_OPENGL std::string const error_string = delimited_string({" ** Warning ** ShadowCalculation: suspect Shading Calculation Update Frequency", - " ** ~~~ ** Value entered=[56], Shadowing Calculations will be inaccurate."}); + " ** ~~~ ** Value entered=[56], Shadowing Calculations will be inaccurate.", + " ** Warning ** No GPU found (required for PixelCounting)", + " ** ~~~ ** PolygonClipping will be used instead"}); EXPECT_TRUE(compare_err_stream(error_string, true)); +#else + if (!Penumbra::Penumbra::is_valid_context()) { + std::string const error_string = delimited_string({" ** Warning ** ShadowCalculation: suspect Shading Calculation Update Frequency", + " ** ~~~ ** Value entered=[56], Shadowing Calculations will be inaccurate."}); + EXPECT_TRUE(compare_err_stream(error_string, true)); + } else { + std::string const error_string = delimited_string({" ** Warning ** ShadowCalculation: suspect Shading Calculation Update Frequency", + " ** ~~~ ** Value entered=[56], Shadowing Calculations will be inaccurate."}); + EXPECT_TRUE(compare_err_stream(error_string, true)); + } +#endif } From 4b6a726b497f300ef647d09962d95dc64740f195 Mon Sep 17 00:00:00 2001 From: Julien Marrec Date: Mon, 8 Jul 2024 23:13:53 +0200 Subject: [PATCH 43/57] print args when --debug-cli is passed --- src/EnergyPlus/CommandLineInterface.cc | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/src/EnergyPlus/CommandLineInterface.cc b/src/EnergyPlus/CommandLineInterface.cc index e54680f8a5b..cba2f718d21 100644 --- a/src/EnergyPlus/CommandLineInterface.cc +++ b/src/EnergyPlus/CommandLineInterface.cc @@ -208,7 +208,26 @@ Built on Platform: {} ->required(false) ->check(CLI::ExistingFile); - bool debugCLI = false; + // Catching it myself, so I can print the arguments vector before it's mutated + bool debugCLI = std::any_of(args.begin(), args.end(), [](const auto &arg) { return arg == "--debug-cli"; }); + if (debugCLI) { + { + fmt::print("ProcessArgs: received args\n"); + int na = 0; + for (const auto &a : args) { + fmt::print("* {}: '{}'\n", na++, a); + } + } + { + fmt::print("\nAfter massaging/expanding of args\n"); + int na = 0; + for (const auto &a : arguments) { + fmt::print("* {}: '{}'\n", na++, a); + } + } + fmt::print("\n"); + } + // bool debugCLI = false; app.add_flag("--debug-cli", debugCLI, "Print the result of the CLI assignments to the console and exit")->group(""); // Empty group to hide it app.footer("Example: energyplus -w weather.epw -r input.idf"); @@ -272,6 +291,9 @@ state.dataStrGlobals->inputFilePath='{}', state.dataGlobal->numThread, state.files.inputWeatherFilePath.filePath.generic_string(), state.dataStrGlobals->inputFilePath.generic_string()); + + fmt::print(stderr, "--debug-cli passed: exiting early\n"); + exit(0); } From 9fc5f17f26e8eb9090510a0057a095a212a76d6e Mon Sep 17 00:00:00 2001 From: Julien Marrec Date: Mon, 8 Jul 2024 23:14:27 +0200 Subject: [PATCH 44/57] WIP, seems to work even with 2 byte unicode chars. I need to tweak readJson too though --- src/EnergyPlus/CommandLineInterface.cc | 4 ++ src/EnergyPlus/FileSystem.cc | 55 +++++++++++++++++++++++-- src/EnergyPlus/SQLiteProcedures.cc | 57 ++++++++++++++++++++++---- 3 files changed, 103 insertions(+), 13 deletions(-) diff --git a/src/EnergyPlus/CommandLineInterface.cc b/src/EnergyPlus/CommandLineInterface.cc index cba2f718d21..3f7eb8920df 100644 --- a/src/EnergyPlus/CommandLineInterface.cc +++ b/src/EnergyPlus/CommandLineInterface.cc @@ -412,7 +412,11 @@ state.dataStrGlobals->inputFilePath='{}', // Helper to construct output file path auto composePath = [&outputFilePrefixFullPath](const std::string &suffix) -> fs::path { + #ifdef _WIN32 + return fs::path(outputFilePrefixFullPath.native() + CLI::widen(suffix)); + #else return fs::path(outputFilePrefixFullPath.string() + suffix); + #endif }; // EnergyPlus files diff --git a/src/EnergyPlus/FileSystem.cc b/src/EnergyPlus/FileSystem.cc index 2566f738473..ac3080e9d91 100644 --- a/src/EnergyPlus/FileSystem.cc +++ b/src/EnergyPlus/FileSystem.cc @@ -98,9 +98,13 @@ namespace FileSystem { // filename. Do we really need that though? // path.make_preferred(); fs::path result = path; + #ifdef _WIN32 + result.make_preferred(); + #else std::string tempPathAsStr = result.make_preferred().string(); std::replace(tempPathAsStr.begin(), tempPathAsStr.end(), DataStringGlobals::altpathChar, DataStringGlobals::pathChar); result = fs::path(tempPathAsStr); + #endif return result; } @@ -113,13 +117,21 @@ namespace FileSystem { fs::path getParentDirectoryPath(fs::path const &path) { // Note: this is needed because "/a/b/c".parent_path() = "/a/b/c/" +#ifdef _WIN32 + auto pathStr = path.native(); + if (!pathStr.empty()) { + while ((pathStr.back() == DataStringGlobals::pathChar) || (pathStr.back() == DataStringGlobals::altpathChar)) { + pathStr.erase(pathStr.size() - 1); + } + } +#else std::string pathStr = path.string(); if (!pathStr.empty()) { while ((pathStr.back() == DataStringGlobals::pathChar) || (pathStr.back() == DataStringGlobals::altpathChar)) { pathStr.erase(pathStr.size() - 1); } } - +#endif // If empty, return "./" instead fs::path parent_path = fs::path(pathStr).parent_path(); if (parent_path.empty()) { @@ -339,11 +351,45 @@ namespace FileSystem { std::string readFile(fs::path const &filePath, std::ios_base::openmode mode) { #ifdef _WIN32 - std::string filePathStr = filePath.string(); - const char *path = filePathStr.c_str(); + if (!fileExists(filePath)) { + throw FatalError("File does not exists"); + } + + auto filePathStr = filePath.native(); + const wchar_t *path = filePathStr.c_str(); + std::wstring_view fopen_mode; + if (mode == std::ios_base::in) { + fopen_mode = L"r"; + } else if (mode == std::ios_base::binary) { + fopen_mode = L"b"; + } else if (mode == (std::ios_base::in | std::ios_base::binary)) { + fopen_mode = L"rb"; + } else { + throw FatalError("ERROR - readFile: Bad openmode argument. Must be std::ios_base::in or std::ios_base::binary"); + } + auto close_file = [](FILE *f) { fclose(f); }; + auto holder = std::unique_ptr(_wfopen(path, fopen_mode.data()), close_file); // (THIS_AUTO_OK) + if (!holder) { + throw FatalError("Could not open file"); + } + + auto f = holder.get(); // (THIS_AUTO_OK) + const std::uintmax_t size = fs::file_size(filePath); + std::string result; + result.resize(size); + + size_t bytes_read = fread(result.data(), 1, size, f); + bool is_eof = feof(f); + bool has_error = ferror(f); + if (is_eof != 0) { + return result; + } + if (has_error != 0 || bytes_read != size) { + throw FatalError("Error reading file"); + } #else const char *path = filePath.c_str(); -#endif + if (!fileExists(filePath)) { throw FatalError(fmt::format("File does not exists: {}", path)); @@ -380,6 +426,7 @@ namespace FileSystem { if (has_error != 0 || bytes_read != size) { throw FatalError(fmt::format("Error reading file: {}", path)); } +#endif return result; } diff --git a/src/EnergyPlus/SQLiteProcedures.cc b/src/EnergyPlus/SQLiteProcedures.cc index 798215cda88..1ec88c7b4d6 100644 --- a/src/EnergyPlus/SQLiteProcedures.cc +++ b/src/EnergyPlus/SQLiteProcedures.cc @@ -46,6 +46,7 @@ // POSSIBILITY OF SUCH DAMAGE. // C++ headers +#include #include #include #include @@ -58,6 +59,7 @@ #include #include #include +#include #include #include #include @@ -66,6 +68,8 @@ #include #include +#include + namespace EnergyPlus { constexpr std::array reportFreqInts = { @@ -2605,18 +2609,39 @@ SQLiteProcedures::SQLiteProcedures(std::shared_ptr const &errorStr fs::path const &errorFilePath) : m_writeOutputToSQLite(writeOutputToSQLite), m_errorStream(errorStream) { + constexpr bool debug = true; + sqlite3 *m_connection = nullptr; if (m_writeOutputToSQLite) { int rc = -1; bool ok = true; + if constexpr (debug) { + // std::cout << "errorStream=" << errorStream << ", dbName=" << dbName << std::endl; + // std::cout << "dbName.string()=" << dbName.string() << std::endl; + // std::cout << "dbName.generic_string()=" << dbName.generic_string() << std::endl; + std::wcout << "dbName.generic_wstring()=" << dbName.generic_wstring() << std::endl; + std::cout << "narrow(dbName.generic_wstring())=" << CLI::narrow(dbName.generic_wstring()) << std::endl; + } + + std::string const dbName_utf8 = [&dbName]() { + if constexpr (std::is_same_v) { + return CLI::narrow(dbName.generic_wstring()); + } else { + return dbName.generic_string(); + } + }(); + // Test if we can write to the sqlite error file - // Does there need to be a seperate sqlite.err file at all? Consider using eplusout.err + // Does there need to be a separate sqlite.err file at all? Consider using eplusout.err if (m_errorStream) { - *m_errorStream << "SQLite3 message, " << errorFilePath.string() << " open for processing!" << std::endl; + *m_errorStream << "SQLite3 message, " << CLI::narrow(errorFilePath.generic_wstring()) << " open for processing!" << std::endl; } else { ok = false; } + if constexpr (debug) { + std::cout << "m_errorStream: " << std::boolalpha << ok << std::endl; + } // Test if we can create a new file named dbName if (ok && dbName != ":memory:") { @@ -2627,17 +2652,27 @@ SQLiteProcedures::SQLiteProcedures(std::shared_ptr const &errorStr ok = false; } } + if constexpr (debug) { + std::cout << "ofstream dbName: " << std::boolalpha << ok << std::endl; + } // Test if we can write to the database // If we can't then there are probably locks on the database if (ok) { // sqlite3_open_v2 could return SQLITE_BUSY at this point. If so, do not proceed to sqlite3_exec. - rc = sqlite3_open_v2(dbName.string().c_str(), &m_connection, SQLITE_OPEN_READWRITE, nullptr); + rc = sqlite3_open_v2(dbName_utf8.c_str(), &m_connection, SQLITE_OPEN_READWRITE, nullptr); if (rc) { *m_errorStream << "SQLite3 message, can't get exclusive lock to open database: " << sqlite3_errmsg(m_connection) << std::endl; ok = false; + if constexpr (debug) { + std::cout << "sqlite3_open_v2: " << std::boolalpha << ok << ' ' << sqlite3_errmsg(m_connection) << std::endl; + } } } + if constexpr (debug) { + std::cout << "sqlite3_open_v2: " << std::boolalpha << ok << std::endl; + } + if (ok) { char *zErrMsg = nullptr; // Set journal_mode OFF to avoid creating the file dbName + "-journal" (when dbName is a regular file) @@ -2652,11 +2687,15 @@ SQLiteProcedures::SQLiteProcedures(std::shared_ptr const &errorStr } else { if (dbName != ":memory:") { // Remove test db - rc = remove(dbName.string().c_str()); - if (rc) { - // File operation failed. SQLite connection is not in an error state. - *m_errorStream << "SQLite3 message, can't remove old database." << std::endl; - ok = false; + // rc = remove(dbName_utf8.c_str()); + if (fs::is_regular_file(dbName)) { + std::error_code ec; + if (!fs::remove(dbName, ec)) { + // File operation failed. SQLite connection is not in an error state. + *m_errorStream << "SQLite3 message, can't remove old database. code=" << ec.value() << ", error: " << ec.message() + << std::endl; + ok = false; + } } } } @@ -2665,7 +2704,7 @@ SQLiteProcedures::SQLiteProcedures(std::shared_ptr const &errorStr if (ok) { // Now open the output db for the duration of the simulation - rc = sqlite3_open_v2(dbName.string().c_str(), &m_connection, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, nullptr); + rc = sqlite3_open_v2(dbName_utf8.c_str(), &m_connection, SQLITE_OPEN_READWRITE | SQLITE_OPEN_CREATE, nullptr); m_db = std::shared_ptr(m_connection, sqlite3_close); if (rc) { *m_errorStream << "SQLite3 message, can't open new database: " << sqlite3_errmsg(m_connection) << std::endl; From cd84fa3c8521c1d00a77c32c4aef64479d1e1271 Mon Sep 17 00:00:00 2001 From: Julien Marrec Date: Mon, 8 Jul 2024 20:44:48 +0200 Subject: [PATCH 45/57] Change readFile and readJSON to use ifstream (that handles fs::path) + avoid using path.string() in that file (need to do it for more) --- src/EnergyPlus/FileSystem.cc | 161 +++++++++++------------------------ src/EnergyPlus/FileSystem.hh | 4 + 2 files changed, 55 insertions(+), 110 deletions(-) diff --git a/src/EnergyPlus/FileSystem.cc b/src/EnergyPlus/FileSystem.cc index ac3080e9d91..7b973018fef 100644 --- a/src/EnergyPlus/FileSystem.cc +++ b/src/EnergyPlus/FileSystem.cc @@ -70,6 +70,8 @@ #include #include +#include + namespace EnergyPlus { namespace FileSystem { @@ -98,13 +100,13 @@ namespace FileSystem { // filename. Do we really need that though? // path.make_preferred(); fs::path result = path; - #ifdef _WIN32 +#ifdef _WIN32 result.make_preferred(); - #else +#else std::string tempPathAsStr = result.make_preferred().string(); std::replace(tempPathAsStr.begin(), tempPathAsStr.end(), DataStringGlobals::altpathChar, DataStringGlobals::pathChar); result = fs::path(tempPathAsStr); - #endif +#endif return result; } @@ -118,7 +120,7 @@ namespace FileSystem { { // Note: this is needed because "/a/b/c".parent_path() = "/a/b/c/" #ifdef _WIN32 - auto pathStr = path.native(); + std::wstring pathStr = path.native(); if (!pathStr.empty()) { while ((pathStr.back() == DataStringGlobals::pathChar) || (pathStr.back() == DataStringGlobals::altpathChar)) { pathStr.erase(pathStr.size() - 1); @@ -228,7 +230,7 @@ namespace FileSystem { // just compare to ".EPJSON" instead of "EPJSON"... fs::path getFileExtension(fs::path const &filePath) { - std::string pext = fs::path(filePath).extension().string(); + std::string pext = toString(filePath.extension()); if (!pext.empty()) { // remove '.' pext = std::string(++pext.begin(), pext.end()); @@ -238,15 +240,8 @@ namespace FileSystem { FileTypes getFileType(fs::path const &filePath) { -#ifdef _WIN32 - std::string const filePathStr = fs::path(filePath).extension().string(); - std::string_view extension = filePathStr.c_str(); -#else - std::string_view extension = fs::path(filePath).extension().c_str(); -#endif - - extension.remove_prefix(extension.find_last_of('.') + 1); - std::string stringExtension = std::string(extension); + std::string stringExtension = toString(filePath.extension()); + stringExtension = stringExtension.substr(stringExtension.rfind('.') + 1); return static_cast(getEnumValue(FileTypesExtUC, Util::makeUPPER(stringExtension))); } @@ -269,7 +264,7 @@ namespace FileSystem { // Create a directory if doesn't already exist if (pathExists(directoryPath)) { // path already exists if (!directoryExists(directoryPath)) { - std::cout << "ERROR: " << getAbsolutePath(directoryPath).string() << " already exists and is not a directory." << std::endl; + std::cout << "ERROR: " << toString(getAbsolutePath(directoryPath)) << " already exists and is not a directory." << std::endl; std::exit(EXIT_FAILURE); } } else { // directory does not already exist @@ -350,135 +345,81 @@ namespace FileSystem { std::string readFile(fs::path const &filePath, std::ios_base::openmode mode) { -#ifdef _WIN32 + // Shenanigans would not be needed with fmt 10+ (maybe earlier), because fmt has native fs::path support if (!fileExists(filePath)) { - throw FatalError("File does not exists"); + throw FatalError(fmt::format("File does not exists: {}", toString(filePath))); } - auto filePathStr = filePath.native(); - const wchar_t *path = filePathStr.c_str(); - std::wstring_view fopen_mode; - if (mode == std::ios_base::in) { - fopen_mode = L"r"; - } else if (mode == std::ios_base::binary) { - fopen_mode = L"b"; - } else if (mode == (std::ios_base::in | std::ios_base::binary)) { - fopen_mode = L"rb"; - } else { + // Can only be 'r', 'b' or 'rb' + if ((mode & (std::ios_base::in | std::ios_base::binary)) == 0) { throw FatalError("ERROR - readFile: Bad openmode argument. Must be std::ios_base::in or std::ios_base::binary"); } - auto close_file = [](FILE *f) { fclose(f); }; - auto holder = std::unique_ptr(_wfopen(path, fopen_mode.data()), close_file); // (THIS_AUTO_OK) - if (!holder) { - throw FatalError("Could not open file"); - } - auto f = holder.get(); // (THIS_AUTO_OK) - const std::uintmax_t size = fs::file_size(filePath); - std::string result; - result.resize(size); - - size_t bytes_read = fread(result.data(), 1, size, f); - bool is_eof = feof(f); - bool has_error = ferror(f); - if (is_eof != 0) { - return result; - } - if (has_error != 0 || bytes_read != size) { - throw FatalError("Error reading file"); - } -#else - const char *path = filePath.c_str(); - - - if (!fileExists(filePath)) { - throw FatalError(fmt::format("File does not exists: {}", path)); + const std::uintmax_t file_size = fs::file_size(filePath); + std::ifstream file(filePath, mode); + if (!file.is_open()) { + throw FatalError(fmt::format("Could not open file: {}", toString(filePath))); } - - std::string_view fopen_mode; - if (mode == std::ios_base::in) { - fopen_mode = "r"; - } else if (mode == std::ios_base::binary) { - fopen_mode = "b"; - } else if (mode == (std::ios_base::in | std::ios_base::binary)) { - fopen_mode = "rb"; - } else { - throw FatalError("ERROR - readFile: Bad openmode argument. Must be std::ios_base::in or std::ios_base::binary"); - } - - auto close_file = [](FILE *f) { fclose(f); }; - auto holder = std::unique_ptr(fopen(path, fopen_mode.data()), close_file); // (THIS_AUTO_OK) - if (!holder) { - throw FatalError(fmt::format("Could not open file: {}", path)); - } - - auto f = holder.get(); // (THIS_AUTO_OK) - const std::uintmax_t size = fs::file_size(filePath); - std::string result; - result.resize(size); - - size_t bytes_read = fread(result.data(), 1, size, f); - bool is_eof = feof(f); - bool has_error = ferror(f); - if (is_eof != 0) { - return result; - } - if (has_error != 0 || bytes_read != size) { - throw FatalError(fmt::format("Error reading file: {}", path)); - } -#endif + std::string result(file_size, '\0'); + file.read(result.data(), file_size); return result; } nlohmann::json readJSON(fs::path const &filePath, std::ios_base::openmode mode) { -#ifdef _WIN32 - std::string filePathStr = filePath.string(); - const char *path = filePathStr.c_str(); -#else - const char *path = filePath.c_str(); -#endif + // Shenanigans would not be needed with fmt 10+ (maybe earlier), because fmt has native fs::path support if (!fileExists(filePath)) { - throw FatalError(fmt::format("File does not exists: {}", path)); + throw FatalError(fmt::format("File does not exists: {}", toString(filePath))); } - std::string_view fopen_mode; - if (mode == std::ios_base::in) { - fopen_mode = "r"; - } else if (mode == std::ios_base::binary) { - fopen_mode = "b"; - } else if (mode == (std::ios_base::in | std::ios_base::binary)) { - fopen_mode = "rb"; - } else { + // Can only be 'r', 'b' or 'rb' + if ((mode & (std::ios_base::in | std::ios_base::binary)) == 0) { throw FatalError("ERROR - readFile: Bad openmode argument. Must be std::ios_base::in or std::ios_base::binary"); } - auto close_file = [](FILE *f) { fclose(f); }; - auto holder = std::unique_ptr(fopen(path, fopen_mode.data()), close_file); // (THIS_AUTO_OK) - if (!holder) { - throw FatalError(fmt::format("Could not open file: {}", path)); + std::ifstream file(filePath, mode); + if (!file.is_open()) { + throw FatalError(fmt::format("Could not open file: {}", toString(filePath))); } - auto f = holder.get(); // (THIS_AUTO_OK) FileTypes const ext = getFileType(filePath); switch (ext) { case FileTypes::EpJSON: case FileTypes::JSON: case FileTypes::GLHE: - return nlohmann::json::parse(f, nullptr, true, true); + return nlohmann::json::parse(file, nullptr, true, true); case FileTypes::CBOR: - return nlohmann::json::from_cbor(f); + return nlohmann::json::from_cbor(file); case FileTypes::MsgPack: - return nlohmann::json::from_msgpack(f); + return nlohmann::json::from_msgpack(file); case FileTypes::UBJSON: - return nlohmann::json::from_ubjson(f); + return nlohmann::json::from_ubjson(file); case FileTypes::BSON: - return nlohmann::json::from_bson(f); + return nlohmann::json::from_bson(file); default: throw FatalError("Invalid file extension. Must be epJSON, JSON, or other experimental extensions"); } } + std::string toString(fs::path const &p) + { + return CLI::detail::maybe_narrow(p.c_str()); + // if constexpr (std::is_same_v) { + // return CLI::narrow(p.wstring()); + // } else { + // return p.string(); + // } + } + + std::string toGenericString(fs::path const &p) + { + if constexpr (std::is_same_v) { + return CLI::narrow(p.generic_wstring()); + } else { + return p.generic_string(); + } + } + } // namespace FileSystem } // namespace EnergyPlus diff --git a/src/EnergyPlus/FileSystem.hh b/src/EnergyPlus/FileSystem.hh index 91f5754ece6..2197b4810ec 100644 --- a/src/EnergyPlus/FileSystem.hh +++ b/src/EnergyPlus/FileSystem.hh @@ -320,6 +320,10 @@ namespace FileSystem { } } + std::string toString(fs::path const &p); + + std::string toGenericString(fs::path const &p); + } // namespace FileSystem } // namespace EnergyPlus #endif From 6121f19f87cf0f628dbbb4f3c4708c2fbec0f562 Mon Sep 17 00:00:00 2001 From: Julien Marrec Date: Mon, 8 Jul 2024 21:57:00 +0200 Subject: [PATCH 46/57] Add a specific fmt::formatter for fs::path that will **narrow** from wide string to string on windows. Supports 's' (string()) or 'g' (generic_string())presentations --- src/EnergyPlus/FileSystem.cc | 9 ++++++++ src/EnergyPlus/FileSystem.hh | 40 +++++++++++++++++++++++++++++------- 2 files changed, 42 insertions(+), 7 deletions(-) diff --git a/src/EnergyPlus/FileSystem.cc b/src/EnergyPlus/FileSystem.cc index 7b973018fef..4fa2ca4ac13 100644 --- a/src/EnergyPlus/FileSystem.cc +++ b/src/EnergyPlus/FileSystem.cc @@ -421,5 +421,14 @@ namespace FileSystem { } } + fs::path appendSuffixToPath(fs::path const &outputFilePrefixFullPath, const std::string &suffix) + { + if constexpr (std::is_same_v) { + return {outputFilePrefixFullPath.wstring() + CLI::widen(suffix)}; + } else { + return {outputFilePrefixFullPath.string() + suffix}; + } + } + } // namespace FileSystem } // namespace EnergyPlus diff --git a/src/EnergyPlus/FileSystem.hh b/src/EnergyPlus/FileSystem.hh index 2197b4810ec..fc1c926237f 100644 --- a/src/EnergyPlus/FileSystem.hh +++ b/src/EnergyPlus/FileSystem.hh @@ -70,13 +70,6 @@ namespace fs = std::experimental::filesystem; #include -// Add a custom formatter for fmt -namespace fmt { -template <> struct formatter : formatter -{ -}; -} // namespace fmt - // If we want to allow this kind of stuff // fs::path p = "folder/eplus"; // std::string suffixStr = "out.audit"; @@ -324,6 +317,39 @@ namespace FileSystem { std::string toGenericString(fs::path const &p); + fs::path appendSuffixToPath(fs::path const& outputFilePrefixFullPath, const std::string &suffix); + } // namespace FileSystem } // namespace EnergyPlus + +// Add a custom formatter for fmt +template <> struct fmt::formatter +{ + // Presentation format: 's' - string, 'g' - generic_string. + char presentation = 's'; + + // Parses format specifications of the form ['s' | 'g']. + constexpr auto parse(format_parse_context &ctx) -> decltype(ctx.begin()) + { + // Parse the presentation format and store it in the formatter: + auto it = ctx.begin(), end = ctx.end(); + if (it != end && (*it == 's' || *it == 'g')) { + presentation = *it++; + } + + // Check if reached the end of the range: + if (it != end && *it != '}') { + throw format_error("invalid format"); + }; + + // Return an iterator past the end of the parsed range: + return it; + } + + template auto format(const fs::path &p, FormatContext &ctx) -> decltype(ctx.out()) + { + return format_to(ctx.out(), "{}", presentation == 'g' ? EnergyPlus::FileSystem::toGenericString(p) : EnergyPlus::FileSystem::toString(p)); + } +}; + #endif From 1573494da37d7b773bced05edf16bc4dda2518d8 Mon Sep 17 00:00:00 2001 From: Julien Marrec Date: Mon, 8 Jul 2024 22:13:38 +0200 Subject: [PATCH 47/57] Use the new fmt::formatter (except ExternalInterface) --- src/EnergyPlus/ChillerElectricASHRAE205.cc | 5 +- src/EnergyPlus/CommandLineInterface.cc | 61 +++++++++---------- src/EnergyPlus/CurveManager.cc | 12 ++-- src/EnergyPlus/DataSystemVariables.cc | 8 +-- src/EnergyPlus/DaylightingManager.cc | 2 +- src/EnergyPlus/FileSystem.cc | 8 +-- src/EnergyPlus/HeatBalanceManager.cc | 8 +-- src/EnergyPlus/IOFiles.cc | 4 +- .../InputProcessing/InputProcessor.cc | 2 +- src/EnergyPlus/OutputProcessor.cc | 10 +-- src/EnergyPlus/OutputReportTabular.cc | 2 +- src/EnergyPlus/PluginManager.cc | 43 ++++++------- src/EnergyPlus/PluginManager.hh | 6 +- src/EnergyPlus/SQLiteProcedures.cc | 14 +---- src/EnergyPlus/ScheduleManager.cc | 4 +- src/EnergyPlus/SimulationManager.cc | 6 +- src/EnergyPlus/SolarShading.cc | 5 +- src/EnergyPlus/TARCOGOutput.cc | 7 ++- src/EnergyPlus/UtilityRoutines.cc | 18 +++--- src/EnergyPlus/WeatherManager.cc | 12 ++-- src/EnergyPlus/WindTurbine.cc | 4 +- src/EnergyPlus/ZoneTempPredictorCorrector.cc | 2 +- 22 files changed, 114 insertions(+), 129 deletions(-) diff --git a/src/EnergyPlus/ChillerElectricASHRAE205.cc b/src/EnergyPlus/ChillerElectricASHRAE205.cc index b3413b28b48..77786d58266 100644 --- a/src/EnergyPlus/ChillerElectricASHRAE205.cc +++ b/src/EnergyPlus/ChillerElectricASHRAE205.cc @@ -71,6 +71,7 @@ #include #include #include +#include #include #include #include @@ -146,9 +147,9 @@ void getChillerASHRAE205Input(EnergyPlusData &state) // Since logger context must persist across all calls to libtk205/btwxt, it must be a member thisChiller.LoggerContext = {&state, format("{} \"{}\"", state.dataIPShortCut->cCurrentModuleObject, thisObjectName)}; thisChiller.Representation = std::dynamic_pointer_cast( - RSInstanceFactory::create("RS0001", rep_file_path.string().c_str(), std::make_shared())); + RSInstanceFactory::create("RS0001", FileSystem::toString(rep_file_path).c_str(), std::make_shared())); if (nullptr == thisChiller.Representation) { - ShowSevereError(state, format("{} is not an instance of an ASHRAE205 Chiller.", rep_file_path.string())); + ShowSevereError(state, format("{} is not an instance of an ASHRAE205 Chiller.", rep_file_path)); ErrorsFound = true; } thisChiller.Representation->performance.performance_map_cooling.get_logger()->set_message_context(&thisChiller.LoggerContext); diff --git a/src/EnergyPlus/CommandLineInterface.cc b/src/EnergyPlus/CommandLineInterface.cc index 3f7eb8920df..b3ff583fafc 100644 --- a/src/EnergyPlus/CommandLineInterface.cc +++ b/src/EnergyPlus/CommandLineInterface.cc @@ -261,8 +261,8 @@ Built on Platform: {} R"debug( state.dataGlobal->AnnualSimulation = {}, state.dataGlobal->DDOnlySimulation = {}, -state.dataStrGlobals->outDirPath = '{}', -state.dataStrGlobals->inputIddFilePath= '{}', +state.dataStrGlobals->outDirPath = '{:g}', +state.dataStrGlobals->inputIddFilePath= '{:g}', runEPMacro = {}, prefixOutName = {}, @@ -274,13 +274,13 @@ state.dataGlobal->outputEpJSONConversionOnly={}, suffixType={}, state.dataGlobal->numThread={}, -state.files.inputWeatherFilePath.filePath='{}', -state.dataStrGlobals->inputFilePath='{}', +state.files.inputWeatherFilePath.filePath='{:g}', +state.dataStrGlobals->inputFilePath='{:g}', )debug", state.dataGlobal->AnnualSimulation, state.dataGlobal->DDOnlySimulation, - state.dataStrGlobals->outDirPath.generic_string(), - state.dataStrGlobals->inputIddFilePath.generic_string(), + state.dataStrGlobals->outDirPath, + state.dataStrGlobals->inputIddFilePath, runEPMacro, prefixOutName, @@ -289,8 +289,8 @@ state.dataStrGlobals->inputFilePath='{}', state.dataGlobal->outputEpJSONConversionOnly, suffixType, state.dataGlobal->numThread, - state.files.inputWeatherFilePath.filePath.generic_string(), - state.dataStrGlobals->inputFilePath.generic_string()); + state.files.inputWeatherFilePath.filePath, + state.dataStrGlobals->inputFilePath); fmt::print(stderr, "--debug-cli passed: exiting early\n"); @@ -329,8 +329,7 @@ state.dataStrGlobals->inputFilePath='{}', break; default: DisplayString(state, - fmt::format("ERROR: Input file must have IDF, IMF, or epJSON extension: {}", - state.dataStrGlobals->inputFilePath.generic_string())); + fmt::format("ERROR: Input file must have IDF, IMF, or epJSON extension: {:g}", state.dataStrGlobals->inputFilePath)); if (eplusRunningViaAPI) { return static_cast(ReturnCodes::Failure); } else { @@ -412,11 +411,7 @@ state.dataStrGlobals->inputFilePath='{}', // Helper to construct output file path auto composePath = [&outputFilePrefixFullPath](const std::string &suffix) -> fs::path { - #ifdef _WIN32 - return fs::path(outputFilePrefixFullPath.native() + CLI::widen(suffix)); - #else - return fs::path(outputFilePrefixFullPath.string() + suffix); - #endif + return FileSystem::appendSuffixToPath(outputFilePrefixFullPath, suffix); }; // EnergyPlus files @@ -531,7 +526,7 @@ state.dataStrGlobals->inputFilePath='{}', if (FileSystem::fileExists(state.files.iniFile.filePath)) { EnergyPlus::InputFile iniFile = state.files.iniFile.try_open(); if (!iniFile.good()) { - DisplayString(state, "ERROR: Could not open file " + iniFile.filePath.string() + " for input (read)."); + DisplayString(state, fmt::format("ERROR: Could not open file {} for input (read).", iniFile.filePath)); if (eplusRunningViaAPI) { return static_cast(ReturnCodes::Failure); } else { @@ -558,7 +553,7 @@ state.dataStrGlobals->inputFilePath='{}', // Check if specified files exist if (!FileSystem::fileExists(state.dataStrGlobals->inputFilePath)) { DisplayString( - state, "ERROR: Could not find input data file: " + FileSystem::getAbsolutePath(state.dataStrGlobals->inputFilePath).string() + "."); + state, fmt::format("ERROR: Could not find input data file: {}.", FileSystem::getAbsolutePath(state.dataStrGlobals->inputFilePath))); DisplayString(state, errorFollowUp); if (eplusRunningViaAPI) { return static_cast(ReturnCodes::Failure); @@ -571,7 +566,7 @@ state.dataStrGlobals->inputFilePath='{}', if (!FileSystem::fileExists(state.files.inputWeatherFilePath.filePath)) { DisplayString( state, - "ERROR: Could not find weather file: " + FileSystem::getAbsolutePath(state.files.inputWeatherFilePath.filePath).string() + "."); + fmt::format("ERROR: Could not find weather file: {}.", FileSystem::getAbsolutePath(state.files.inputWeatherFilePath.filePath))); DisplayString(state, errorFollowUp); if (eplusRunningViaAPI) { return static_cast(ReturnCodes::Failure); @@ -587,14 +582,14 @@ state.dataStrGlobals->inputFilePath='{}', if (runEPMacro) { fs::path epMacroPath = (state.dataStrGlobals->exeDirectoryPath / "EPMacro").replace_extension(FileSystem::exeExtension); if (!FileSystem::fileExists(epMacroPath)) { - DisplayString(state, "ERROR: Could not find EPMacro executable: " + FileSystem::getAbsolutePath(epMacroPath).string() + "."); + DisplayString(state, fmt::format("ERROR: Could not find EPMacro executable: {}.", FileSystem::getAbsolutePath(epMacroPath))); if (eplusRunningViaAPI) { return static_cast(ReturnCodes::Failure); } else { exit(EXIT_FAILURE); } } - std::string epMacroCommand = "\"" + epMacroPath.string() + "\""; + std::string epMacroCommand = "\"" + FileSystem::toString(epMacroPath) + "\""; bool inputFilePathdIn = (FileSystem::getAbsolutePath(state.dataStrGlobals->inputFilePath) == FileSystem::getAbsolutePath("in.imf")); if (!inputFilePathdIn) { @@ -615,21 +610,21 @@ state.dataStrGlobals->inputFilePath='{}', (state.dataStrGlobals->exeDirectoryPath / fs::path("ExpandObjects")).replace_extension(FileSystem::exeExtension); if (!FileSystem::fileExists(expandObjectsPath)) { DisplayString(state, - "ERROR: Could not find ExpandObjects executable: " + FileSystem::getAbsolutePath(expandObjectsPath).string() + "."); + fmt::format("ERROR: Could not find ExpandObjects executable: {}.", FileSystem::getAbsolutePath(expandObjectsPath))); if (eplusRunningViaAPI) { return static_cast(ReturnCodes::Failure); } else { exit(EXIT_FAILURE); } } - std::string expandObjectsCommand = "\"" + expandObjectsPath.string() + "\""; + std::string expandObjectsCommand = "\"" + FileSystem::toString(expandObjectsPath) + "\""; bool inputFilePathdIn = (FileSystem::getAbsolutePath(state.dataStrGlobals->inputFilePath) == FileSystem::getAbsolutePath("in.idf")); // check if IDD actually exists since ExpandObjects still requires it if (!FileSystem::fileExists(state.dataStrGlobals->inputIddFilePath)) { DisplayString(state, - "ERROR: Could not find input data dictionary: " + - FileSystem::getAbsolutePath(state.dataStrGlobals->inputIddFilePath).string() + "."); + fmt::format("ERROR: Could not find input data dictionary: {}.", + FileSystem::getAbsolutePath(state.dataStrGlobals->inputIddFilePath))); DisplayString(state, errorFollowUp); if (eplusRunningViaAPI) { return static_cast(ReturnCodes::Failure); @@ -823,7 +818,7 @@ state.dataStrGlobals->inputFilePath='{}', state, "ERROR: Could not find ReadVarsESO executable. When calling through C API, make sure to call setEnergyPlusRootDirectory"); } else { - DisplayString(state, "ERROR: Could not find ReadVarsESO executable: " + FileSystem::getAbsolutePath(readVarsPath).string() + "."); + DisplayString(state, fmt::format("ERROR: Could not find ReadVarsESO executable: {}.", FileSystem::getAbsolutePath(readVarsPath))); } return static_cast(ReturnCodes::Failure); } @@ -836,10 +831,10 @@ state.dataStrGlobals->inputFilePath='{}', if (!rviFileExists) { std::ofstream ofs{RVIfile}; if (!ofs.good()) { - ShowFatalError(state, format("EnergyPlus: Could not open file \"{}\" for output (write).", RVIfile.string())); + ShowFatalError(state, format("EnergyPlus: Could not open file \"{}\" for output (write).", RVIfile)); } else { - ofs << state.files.eso.filePath.string() << '\n'; - ofs << state.files.csv.filePath.string() << '\n'; + ofs << FileSystem::toString(state.files.eso.filePath) << '\n'; + ofs << FileSystem::toString(state.files.csv.filePath) << '\n'; } } @@ -847,17 +842,17 @@ state.dataStrGlobals->inputFilePath='{}', if (!mviFileExists) { std::ofstream ofs{MVIfile}; if (!ofs.good()) { - ShowFatalError(state, format("EnergyPlus: Could not open file \"{}\" for output (write).", RVIfile.string())); + ShowFatalError(state, format("EnergyPlus: Could not open file \"{}\" for output (write).", RVIfile)); } else { - ofs << state.files.mtr.filePath.string() << '\n'; - ofs << state.files.mtr_csv.filePath.string() << '\n'; + ofs << FileSystem::toString(state.files.mtr.filePath) << '\n'; + ofs << FileSystem::toString(state.files.mtr_csv.filePath) << '\n'; } } // We quote the paths in case we have spaces // "/Path/to/ReadVarEso" "/Path/to/folder with spaces/file.rvi" unlimited - std::string const readVarsRviCommand = "\"" + readVarsPath.string() + "\" \"" + RVIfile.string() + "\" unlimited"; - std::string const readVarsMviCommand = "\"" + readVarsPath.string() + "\" \"" + MVIfile.string() + "\" unlimited"; + std::string const readVarsRviCommand = "\"" + FileSystem::toString(readVarsPath) + "\" \"" + FileSystem::toString(RVIfile) + "\" unlimited"; + std::string const readVarsMviCommand = "\"" + FileSystem::toString(readVarsPath) + "\" \"" + FileSystem::toString(MVIfile) + "\" unlimited"; // systemCall will be responsible to handle to above command on Windows versus Unix FileSystem::systemCall(readVarsRviCommand); diff --git a/src/EnergyPlus/CurveManager.cc b/src/EnergyPlus/CurveManager.cc index ea358edc77a..f000fde6243 100644 --- a/src/EnergyPlus/CurveManager.cc +++ b/src/EnergyPlus/CurveManager.cc @@ -2309,12 +2309,12 @@ namespace Curve { fs::path filePath(tmp); if (!indVarInstance.count("external_file_column_number")) { ShowSevereError(state, - format("{}: No column number defined for external file \"{}\"", contextString, filePath.string())); + format("{}: No column number defined for external file \"{}\"", contextString, filePath)); ErrorsFound = true; } if (!indVarInstance.count("external_file_starting_row_number")) { ShowSevereError( - state, format("{}: No starting row number defined for external file \"{}\"", contextString, filePath.string())); + state, format("{}: No starting row number defined for external file \"{}\"", contextString, filePath)); ErrorsFound = true; } @@ -2507,12 +2507,12 @@ namespace Curve { fs::path filePath(tmp); if (!fields.count("external_file_column_number")) { - ShowSevereError(state, format("{}: No column number defined for external file \"{}\"", contextString, filePath.string())); + ShowSevereError(state, format("{}: No column number defined for external file \"{}\"", contextString, filePath)); ErrorsFound = true; } if (!fields.count("external_file_starting_row_number")) { ShowSevereError(state, - format("{}: No starting row number defined for external file \"{}\"", contextString, filePath.string())); + format("{}: No starting row number defined for external file \"{}\"", contextString, filePath)); ErrorsFound = true; } @@ -2682,11 +2682,11 @@ namespace Curve { auto &content = contents[col]; if (col >= numColumns) { ShowFatalError( - state, format("File \"{}\" : Requested column ({}) exceeds the number of columns ({}).", filePath.string(), col + 1, numColumns)); + state, format("File \"{}\" : Requested column ({}) exceeds the number of columns ({}).", filePath, col + 1, numColumns)); } if (row >= numRows) { ShowFatalError( - state, format("File \"{}\" : Requested starting row ({}) exceeds the number of rows ({}).", filePath.string(), row + 1, numRows)); + state, format("File \"{}\" : Requested starting row ({}) exceeds the number of rows ({}).", filePath, row + 1, numRows)); } std::vector array(numRows - row); std::transform(content.begin() + row, content.end(), array.begin(), [](std::string_view str) { diff --git a/src/EnergyPlus/DataSystemVariables.cc b/src/EnergyPlus/DataSystemVariables.cc index 2d13588b361..def6ab83745 100644 --- a/src/EnergyPlus/DataSystemVariables.cc +++ b/src/EnergyPlus/DataSystemVariables.cc @@ -183,7 +183,7 @@ namespace DataSystemVariables { for (std::size_t i = 0; i < numPathsToTest; ++i) { if (FileSystem::fileExists(pathsToCheck[i].first)) { foundFilePath = pathsToCheck[i].first; - print(state.files.audit, "found ({})={}\n", pathsToCheck[i].second, FileSystem::getAbsolutePath(foundFilePath).string()); + print(state.files.audit, "found ({})={}\n", pathsToCheck[i].second, FileSystem::getAbsolutePath(foundFilePath)); return foundFilePath; } else { @@ -198,15 +198,15 @@ namespace DataSystemVariables { if (!found) { pathsChecked.push_back(currentPath); } - print(state.files.audit, "not found ({})={}\n", pathsToCheck[i].second, FileSystem::getAbsolutePath(pathsToCheck[i].first).string()); + print(state.files.audit, "not found ({})={}\n", pathsToCheck[i].second, FileSystem::getAbsolutePath(pathsToCheck[i].first)); } } // If we get here, we didn't find the file - ShowSevereError(state, format("{}\"{}\" not found.", contextString, originalInputFilePath.string())); + ShowSevereError(state, format("{}\"{}\" not found.", contextString, originalInputFilePath)); ShowContinueError(state, " Paths searched:"); for (auto &path : pathsChecked) { - ShowContinueError(state, format(" {}: \"{}\"", path.second, path.first.string())); + ShowContinueError(state, format(" {}: \"{}\"", path.second, path.first)); } return foundFilePath; diff --git a/src/EnergyPlus/DaylightingManager.cc b/src/EnergyPlus/DaylightingManager.cc index a5ac94e669f..c06f9dee700 100644 --- a/src/EnergyPlus/DaylightingManager.cc +++ b/src/EnergyPlus/DaylightingManager.cc @@ -8998,7 +8998,7 @@ void ReportIllumMap(EnergyPlusData &state, int const MapNum) auto openMapFile = [&](const fs::path &filePath) -> InputOutputFile & { auto &outputFile = *illumMap.mapFile; - outputFile.filePath = fs::path(filePath.string() + fmt::to_string(MapNum)); + outputFile.filePath = FileSystem::appendSuffixToPath(filePath, fmt::to_string(MapNum)); outputFile.ensure_open(state, "ReportIllumMap"); return outputFile; }; diff --git a/src/EnergyPlus/FileSystem.cc b/src/EnergyPlus/FileSystem.cc index 4fa2ca4ac13..9f573a96a39 100644 --- a/src/EnergyPlus/FileSystem.cc +++ b/src/EnergyPlus/FileSystem.cc @@ -347,7 +347,7 @@ namespace FileSystem { { // Shenanigans would not be needed with fmt 10+ (maybe earlier), because fmt has native fs::path support if (!fileExists(filePath)) { - throw FatalError(fmt::format("File does not exists: {}", toString(filePath))); + throw FatalError(fmt::format("File does not exists: {}", filePath)); } // Can only be 'r', 'b' or 'rb' @@ -358,7 +358,7 @@ namespace FileSystem { const std::uintmax_t file_size = fs::file_size(filePath); std::ifstream file(filePath, mode); if (!file.is_open()) { - throw FatalError(fmt::format("Could not open file: {}", toString(filePath))); + throw FatalError(fmt::format("Could not open file: {}", filePath)); } std::string result(file_size, '\0'); file.read(result.data(), file_size); @@ -370,7 +370,7 @@ namespace FileSystem { // Shenanigans would not be needed with fmt 10+ (maybe earlier), because fmt has native fs::path support if (!fileExists(filePath)) { - throw FatalError(fmt::format("File does not exists: {}", toString(filePath))); + throw FatalError(fmt::format("File does not exists: {}", filePath)); } // Can only be 'r', 'b' or 'rb' @@ -380,7 +380,7 @@ namespace FileSystem { std::ifstream file(filePath, mode); if (!file.is_open()) { - throw FatalError(fmt::format("Could not open file: {}", toString(filePath))); + throw FatalError(fmt::format("Could not open file: {}", filePath)); } FileTypes const ext = getFileType(filePath); diff --git a/src/EnergyPlus/HeatBalanceManager.cc b/src/EnergyPlus/HeatBalanceManager.cc index 5f791ee9e1a..2cb173bfd80 100644 --- a/src/EnergyPlus/HeatBalanceManager.cc +++ b/src/EnergyPlus/HeatBalanceManager.cc @@ -1924,7 +1924,7 @@ namespace HeatBalanceManager { DisplayString(state, "--Construction not found"); ErrorsFound = true; ShowSevereError(state, format("No match on WINDOW5 data file for Construction={}, or error in data file.", ConstructAlphas(0))); - ShowContinueError(state, format("...Looking on file={}", window5DataFilePath.string())); // TODO: call getAbsolutePath maybe? + ShowContinueError(state, format("...Looking on file={}", window5DataFilePath)); // TODO: call getAbsolutePath maybe? continue; } @@ -3854,9 +3854,9 @@ namespace HeatBalanceManager { if (endcol > 0) { if (int(NextLine.data[endcol - 1]) == DataSystemVariables::iUnicode_end) { ShowSevereError(state, - format("SearchWindow5DataFile: For \"{}\" in {} fiile, appears to be a Unicode or binary file.", + format("SearchWindow5DataFile: For \"{}\" in {} file, appears to be a Unicode or binary file.", DesiredConstructionName, - DesiredFilePath.string())); + DesiredFilePath)); ShowContinueError(state, "...This file cannot be read by this program. Please save as PC or Unix file and try again"); ShowFatalError(state, "Program terminates due to previous condition."); } @@ -3868,7 +3868,7 @@ namespace HeatBalanceManager { if (NextLine.eof) goto Label1000; ++FileLineCount; if (!has_prefixi(NextLine.data, "WINDOW5")) { - ShowSevereError(state, format("HeatBalanceManager: SearchWindow5DataFile: Error in Data File={}", DesiredFilePath.string())); + ShowSevereError(state, format("HeatBalanceManager: SearchWindow5DataFile: Error in Data File={}", DesiredFilePath)); ShowFatalError( state, format("Error reading Window5 Data File: first word of window entry is \"{}\", should be Window5.", NextLine.data.substr(0, 7))); diff --git a/src/EnergyPlus/IOFiles.cc b/src/EnergyPlus/IOFiles.cc index 614a27abcfd..66f0c09f3cc 100644 --- a/src/EnergyPlus/IOFiles.cc +++ b/src/EnergyPlus/IOFiles.cc @@ -68,7 +68,7 @@ InputFile &InputFile::ensure_open(EnergyPlusData &state, const std::string &call open(false, output_to_file); } if (!good()) { - ShowFatalError(state, fmt::format("{}: Could not open file {} for input (read).", caller, filePath.string())); + ShowFatalError(state, fmt::format("{}: Could not open file {} for input (read).", caller, filePath)); } return *this; } @@ -217,7 +217,7 @@ InputOutputFile &InputOutputFile::ensure_open(EnergyPlusData &state, const std:: open(false, output_to_file); } if (!good()) { - ShowFatalError(state, fmt::format("{}: Could not open file {} for output (write).", caller, filePath.string())); + ShowFatalError(state, fmt::format("{}: Could not open file {} for output (write).", caller, filePath)); } return *this; } diff --git a/src/EnergyPlus/InputProcessing/InputProcessor.cc b/src/EnergyPlus/InputProcessing/InputProcessor.cc index 85eaf153d0c..cbbc4776a7c 100644 --- a/src/EnergyPlus/InputProcessing/InputProcessor.cc +++ b/src/EnergyPlus/InputProcessing/InputProcessor.cc @@ -259,7 +259,7 @@ void cleanEPJSON(json &epjson) void InputProcessor::processInput(EnergyPlusData &state) { if (!FileSystem::fileExists(state.dataStrGlobals->inputFilePath)) { - ShowFatalError(state, "Input file path " + state.dataStrGlobals->inputFilePath.string() + " not found"); + ShowFatalError(state, fmt::format("Input file path {} not found", state.dataStrGlobals->inputFilePath)); return; } diff --git a/src/EnergyPlus/OutputProcessor.cc b/src/EnergyPlus/OutputProcessor.cc index 11f04dd6102..80f48e6b049 100644 --- a/src/EnergyPlus/OutputProcessor.cc +++ b/src/EnergyPlus/OutputProcessor.cc @@ -3913,8 +3913,8 @@ void SetInitialMeterReportingAndOutputNames(EnergyPlusData &state, format(R"(Output:Meter:MeterFileOnly requested for "{}" ({}), already on "Output:Meter". Will report to both {} and {})", meter->Name, reportFreqNames[(freq == ReportFreq::EachCall) ? (int)ReportFreq::TimeStep : (int)freq], - state.files.eso.filePath.filename().string(), - state.files.mtr.filePath.filename().string())); + state.files.eso.filePath.filename(), + state.files.mtr.filePath.filename())); } if (!period.Rpt) { period.Rpt = true; @@ -3933,8 +3933,8 @@ void SetInitialMeterReportingAndOutputNames(EnergyPlusData &state, format("Output:Meter:MeterFileOnly requested for \"Cumulative {}\" (TimeStep), already on \"Output:Meter\". " "Will report to both {} and {}", meter->Name, - state.files.eso.filePath.filename().string(), - state.files.mtr.filePath.filename().string())); + state.files.eso.filePath.filename(), + state.files.mtr.filePath.filename())); } if (!period.accRpt) { @@ -4730,7 +4730,7 @@ int initErrorFile(EnergyPlusData &state) { state.files.err_stream = std::make_unique(state.files.outputErrFilePath); if (state.files.err_stream->bad()) { - DisplayString(state, "ERROR: Could not open file " + state.files.outputErrFilePath.string() + " for output (write)."); + DisplayString(state, fmt::format("ERROR: Could not open file {} for output (write).", state.files.outputErrFilePath)); return EXIT_FAILURE; } return EXIT_SUCCESS; diff --git a/src/EnergyPlus/OutputReportTabular.cc b/src/EnergyPlus/OutputReportTabular.cc index c0e6b764335..4d7a6aa62f5 100644 --- a/src/EnergyPlus/OutputReportTabular.cc +++ b/src/EnergyPlus/OutputReportTabular.cc @@ -179,7 +179,7 @@ std::ofstream &open_tbl_stream(EnergyPlusData &state, int const iStyle, fs::path if (output_to_file) { tbl_stream.open(filePath); if (!tbl_stream) { - ShowFatalError(state, format("OpenOutputTabularFile: Could not open file \"{}\" for output (write).", filePath.string())); + ShowFatalError(state, format("OpenOutputTabularFile: Could not open file \"{}\" for output (write).", filePath)); } } else { tbl_stream.setstate(std::ios_base::badbit); diff --git a/src/EnergyPlus/PluginManager.cc b/src/EnergyPlus/PluginManager.cc index 73f2b98fb99..ca742de3dce 100644 --- a/src/EnergyPlus/PluginManager.cc +++ b/src/EnergyPlus/PluginManager.cc @@ -407,17 +407,16 @@ void initPython(EnergyPlusData &state, fs::path const &pathToPythonPackages) status = PyConfig_SetString(&config, &config.home, wcharPath); if (PyStatus_Exception(status)) { - ShowFatalError(state, fmt::format("Could not set home to {} on PyConfig... {}", pathToPythonPackages.generic_string(), status)); + ShowFatalError(state, fmt::format("Could not set home to {:g} on PyConfig... {}", pathToPythonPackages, status)); } status = PyConfig_SetString(&config, &config.base_prefix, wcharPath); if (PyStatus_Exception(status)) { - ShowFatalError(state, fmt::format("Could not set base_prefix to {} on PyConfig... {}", pathToPythonPackages.generic_string(), status)); + ShowFatalError(state, fmt::format("Could not set base_prefix to {:g} on PyConfig... {}", pathToPythonPackages, status)); } config.module_search_paths_set = 1; status = PyWideStringList_Append(&config.module_search_paths, wcharPath); if (PyStatus_Exception(status)) { - ShowFatalError(state, - fmt::format("Could not add {} to module_search_paths on PyConfig... {}", pathToPythonPackages.generic_string(), status)); + ShowFatalError(state, fmt::format("Could not add {:g} to module_search_paths on PyConfig... {}", pathToPythonPackages, status)); } } else { @@ -428,17 +427,16 @@ void initPython(EnergyPlusData &state, fs::path const &pathToPythonPackages) status = PyConfig_SetString(&config, &config.home, wcharPath); if (PyStatus_Exception(status)) { - ShowFatalError(state, fmt::format("Could not set home to {} on PyConfig... {}", pathToPythonPackages.generic_string(), status)); + ShowFatalError(state, fmt::format("Could not set home to {:g} on PyConfig... {}", pathToPythonPackages, status)); } status = PyConfig_SetString(&config, &config.base_prefix, wcharPath); if (PyStatus_Exception(status)) { - ShowFatalError(state, fmt::format("Could not set base_prefix to {} on PyConfig... {}", pathToPythonPackages.generic_string(), status)); + ShowFatalError(state, fmt::format("Could not set base_prefix to {:g} on PyConfig... {}", pathToPythonPackages, status)); } config.module_search_paths_set = 1; status = PyWideStringList_Append(&config.module_search_paths, wcharPath); if (PyStatus_Exception(status)) { - ShowFatalError(state, - fmt::format("Could not add {} to module_search_paths on PyConfig... {}", pathToPythonPackages.generic_string(), status)); + ShowFatalError(state, fmt::format("Could not add {:g} to module_search_paths on PyConfig... {}", pathToPythonPackages, status)); } PyMem_RawFree(wcharPath); @@ -697,6 +695,12 @@ PluginManager::~PluginManager() #endif // LINK_WITH_PYTHON } +PluginInstance::PluginInstance(const fs::path &_modulePath, const std::string &_className, std::string emsName, bool runPluginDuringWarmup) + : modulePath(_modulePath), className(_className), emsAlias(std::move(emsName)), runDuringWarmup(runPluginDuringWarmup), + stringIdentifier(FileSystem::toString(_modulePath) + "." + _className) +{ +} + void PluginInstance::reportPythonError([[maybe_unused]] EnergyPlusData &state) { #if LINK_WITH_PYTHON @@ -786,13 +790,13 @@ void PluginInstance::setup([[maybe_unused]] EnergyPlusData &state) pModuleName = PyUnicode_FromString(s.c_str()); // New reference } if (pModuleName == nullptr) { - EnergyPlus::ShowFatalError(state, format("Failed to convert the Module Path \"{}\" for import", this->modulePath.generic_string())); + EnergyPlus::ShowFatalError(state, format("Failed to convert the Module Path \"{:g}\" for import", this->modulePath)); } this->pModule = PyImport_Import(pModuleName); Py_DECREF(pModuleName); if (!this->pModule) { - EnergyPlus::ShowSevereError(state, format("Failed to import module \"{}\"", this->modulePath.generic_string())); + EnergyPlus::ShowSevereError(state, format("Failed to import module \"{:g}\"", this->modulePath)); EnergyPlus::ShowContinueError(state, format("Current sys.path={}", PluginManager::currentPythonPath())); // ONLY call PyErr_Print if PyErr has occurred, otherwise it will cause other problems if (PyErr_Occurred()) { @@ -804,7 +808,7 @@ void PluginInstance::setup([[maybe_unused]] EnergyPlusData &state) } PyObject *pModuleDict = PyModule_GetDict(this->pModule); if (!pModuleDict) { - EnergyPlus::ShowSevereError(state, format("Failed to read module dictionary from module \"{}\"", this->modulePath.generic_string())); + EnergyPlus::ShowSevereError(state, format("Failed to read module dictionary from module \"{:g}\"", this->modulePath)); if (PyErr_Occurred()) { PluginInstance::reportPythonError(state); } else { @@ -826,7 +830,7 @@ void PluginInstance::setup([[maybe_unused]] EnergyPlusData &state) PyObject *pClass = PyDict_GetItemString(pModuleDict, className.c_str()); // Py_DECREF(pModuleDict); // PyModule_GetDict returns a borrowed reference, DO NOT decrement if (!pClass) { - EnergyPlus::ShowSevereError(state, format(R"(Failed to get class type "{}" from module "{}")", className, modulePath.generic_string())); + EnergyPlus::ShowSevereError(state, format(R"(Failed to get class type "{}" from module "{:g}")", className, modulePath)); if (PyErr_Occurred()) { PluginInstance::reportPythonError(state); } else { @@ -863,11 +867,9 @@ void PluginInstance::setup([[maybe_unused]] EnergyPlusData &state) std::string const detectOverriddenFunctionName = "_detect_overridden"; PyObject *detectFunction = PyObject_GetAttrString(this->pClassInstance, detectOverriddenFunctionName.c_str()); if (!detectFunction || !PyCallable_Check(detectFunction)) { - EnergyPlus::ShowSevereError(state, - format(R"(Could not find or call function "{}" on class "{}.{}")", - detectOverriddenFunctionName, - this->modulePath.generic_string(), - this->className)); + EnergyPlus::ShowSevereError( + state, + format(R"(Could not find or call function "{}" on class "{:g}.{}")", detectOverriddenFunctionName, this->modulePath, this->className)); if (PyErr_Occurred()) { PluginInstance::reportPythonError(state); } else { @@ -1177,8 +1179,7 @@ void PluginManager::addToPythonPath(EnergyPlusData &state, const fs::path &inclu unicodeIncludePath = PyUnicode_FromString(s.c_str()); // New reference } if (unicodeIncludePath == nullptr) { - EnergyPlus::ShowFatalError(state, - format("ERROR converting the path \"{}\" for addition to the sys.path in Python", includePath.generic_string())); + EnergyPlus::ShowFatalError(state, format("ERROR converting the path \"{:g}\" for addition to the sys.path in Python", includePath)); } PyObject *sysPath = PySys_GetObject("path"); // Borrowed reference @@ -1189,11 +1190,11 @@ void PluginManager::addToPythonPath(EnergyPlusData &state, const fs::path &inclu if (PyErr_Occurred()) { PluginInstance::reportPythonError(state); } - EnergyPlus::ShowFatalError(state, format("ERROR adding \"{}\" to the sys.path in Python", includePath.generic_string())); + EnergyPlus::ShowFatalError(state, format("ERROR adding \"{:g}\" to the sys.path in Python", includePath)); } if (userDefinedPath) { - EnergyPlus::ShowMessage(state, format("Successfully added path \"{}\" to the sys.path in Python", includePath.generic_string())); + EnergyPlus::ShowMessage(state, format("Successfully added path \"{:g}\" to the sys.path in Python", includePath)); } // PyRun_SimpleString)("print(' EPS : ' + str(sys.path))"); diff --git a/src/EnergyPlus/PluginManager.hh b/src/EnergyPlus/PluginManager.hh index ceb84bb5bfd..f9122a1afce 100644 --- a/src/EnergyPlus/PluginManager.hh +++ b/src/EnergyPlus/PluginManager.hh @@ -93,11 +93,7 @@ namespace PluginManagement { struct PluginInstance { - PluginInstance(const fs::path &_modulePath, const std::string &_className, std::string emsName, bool runPluginDuringWarmup) - : modulePath(_modulePath), className(_className), emsAlias(std::move(emsName)), runDuringWarmup(runPluginDuringWarmup), - stringIdentifier(_modulePath.string() + "." + _className) - { - } + PluginInstance(const fs::path &_modulePath, const std::string &_className, std::string emsName, bool runPluginDuringWarmup); // members fs::path modulePath; diff --git a/src/EnergyPlus/SQLiteProcedures.cc b/src/EnergyPlus/SQLiteProcedures.cc index 1ec88c7b4d6..56b7e53f825 100644 --- a/src/EnergyPlus/SQLiteProcedures.cc +++ b/src/EnergyPlus/SQLiteProcedures.cc @@ -68,8 +68,6 @@ #include #include -#include - namespace EnergyPlus { constexpr std::array reportFreqInts = { @@ -2621,21 +2619,15 @@ SQLiteProcedures::SQLiteProcedures(std::shared_ptr const &errorStr // std::cout << "dbName.string()=" << dbName.string() << std::endl; // std::cout << "dbName.generic_string()=" << dbName.generic_string() << std::endl; std::wcout << "dbName.generic_wstring()=" << dbName.generic_wstring() << std::endl; - std::cout << "narrow(dbName.generic_wstring())=" << CLI::narrow(dbName.generic_wstring()) << std::endl; + std::cout << "narrow(dbName.generic_wstring())=" << FileSystem::toGenericString(dbName) << std::endl; } - std::string const dbName_utf8 = [&dbName]() { - if constexpr (std::is_same_v) { - return CLI::narrow(dbName.generic_wstring()); - } else { - return dbName.generic_string(); - } - }(); + std::string const dbName_utf8 = FileSystem::toGenericString(dbName); // Test if we can write to the sqlite error file // Does there need to be a separate sqlite.err file at all? Consider using eplusout.err if (m_errorStream) { - *m_errorStream << "SQLite3 message, " << CLI::narrow(errorFilePath.generic_wstring()) << " open for processing!" << std::endl; + *m_errorStream << "SQLite3 message, " << FileSystem::toGenericString(errorFilePath) << " open for processing!" << std::endl; } else { ok = false; } diff --git a/src/EnergyPlus/ScheduleManager.cc b/src/EnergyPlus/ScheduleManager.cc index 27e216bad7c..83184a58b25 100644 --- a/src/EnergyPlus/ScheduleManager.cc +++ b/src/EnergyPlus/ScheduleManager.cc @@ -490,7 +490,7 @@ namespace ScheduleManager { ShowSevereError(state, error); } } - ShowContinueError(state, fmt::format("Error Occurred in {}", state.files.TempFullFilePath.filePath.string())); + ShowContinueError(state, fmt::format("Error Occurred in {}", state.files.TempFullFilePath.filePath)); ShowFatalError(state, "Program terminates due to previous condition."); } schedule_file_shading_result = it.first; @@ -1805,7 +1805,7 @@ namespace ScheduleManager { ShowSevereError(state, error); } } - ShowContinueError(state, fmt::format("Error Occurred in {}", state.files.TempFullFilePath.filePath.string())); + ShowContinueError(state, fmt::format("Error Occurred in {}", state.files.TempFullFilePath.filePath)); ShowFatalError(state, "Program terminates due to previous condition."); } result = it.first; diff --git a/src/EnergyPlus/SimulationManager.cc b/src/EnergyPlus/SimulationManager.cc index 70ba13d6ddd..20306b3dae7 100644 --- a/src/EnergyPlus/SimulationManager.cc +++ b/src/EnergyPlus/SimulationManager.cc @@ -1579,7 +1579,7 @@ namespace SimulationManager { { auto result = std::make_unique(filePath, mode); // (AUTO_OK_UPTR) if (!result->good()) { - ShowFatalError(state, format("OpenOutputFiles: Could not open file {} for output (write).", filePath.string())); + ShowFatalError(state, format("OpenOutputFiles: Could not open file {} for output (write).", filePath)); } return result; } @@ -1588,7 +1588,7 @@ namespace SimulationManager { { std::unique_ptr result = nullptr; #ifdef _WIN32 - std::string filePathStr = filePath.string(); + std::string filePathStr = FileSystem::toString(filePath); const char *path = filePathStr.c_str(); #else const char *path = filePath.c_str(); @@ -1598,7 +1598,7 @@ namespace SimulationManager { result = std::make_unique(std::move(f)); } catch (const std::system_error &error) { ShowSevereError(state, error.what()); - ShowFatalError(state, format("OpenOutputFiles: Could not open file {} for output (write).", filePath.string())); + ShowFatalError(state, format("OpenOutputFiles: Could not open file {} for output (write).", filePath)); } return result; } diff --git a/src/EnergyPlus/SolarShading.cc b/src/EnergyPlus/SolarShading.cc index adbeb77c6ce..30d09da0595 100644 --- a/src/EnergyPlus/SolarShading.cc +++ b/src/EnergyPlus/SolarShading.cc @@ -186,9 +186,8 @@ void InitSolarCalculations(EnergyPlusData &state) state.dataSolarShading->shd_stream = std::make_unique(state.dataStrGlobals->outputShdFilePath, std::ios_base::out | std::ios_base::trunc); if (!state.dataSolarShading->shd_stream) { - ShowFatalError(state, - format("InitSolarCalculations: Could not open file \"{}\" for output (write).", - state.dataStrGlobals->outputShdFilePath.string())); + ShowFatalError( + state, format("InitSolarCalculations: Could not open file \"{}\" for output (write).", state.dataStrGlobals->outputShdFilePath)); } } else { state.dataSolarShading->shd_stream = std::make_unique(nullptr); diff --git a/src/EnergyPlus/TARCOGOutput.cc b/src/EnergyPlus/TARCOGOutput.cc index d42e230c7d5..7cb0680024e 100644 --- a/src/EnergyPlus/TARCOGOutput.cc +++ b/src/EnergyPlus/TARCOGOutput.cc @@ -52,6 +52,7 @@ // EnergyPlus Headers #include #include +#include #include #include #include @@ -291,7 +292,7 @@ void WriteInputArguments(EnergyPlusData &state, print(InArgumentsFile, Format_1007, state.dataTARCOGOutputs->iguID); } - print(InArgumentsFile, " Debug dir: {}\n", DBGD.string()); + print(InArgumentsFile, " Debug dir: {}\n", DBGD); print(InArgumentsFile, "\n"); print(InArgumentsFile, Format_1000); @@ -1267,8 +1268,8 @@ void PrepDebugFilesAndVariables(EnergyPlusData &state, // setup file names if file name is provided, otherwise keep default if (!Debug_file.empty()) { - files.WINCogFilePath = fs::path(Debug_file.string() + ".w7"); - files.DebugOutputFilePath = fs::path(Debug_file.string() + ".dbg"); + files.WINCogFilePath = FileSystem::appendSuffixToPath(Debug_file, ".w7"); + files.DebugOutputFilePath = FileSystem::appendSuffixToPath(Debug_file, ".dbg"); } files.WriteDebugOutput = false; diff --git a/src/EnergyPlus/UtilityRoutines.cc b/src/EnergyPlus/UtilityRoutines.cc index dd63a95befb..5de5db24599 100644 --- a/src/EnergyPlus/UtilityRoutines.cc +++ b/src/EnergyPlus/UtilityRoutines.cc @@ -75,7 +75,7 @@ extern "C" { #include // #include #include -// #include +#include #include #include // #include @@ -431,9 +431,9 @@ namespace Util { if (state.files.outputControl.perflog) { fsPerfLog.open(state.dataStrGlobals->outputPerfLogFilePath, std::fstream::out); // open file normally if (!fsPerfLog) { - ShowFatalError(state, - format("appendPerfLog: Could not open file \"{}\" for output (write).", - state.dataStrGlobals->outputPerfLogFilePath.string())); + ShowFatalError( + state, + format("appendPerfLog: Could not open file \"{}\" for output (write).", state.dataStrGlobals->outputPerfLogFilePath)); } fsPerfLog << state.dataUtilityRoutines->appendPerfLog_headerRow << std::endl; fsPerfLog << state.dataUtilityRoutines->appendPerfLog_valuesRow << std::endl; @@ -442,9 +442,9 @@ namespace Util { if (state.files.outputControl.perflog) { fsPerfLog.open(state.dataStrGlobals->outputPerfLogFilePath, std::fstream::app); // append to already existing file if (!fsPerfLog) { - ShowFatalError(state, - format("appendPerfLog: Could not open file \"{}\" for output (append).", - state.dataStrGlobals->outputPerfLogFilePath.string())); + ShowFatalError( + state, + format("appendPerfLog: Could not open file \"{}\" for output (append).", state.dataStrGlobals->outputPerfLogFilePath)); } fsPerfLog << state.dataUtilityRoutines->appendPerfLog_valuesRow << std::endl; } @@ -576,7 +576,7 @@ int AbortEnergyPlus(EnergyPlusData &state) auto tempfl = state.files.endFile.try_open(state.files.outputControl.end); if (!tempfl.good()) { - DisplayString(state, "AbortEnergyPlus: Could not open file " + tempfl.filePath.string() + " for output (write)."); + DisplayString(state, fmt::format("AbortEnergyPlus: Could not open file {} for output (write).", tempfl.filePath)); } print( tempfl, "EnergyPlus Terminated--Fatal Error Detected. {} Warning; {} Severe Errors; Elapsed Time={}\n", NumWarnings, NumSevere, Elapsed); @@ -712,7 +712,7 @@ int EndEnergyPlus(EnergyPlusData &state) { auto tempfl = state.files.endFile.try_open(state.files.outputControl.end); if (!tempfl.good()) { - DisplayString(state, "EndEnergyPlus: Could not open file " + tempfl.filePath.string() + " for output (write)."); + DisplayString(state, fmt::format("EndEnergyPlus: Could not open file {} for output (write).", tempfl.filePath)); } print(tempfl, "EnergyPlus Completed Successfully-- {} Warning; {} Severe Errors; Elapsed Time={}\n", NumWarnings, NumSevere, Elapsed); } diff --git a/src/EnergyPlus/WeatherManager.cc b/src/EnergyPlus/WeatherManager.cc index 6b267eaf01a..20f2f26a740 100644 --- a/src/EnergyPlus/WeatherManager.cc +++ b/src/EnergyPlus/WeatherManager.cc @@ -8432,7 +8432,7 @@ namespace Weather { auto statFile = state.files.inStatFilePath.try_open(); if (!statFile.good()) { ShowSevereError(state, - format("CalcAnnualAndMonthlyDryBulbTemp: Could not open file {} for input (read).", statFile.filePath.string())); + format("CalcAnnualAndMonthlyDryBulbTemp: Could not open file {} for input (read).", statFile.filePath)); ShowContinueError(state, "Water Mains Temperature will be set to a fixed default value of 10.0 C."); return; } @@ -8453,14 +8453,14 @@ namespace Weather { ShowSevereError( state, format("CalcAnnualAndMonthlyDryBulbTemp: Stat file '{}' does not have Monthly Statistics for Dry Bulb temperatures.", - statFile.filePath.string())); + statFile.filePath)); ShowContinueError(state, "Water Mains Temperature will be set to a fixed default value of 10.0 C."); return; } else if (lineAvg.find("Daily Avg") == std::string::npos) { ShowSevereError(state, format("CalcAnnualAndMonthlyDryBulbTemp: Stat file '{}' does not have the 'Daily Avg' line in the Monthly " "Statistics for Dry Bulb temperatures.", - statFile.filePath.string())); + statFile.filePath)); ShowContinueError(state, "Water Mains Temperature will be set to a fixed default value of 10.0 C."); return; } else { @@ -8482,7 +8482,7 @@ namespace Weather { bool epwHasLeapYear(false); if (!epwFile.good()) { ShowSevereError(state, - format("CalcAnnualAndMonthlyDryBulbTemp: Could not open file {} for input (read).", epwFile.filePath.string())); + format("CalcAnnualAndMonthlyDryBulbTemp: Could not open file {} for input (read).", epwFile.filePath)); ShowContinueError(state, "Water Mains Temperature will be set to a fixed default value of 10.0 C."); return; } @@ -8541,8 +8541,8 @@ namespace Weather { this->OADryBulbWeatherDataProcessed = true; } else { ShowSevereError(state, "CalcAnnualAndMonthlyDryBulbTemp: weather file or stat file does not exist."); - ShowContinueError(state, format("Weather file: {}.", state.files.inputWeatherFilePath.filePath.string())); - ShowContinueError(state, format("Stat file: {}.", state.files.inStatFilePath.filePath.string())); + ShowContinueError(state, format("Weather file: {}.", state.files.inputWeatherFilePath.filePath)); + ShowContinueError(state, format("Stat file: {}.", state.files.inStatFilePath.filePath)); ShowContinueError(state, "Water Mains Monthly Temperature cannot be calculated using CorrelationFromWeatherFile method."); ShowContinueError(state, "Instead a fixed default value of 10.0 C will be used."); } diff --git a/src/EnergyPlus/WindTurbine.cc b/src/EnergyPlus/WindTurbine.cc index 3de7724f34c..ab1ee89df7d 100644 --- a/src/EnergyPlus/WindTurbine.cc +++ b/src/EnergyPlus/WindTurbine.cc @@ -825,7 +825,7 @@ namespace WindTurbine { ShowWarningError(state, format("InitWindTurbine: read from {} file shows <365 days in weather file. Annual average " "wind speed used will be inaccurate.", - state.files.inStatFilePath.filePath.string())); + state.files.inStatFilePath.filePath)); lineIn.data.erase(0, lnPtr + 1); warningShown = true; } @@ -835,7 +835,7 @@ namespace WindTurbine { ShowWarningError(state, format("InitWindTurbine: read from {} file shows <365 days in weather file. Annual average wind " "speed used will be inaccurate.", - state.files.inStatFilePath.filePath.string())); + state.files.inStatFilePath.filePath)); lineIn.data.erase(0, lnPtr + 1); warningShown = true; } diff --git a/src/EnergyPlus/ZoneTempPredictorCorrector.cc b/src/EnergyPlus/ZoneTempPredictorCorrector.cc index 52944be15e9..20783b681b4 100644 --- a/src/EnergyPlus/ZoneTempPredictorCorrector.cc +++ b/src/EnergyPlus/ZoneTempPredictorCorrector.cc @@ -2690,7 +2690,7 @@ void CalculateMonthlyRunningAverageDryBulb(EnergyPlusData &state, Array1D Date: Mon, 8 Jul 2024 22:19:41 +0200 Subject: [PATCH 48/57] tweak toString to use a type_traits too --- src/EnergyPlus/FileSystem.cc | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/EnergyPlus/FileSystem.cc b/src/EnergyPlus/FileSystem.cc index 9f573a96a39..ff8484e9556 100644 --- a/src/EnergyPlus/FileSystem.cc +++ b/src/EnergyPlus/FileSystem.cc @@ -53,6 +53,7 @@ #include #include #include +#include #ifdef _WIN32 #include @@ -404,12 +405,11 @@ namespace FileSystem { std::string toString(fs::path const &p) { - return CLI::detail::maybe_narrow(p.c_str()); - // if constexpr (std::is_same_v) { - // return CLI::narrow(p.wstring()); - // } else { - // return p.string(); - // } + if constexpr (std::is_same_v) { + return CLI::narrow(p.wstring()); + } else { + return p.string(); + } } std::string toGenericString(fs::path const &p) From 83d7cf3f96e2d916a995161f48535ddb065aebdc Mon Sep 17 00:00:00 2001 From: Julien Marrec Date: Mon, 8 Jul 2024 22:22:16 +0200 Subject: [PATCH 49/57] update ExternalInterface --- src/EnergyPlus/ExternalInterface.cc | 31 +++++++++++++---------------- 1 file changed, 14 insertions(+), 17 deletions(-) diff --git a/src/EnergyPlus/ExternalInterface.cc b/src/EnergyPlus/ExternalInterface.cc index d36372fd93c..30e6ff105df 100644 --- a/src/EnergyPlus/ExternalInterface.cc +++ b/src/EnergyPlus/ExternalInterface.cc @@ -324,7 +324,7 @@ void CloseSocket(EnergyPlusData &state, int const FlagToWriteToSocket) bool fileExist = FileSystem::fileExists(state.dataExternalInterface->socCfgFilPath); if ((state.dataExternalInterface->socketFD == -1) && fileExist) { - state.dataExternalInterface->socketFD = establishclientsocket(state.dataExternalInterface->socCfgFilPath.string().c_str()); + state.dataExternalInterface->socketFD = establishclientsocket(FileSystem::toString(state.dataExternalInterface->socCfgFilPath).c_str()); } if (state.dataExternalInterface->socketFD >= 0) { @@ -398,14 +398,14 @@ void InitExternalInterface(EnergyPlusData &state) // Get port number if (FileSystem::fileExists(state.dataExternalInterface->socCfgFilPath)) { - state.dataExternalInterface->socketFD = establishclientsocket(state.dataExternalInterface->socCfgFilPath.string().c_str()); + state.dataExternalInterface->socketFD = establishclientsocket(FileSystem::toString(state.dataExternalInterface->socCfgFilPath).c_str()); if (state.dataExternalInterface->socketFD < 0) { ShowSevereError(state, format("ExternalInterface: Could not open socket. File descriptor = {}.", state.dataExternalInterface->socketFD)); state.dataExternalInterface->ErrorsFound = true; } } else { - ShowSevereError(state, format("ExternalInterface: Did not find file \"{}\".", state.dataExternalInterface->socCfgFilPath.string())); + ShowSevereError(state, format("ExternalInterface: Did not find file \"{}\".", state.dataExternalInterface->socCfgFilPath)); ShowContinueError(state, "This file needs to be in same directory as in.idf."); ShowContinueError(state, "Check the documentation for the ExternalInterface."); state.dataExternalInterface->ErrorsFound = true; @@ -833,7 +833,7 @@ void InstantiateInitializeFMUImport(EnergyPlusData &state) // Instantiate FMUs for (int i = 1; i <= state.dataExternalInterface->NumFMUObjects; ++i) { for (int j = 1; j <= state.dataExternalInterface->FMU(i).NumInstances; ++j) { - std::string const &folderStr = state.dataExternalInterface->FMU(i).Instance(j).WorkingFolder.string(); + std::string const folderStr = FileSystem::toString(state.dataExternalInterface->FMU(i).Instance(j).WorkingFolder); state.dataExternalInterface->FMU(i).Instance(j).fmicomponent = fmiEPlusInstantiateSlave((char *)folderStr.c_str(), &state.dataExternalInterface->FMU(i).Instance(j).LenWorkingFolder, @@ -1024,7 +1024,7 @@ void InitExternalInterfaceFMUImport(EnergyPlusData &state) strippedFileName(Loop) = state.dataExternalInterface->FMU(Loop).Name; } } - fullFileName(Loop) = tempFullFilePath.string(); + fullFileName(Loop) = FileSystem::toString(tempFullFilePath); } else { state.dataExternalInterface->ErrorsFound = true; } @@ -1132,14 +1132,13 @@ void InitExternalInterfaceFMUImport(EnergyPlusData &state) for (int i = 1; i <= state.dataExternalInterface->NumFMUObjects; ++i) { for (int j = 1; j <= state.dataExternalInterface->FMU(i).NumInstances; ++j) { // get the length of working folder trimmed - state.dataExternalInterface->FMU(i).Instance(j).LenWorkingFolder = - state.dataExternalInterface->FMU(i).Instance(j).WorkingFolder.string().length(); + std::string const workingFolderStr = FileSystem::toString(state.dataExternalInterface->FMU(i).Instance(j).WorkingFolder); + state.dataExternalInterface->FMU(i).Instance(j).LenWorkingFolder = workingFolderStr.length(); // unpack fmus // preprocess arguments for library call { std::vector fullFileNameArr(getCharArrayFromString(fullFileName(i))); - std::vector workingFolderArr( - getCharArrayFromString(state.dataExternalInterface->FMU(i).Instance(j).WorkingFolder.string())); + std::vector workingFolderArr(getCharArrayFromString(workingFolderStr)); int lenFileName(len(fullFileName(i))); // make the library call @@ -1158,8 +1157,7 @@ void InitExternalInterfaceFMUImport(EnergyPlusData &state) { // determine modelID and modelGUID of all FMU instances // preprocess arguments for library call - std::vector workingFolderArr( - getCharArrayFromString(state.dataExternalInterface->FMU(i).Instance(j).WorkingFolder.string())); + std::vector workingFolderArr(getCharArrayFromString(workingFolderStr)); // make the library call state.dataExternalInterface->FMU(i).Instance(j).Index = @@ -1185,13 +1183,12 @@ void InitExternalInterfaceFMUImport(EnergyPlusData &state) { // get the path to the binaries // preprocess args for library call - std::vector workingFolderArr( - getCharArrayFromString(state.dataExternalInterface->FMU(i).Instance(j).WorkingFolder.string())); + std::vector workingFolderArr(getCharArrayFromString(workingFolderStr)); // Reserve some space in the string, becasue addLibPathCurrentWorkflowFolder doesn't allocate memory for the // workingFolderWithLibArr Note: you can't call str.resize(str.length() + 91) because the conversion to std::vector will // find the null terminator and so it will have no effect - std::string reservedString = state.dataExternalInterface->FMU(i).Instance(j).WorkingFolder.string() + - " "; + std::string reservedString = + workingFolderStr + " "; std::vector workingFolderWithLibArr(getCharArrayFromString(reservedString)); // make the library call @@ -1218,14 +1215,14 @@ void InitExternalInterfaceFMUImport(EnergyPlusData &state) // get the length of the working folder with libraries state.dataExternalInterface->FMU(i).Instance(j).LenWorkingFolder_wLib = - state.dataExternalInterface->FMU(i).Instance(j).WorkingFolder_wLib.string().length(); + FileSystem::toString(state.dataExternalInterface->FMU(i).Instance(j).WorkingFolder_wLib).length(); } { // determine the FMI version // preprocess args for library call std::vector workingFolderWithLibArr( - getCharArrayFromString(state.dataExternalInterface->FMU(i).Instance(j).WorkingFolder_wLib.string())); + getCharArrayFromString(FileSystem::toString(state.dataExternalInterface->FMU(i).Instance(j).WorkingFolder_wLib))); std::vector VersionNumArr( getCharArrayFromString(" ")); // the version should only be 3 characters long, since for now we only handle "1.0" From 48eb2eb3e40c43cc4a30faf4fc9848fbd5520d2f Mon Sep 17 00:00:00 2001 From: Julien Marrec Date: Tue, 23 Jul 2024 06:56:16 +0200 Subject: [PATCH 50/57] Remove debug code in SQLiteProcedures --- src/EnergyPlus/SQLiteProcedures.cc | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/src/EnergyPlus/SQLiteProcedures.cc b/src/EnergyPlus/SQLiteProcedures.cc index 56b7e53f825..5cd1aa4d2b1 100644 --- a/src/EnergyPlus/SQLiteProcedures.cc +++ b/src/EnergyPlus/SQLiteProcedures.cc @@ -2607,21 +2607,11 @@ SQLiteProcedures::SQLiteProcedures(std::shared_ptr const &errorStr fs::path const &errorFilePath) : m_writeOutputToSQLite(writeOutputToSQLite), m_errorStream(errorStream) { - constexpr bool debug = true; - sqlite3 *m_connection = nullptr; if (m_writeOutputToSQLite) { int rc = -1; bool ok = true; - if constexpr (debug) { - // std::cout << "errorStream=" << errorStream << ", dbName=" << dbName << std::endl; - // std::cout << "dbName.string()=" << dbName.string() << std::endl; - // std::cout << "dbName.generic_string()=" << dbName.generic_string() << std::endl; - std::wcout << "dbName.generic_wstring()=" << dbName.generic_wstring() << std::endl; - std::cout << "narrow(dbName.generic_wstring())=" << FileSystem::toGenericString(dbName) << std::endl; - } - std::string const dbName_utf8 = FileSystem::toGenericString(dbName); // Test if we can write to the sqlite error file @@ -2631,9 +2621,6 @@ SQLiteProcedures::SQLiteProcedures(std::shared_ptr const &errorStr } else { ok = false; } - if constexpr (debug) { - std::cout << "m_errorStream: " << std::boolalpha << ok << std::endl; - } // Test if we can create a new file named dbName if (ok && dbName != ":memory:") { @@ -2644,9 +2631,6 @@ SQLiteProcedures::SQLiteProcedures(std::shared_ptr const &errorStr ok = false; } } - if constexpr (debug) { - std::cout << "ofstream dbName: " << std::boolalpha << ok << std::endl; - } // Test if we can write to the database // If we can't then there are probably locks on the database @@ -2656,14 +2640,8 @@ SQLiteProcedures::SQLiteProcedures(std::shared_ptr const &errorStr if (rc) { *m_errorStream << "SQLite3 message, can't get exclusive lock to open database: " << sqlite3_errmsg(m_connection) << std::endl; ok = false; - if constexpr (debug) { - std::cout << "sqlite3_open_v2: " << std::boolalpha << ok << ' ' << sqlite3_errmsg(m_connection) << std::endl; - } } } - if constexpr (debug) { - std::cout << "sqlite3_open_v2: " << std::boolalpha << ok << std::endl; - } if (ok) { char *zErrMsg = nullptr; From f7be7486ea9f8166aa0903064ea8b9ec350a9504 Mon Sep 17 00:00:00 2001 From: Rick Strand Date: Tue, 23 Jul 2024 06:20:48 -0500 Subject: [PATCH 51/57] 10299 Another Round of Unit Test Fixes Last round was closer to getting rid of all of the unit test fails. Hopefully this gets everything fixed up and ready to go. --- tst/EnergyPlus/unit/SolarShading.unit.cc | 52 ++++++++++++++++++++---- 1 file changed, 43 insertions(+), 9 deletions(-) diff --git a/tst/EnergyPlus/unit/SolarShading.unit.cc b/tst/EnergyPlus/unit/SolarShading.unit.cc index 1b1c9949b27..aa28eb96a4a 100644 --- a/tst/EnergyPlus/unit/SolarShading.unit.cc +++ b/tst/EnergyPlus/unit/SolarShading.unit.cc @@ -3892,22 +3892,33 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_Warn_Pixel_Count_and_TM_Schedule) EXPECT_EQ(state->dataSolarShading->anyScheduledShadingSurface, true); +#ifdef EP_NO_OPENGL EXPECT_EQ(state->dataErrTracking->AskForSurfacesReport, true); - EXPECT_EQ(state->dataErrTracking->TotalWarningErrors, 1); - // Expect no severe errors at this point + EXPECT_EQ(state->dataErrTracking->TotalWarningErrors, 2); EXPECT_EQ(state->dataErrTracking->TotalSevereErrors, 0); +#else + if (!Penumbra::Penumbra::is_valid_context()) { + EXPECT_EQ(state->dataErrTracking->AskForSurfacesReport, true); + EXPECT_EQ(state->dataErrTracking->TotalWarningErrors, 2); + EXPECT_EQ(state->dataErrTracking->TotalSevereErrors, 0); + } else { + EXPECT_EQ(state->dataErrTracking->AskForSurfacesReport, true); + EXPECT_EQ(state->dataErrTracking->TotalWarningErrors, 1); + EXPECT_EQ(state->dataErrTracking->TotalSevereErrors, 0); + } +#endif SolarShading::processShadowingInput(*state); #ifdef EP_NO_OPENGL - EXPECT_EQ(state->dataErrTracking->TotalWarningErrors, 1); + EXPECT_EQ(state->dataErrTracking->TotalWarningErrors, 2); EXPECT_EQ(state->dataErrTracking->TotalSevereErrors, 0; EXPECT_EQ(state->dataErrTracking->LastSevereError, ""); #else if (!Penumbra::Penumbra::is_valid_context()) { EXPECT_EQ(state->dataErrTracking->TotalWarningErrors, 2); - EXPECT_EQ(state->dataErrTracking->TotalSevereErrors, 1); - EXPECT_EQ(state->dataErrTracking->LastSevereError, "The Shading Calculation Method of choice is \"PixelCounting\"; "); + EXPECT_EQ(state->dataErrTracking->TotalSevereErrors, 0); + EXPECT_EQ(state->dataErrTracking->LastSevereError, ""); } else { EXPECT_EQ(state->dataErrTracking->TotalWarningErrors, 1); EXPECT_EQ(state->dataErrTracking->TotalSevereErrors, 1); @@ -6083,7 +6094,16 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_GetShadowingInputTest4) EXPECT_EQ(expectedOverlaps, state->dataSolarShading->MaxHCS); EXPECT_FALSE(state->dataSysVars->SutherlandHodgman); EXPECT_FALSE(state->dataSysVars->SlaterBarsky); - EXPECT_ENUM_EQ(state->dataSysVars->shadingMethod, ShadingMethod::PixelCounting); + +#ifdef EP_NO_OPENGL + EXPECT_ENUM_EQ(state->dataSysVars->shadingMethod, ShadingMethod::PolygonClipping); +#else + if (!Penumbra::Penumbra::is_valid_context()) { + EXPECT_ENUM_EQ(state->dataSysVars->shadingMethod, ShadingMethod::PolygonClipping); + } else { + EXPECT_ENUM_EQ(state->dataSysVars->shadingMethod, ShadingMethod::PixelCounting); + } +#endif } TEST_F(EnergyPlusFixture, SolarShadingTest_GetShadowingInputTest5) @@ -6116,7 +6136,16 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_GetShadowingInputTest5) EXPECT_EQ(expectedOverlaps, state->dataSolarShading->MaxHCS); EXPECT_TRUE(state->dataSysVars->SutherlandHodgman); EXPECT_FALSE(state->dataSysVars->SlaterBarsky); - EXPECT_ENUM_EQ(state->dataSysVars->shadingMethod, ShadingMethod::PixelCounting); + +#ifdef EP_NO_OPENGL + EXPECT_ENUM_EQ(state->dataSysVars->shadingMethod, ShadingMethod::PolygonClipping); +#else + if (!Penumbra::Penumbra::is_valid_context()) { + EXPECT_ENUM_EQ(state->dataSysVars->shadingMethod, ShadingMethod::PolygonClipping); + } else { + EXPECT_ENUM_EQ(state->dataSysVars->shadingMethod, ShadingMethod::PixelCounting); + } +#endif } TEST_F(EnergyPlusFixture, SolarShadingTest_GetShadowingInputTest6) @@ -6150,7 +6179,6 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_GetShadowingInputTest6) EXPECT_EQ(expectedOverlaps, state->dataSolarShading->MaxHCS); EXPECT_TRUE(state->dataSysVars->SutherlandHodgman); EXPECT_TRUE(state->dataSysVars->SlaterBarsky); - EXPECT_ENUM_EQ(state->dataSysVars->shadingMethod, ShadingMethod::PixelCounting); #ifdef EP_NO_OPENGL std::string const error_string = delimited_string({" ** Warning ** ShadowCalculation: suspect Shading Calculation Update Frequency", @@ -6158,15 +6186,21 @@ TEST_F(EnergyPlusFixture, SolarShadingTest_GetShadowingInputTest6) " ** Warning ** No GPU found (required for PixelCounting)", " ** ~~~ ** PolygonClipping will be used instead"}); EXPECT_TRUE(compare_err_stream(error_string, true)); + EXPECT_ENUM_EQ(state->dataSysVars->shadingMethod, ShadingMethod::PolygonClipping); + #else if (!Penumbra::Penumbra::is_valid_context()) { std::string const error_string = delimited_string({" ** Warning ** ShadowCalculation: suspect Shading Calculation Update Frequency", - " ** ~~~ ** Value entered=[56], Shadowing Calculations will be inaccurate."}); + " ** ~~~ ** Value entered=[56], Shadowing Calculations will be inaccurate.", + " ** Warning ** No GPU found (required for PixelCounting)", + " ** ~~~ ** PolygonClipping will be used instead"}); EXPECT_TRUE(compare_err_stream(error_string, true)); + EXPECT_ENUM_EQ(state->dataSysVars->shadingMethod, ShadingMethod::PolygonClipping); } else { std::string const error_string = delimited_string({" ** Warning ** ShadowCalculation: suspect Shading Calculation Update Frequency", " ** ~~~ ** Value entered=[56], Shadowing Calculations will be inaccurate."}); EXPECT_TRUE(compare_err_stream(error_string, true)); + EXPECT_ENUM_EQ(state->dataSysVars->shadingMethod, ShadingMethod::PixelCounting); } #endif } From 0a0aa68b8497ee4874c39aca38ccb7113a18c06e Mon Sep 17 00:00:00 2001 From: Rick Strand Date: Tue, 23 Jul 2024 14:50:21 -0500 Subject: [PATCH 52/57] 10299 Get Rid of Unneeded Get Flag A get flag was added early on during work on this defect. It is not necessary and may be causing some issues with API runs. Even if that isn't the problem, there is no reason to keep this flag/code--it's unnecessary. --- src/EnergyPlus/SolarShading.cc | 5 ----- src/EnergyPlus/SolarShading.hh | 1 - 2 files changed, 6 deletions(-) diff --git a/src/EnergyPlus/SolarShading.cc b/src/EnergyPlus/SolarShading.cc index e166aed955a..638d1b57f25 100644 --- a/src/EnergyPlus/SolarShading.cc +++ b/src/EnergyPlus/SolarShading.cc @@ -411,11 +411,6 @@ void GetShadowingInput(EnergyPlusData &state) using DataSystemVariables::ShadingMethod; // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - if (state.dataSolarShading->getShadowingCalculationInput) { - state.dataSolarShading->getShadowingCalculationInput = false; - } else { - return; - } int NumItems; int NumNumbers; int NumAlphas; diff --git a/src/EnergyPlus/SolarShading.hh b/src/EnergyPlus/SolarShading.hh index bd466b327bf..5e3d62e5f41 100644 --- a/src/EnergyPlus/SolarShading.hh +++ b/src/EnergyPlus/SolarShading.hh @@ -437,7 +437,6 @@ struct SolarShadingData : BaseGlobalStruct #endif bool GetInputFlag = true; - bool getShadowingCalculationInput = true; bool anyScheduledShadingSurface = false; bool firstTime = true; bool debugging = false; From 5664dfa35f5109fa181cda55195411e046550703 Mon Sep 17 00:00:00 2001 From: Rick Strand Date: Wed, 24 Jul 2024 06:59:33 -0500 Subject: [PATCH 53/57] 10299 Clang Format Final Missed clang formatting on a file... --- src/EnergyPlus/DataSystemVariables.hh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/EnergyPlus/DataSystemVariables.hh b/src/EnergyPlus/DataSystemVariables.hh index 156d628ab01..e8506ce2439 100644 --- a/src/EnergyPlus/DataSystemVariables.hh +++ b/src/EnergyPlus/DataSystemVariables.hh @@ -115,8 +115,8 @@ struct SystemVarsData : BaseGlobalStruct bool DisableSelfShadingWithinGroup = false; bool DisableSelfShadingBetweenGroup = false; - int shadingGroupsNum = 0; // number of shading groups - Array1D_string zoneName; // array of zone names in user input + int shadingGroupsNum = 0; // number of shading groups + Array1D_string zoneName; // array of zone names in user input bool TrackAirLoopEnvFlag = false; // If TRUE generates a file with runtime statistics for each HVAC // controller on each air loop From a0cff9a04860e25e5091e1048f18b31a36038ba7 Mon Sep 17 00:00:00 2001 From: Rick Strand Date: Wed, 24 Jul 2024 15:25:33 -0500 Subject: [PATCH 54/57] 10299 Request to Improve Variable Name Addressed review request to change the name of a variable to be more descriptive. --- src/EnergyPlus/DataSystemVariables.hh | 4 ++-- src/EnergyPlus/SolarShading.cc | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/EnergyPlus/DataSystemVariables.hh b/src/EnergyPlus/DataSystemVariables.hh index e8506ce2439..5d4eedc1c54 100644 --- a/src/EnergyPlus/DataSystemVariables.hh +++ b/src/EnergyPlus/DataSystemVariables.hh @@ -115,8 +115,8 @@ struct SystemVarsData : BaseGlobalStruct bool DisableSelfShadingWithinGroup = false; bool DisableSelfShadingBetweenGroup = false; - int shadingGroupsNum = 0; // number of shading groups - Array1D_string zoneName; // array of zone names in user input + int shadingGroupsNum = 0; // number of shading groups + Array1D_string shadingGroupZoneListNames; // array of zone names in user input bool TrackAirLoopEnvFlag = false; // If TRUE generates a file with runtime statistics for each HVAC // controller on each air loop diff --git a/src/EnergyPlus/SolarShading.cc b/src/EnergyPlus/SolarShading.cc index 638d1b57f25..6c95f90459a 100644 --- a/src/EnergyPlus/SolarShading.cc +++ b/src/EnergyPlus/SolarShading.cc @@ -658,9 +658,9 @@ void GetShadowingInput(EnergyPlusData &state) aNum++; state.dataSysVars->shadingGroupsNum = NumAlphas - (aNum - 1); - state.dataSysVars->zoneName.allocate(state.dataSysVars->shadingGroupsNum); + state.dataSysVars->shadingGroupZoneListNames.allocate(state.dataSysVars->shadingGroupsNum); for (int numZone = 1; numZone <= state.dataSysVars->shadingGroupsNum; ++numZone) { - state.dataSysVars->zoneName(numZone) = state.dataIPShortCut->cAlphaArgs(aNum - 1 + numZone); + state.dataSysVars->shadingGroupZoneListNames(numZone) = state.dataIPShortCut->cAlphaArgs(aNum - 1 + numZone); } if (!state.dataSysVars->DetailedSolarTimestepIntegration && state.dataSurface->ShadingTransmittanceVaries && @@ -757,7 +757,8 @@ void processShadowingInput(EnergyPlusData &state) if (NumOfShadingGroups > 0) { DisableSelfShadingGroups.allocate(NumOfShadingGroups); for (int i = 1; i <= NumOfShadingGroups; i++) { - Found = Util::FindItemInList(state.dataSysVars->zoneName(i), state.dataHeatBal->ZoneList, state.dataHeatBal->NumOfZoneLists); + Found = Util::FindItemInList( + state.dataSysVars->shadingGroupZoneListNames(i), state.dataHeatBal->ZoneList, state.dataHeatBal->NumOfZoneLists); if (Found != 0) DisableSelfShadingGroups(i) = Found; } From ef9b8161be68fc976213e30bd05fbb4896ad0c31 Mon Sep 17 00:00:00 2001 From: Rick Strand Date: Wed, 24 Jul 2024 21:49:05 -0500 Subject: [PATCH 55/57] 10299 Back Out Variable Name Change Something not quite right about this simply variable name change. Things went from expected diffs only to "unexpected" diffs. --- src/EnergyPlus/DataSystemVariables.hh | 4 ++-- src/EnergyPlus/SolarShading.cc | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/src/EnergyPlus/DataSystemVariables.hh b/src/EnergyPlus/DataSystemVariables.hh index 5d4eedc1c54..e8506ce2439 100644 --- a/src/EnergyPlus/DataSystemVariables.hh +++ b/src/EnergyPlus/DataSystemVariables.hh @@ -115,8 +115,8 @@ struct SystemVarsData : BaseGlobalStruct bool DisableSelfShadingWithinGroup = false; bool DisableSelfShadingBetweenGroup = false; - int shadingGroupsNum = 0; // number of shading groups - Array1D_string shadingGroupZoneListNames; // array of zone names in user input + int shadingGroupsNum = 0; // number of shading groups + Array1D_string zoneName; // array of zone names in user input bool TrackAirLoopEnvFlag = false; // If TRUE generates a file with runtime statistics for each HVAC // controller on each air loop diff --git a/src/EnergyPlus/SolarShading.cc b/src/EnergyPlus/SolarShading.cc index 6c95f90459a..638d1b57f25 100644 --- a/src/EnergyPlus/SolarShading.cc +++ b/src/EnergyPlus/SolarShading.cc @@ -658,9 +658,9 @@ void GetShadowingInput(EnergyPlusData &state) aNum++; state.dataSysVars->shadingGroupsNum = NumAlphas - (aNum - 1); - state.dataSysVars->shadingGroupZoneListNames.allocate(state.dataSysVars->shadingGroupsNum); + state.dataSysVars->zoneName.allocate(state.dataSysVars->shadingGroupsNum); for (int numZone = 1; numZone <= state.dataSysVars->shadingGroupsNum; ++numZone) { - state.dataSysVars->shadingGroupZoneListNames(numZone) = state.dataIPShortCut->cAlphaArgs(aNum - 1 + numZone); + state.dataSysVars->zoneName(numZone) = state.dataIPShortCut->cAlphaArgs(aNum - 1 + numZone); } if (!state.dataSysVars->DetailedSolarTimestepIntegration && state.dataSurface->ShadingTransmittanceVaries && @@ -757,8 +757,7 @@ void processShadowingInput(EnergyPlusData &state) if (NumOfShadingGroups > 0) { DisableSelfShadingGroups.allocate(NumOfShadingGroups); for (int i = 1; i <= NumOfShadingGroups; i++) { - Found = Util::FindItemInList( - state.dataSysVars->shadingGroupZoneListNames(i), state.dataHeatBal->ZoneList, state.dataHeatBal->NumOfZoneLists); + Found = Util::FindItemInList(state.dataSysVars->zoneName(i), state.dataHeatBal->ZoneList, state.dataHeatBal->NumOfZoneLists); if (Found != 0) DisableSelfShadingGroups(i) = Found; } From 08909a8817b679e9c4d2898e559a6c25f01fe242 Mon Sep 17 00:00:00 2001 From: Rick Strand Date: Thu, 25 Jul 2024 06:48:14 -0500 Subject: [PATCH 56/57] 10299 Attempt 2 at Variable Rename Trying again to rename a variable. This seemed to cause a lot of issues yesterday, but was that because of changes to develop that were happening at the same time? --- src/EnergyPlus/DataSystemVariables.hh | 4 ++-- src/EnergyPlus/SolarShading.cc | 7 ++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/EnergyPlus/DataSystemVariables.hh b/src/EnergyPlus/DataSystemVariables.hh index e8506ce2439..5d4eedc1c54 100644 --- a/src/EnergyPlus/DataSystemVariables.hh +++ b/src/EnergyPlus/DataSystemVariables.hh @@ -115,8 +115,8 @@ struct SystemVarsData : BaseGlobalStruct bool DisableSelfShadingWithinGroup = false; bool DisableSelfShadingBetweenGroup = false; - int shadingGroupsNum = 0; // number of shading groups - Array1D_string zoneName; // array of zone names in user input + int shadingGroupsNum = 0; // number of shading groups + Array1D_string shadingGroupZoneListNames; // array of zone names in user input bool TrackAirLoopEnvFlag = false; // If TRUE generates a file with runtime statistics for each HVAC // controller on each air loop diff --git a/src/EnergyPlus/SolarShading.cc b/src/EnergyPlus/SolarShading.cc index 638d1b57f25..6c95f90459a 100644 --- a/src/EnergyPlus/SolarShading.cc +++ b/src/EnergyPlus/SolarShading.cc @@ -658,9 +658,9 @@ void GetShadowingInput(EnergyPlusData &state) aNum++; state.dataSysVars->shadingGroupsNum = NumAlphas - (aNum - 1); - state.dataSysVars->zoneName.allocate(state.dataSysVars->shadingGroupsNum); + state.dataSysVars->shadingGroupZoneListNames.allocate(state.dataSysVars->shadingGroupsNum); for (int numZone = 1; numZone <= state.dataSysVars->shadingGroupsNum; ++numZone) { - state.dataSysVars->zoneName(numZone) = state.dataIPShortCut->cAlphaArgs(aNum - 1 + numZone); + state.dataSysVars->shadingGroupZoneListNames(numZone) = state.dataIPShortCut->cAlphaArgs(aNum - 1 + numZone); } if (!state.dataSysVars->DetailedSolarTimestepIntegration && state.dataSurface->ShadingTransmittanceVaries && @@ -757,7 +757,8 @@ void processShadowingInput(EnergyPlusData &state) if (NumOfShadingGroups > 0) { DisableSelfShadingGroups.allocate(NumOfShadingGroups); for (int i = 1; i <= NumOfShadingGroups; i++) { - Found = Util::FindItemInList(state.dataSysVars->zoneName(i), state.dataHeatBal->ZoneList, state.dataHeatBal->NumOfZoneLists); + Found = Util::FindItemInList( + state.dataSysVars->shadingGroupZoneListNames(i), state.dataHeatBal->ZoneList, state.dataHeatBal->NumOfZoneLists); if (Found != 0) DisableSelfShadingGroups(i) = Found; } From ba5a73f4772d0b1a9ae68b0540c192bc78777dd4 Mon Sep 17 00:00:00 2001 From: Edwin Lee Date: Thu, 25 Jul 2024 14:57:41 -0500 Subject: [PATCH 57/57] Applied clang format --- src/EnergyPlus/CurveManager.cc | 18 ++++++++---------- src/EnergyPlus/FileSystem.hh | 2 +- src/EnergyPlus/WeatherManager.cc | 6 ++---- 3 files changed, 11 insertions(+), 15 deletions(-) diff --git a/src/EnergyPlus/CurveManager.cc b/src/EnergyPlus/CurveManager.cc index f000fde6243..e8c3faec990 100644 --- a/src/EnergyPlus/CurveManager.cc +++ b/src/EnergyPlus/CurveManager.cc @@ -2308,13 +2308,12 @@ namespace Curve { std::string tmp = indVarInstance.at("external_file_name").get(); fs::path filePath(tmp); if (!indVarInstance.count("external_file_column_number")) { - ShowSevereError(state, - format("{}: No column number defined for external file \"{}\"", contextString, filePath)); + ShowSevereError(state, format("{}: No column number defined for external file \"{}\"", contextString, filePath)); ErrorsFound = true; } if (!indVarInstance.count("external_file_starting_row_number")) { - ShowSevereError( - state, format("{}: No starting row number defined for external file \"{}\"", contextString, filePath)); + ShowSevereError(state, + format("{}: No starting row number defined for external file \"{}\"", contextString, filePath)); ErrorsFound = true; } @@ -2511,8 +2510,7 @@ namespace Curve { ErrorsFound = true; } if (!fields.count("external_file_starting_row_number")) { - ShowSevereError(state, - format("{}: No starting row number defined for external file \"{}\"", contextString, filePath)); + ShowSevereError(state, format("{}: No starting row number defined for external file \"{}\"", contextString, filePath)); ErrorsFound = true; } @@ -2681,12 +2679,12 @@ namespace Curve { std::size_t row = colAndRow.second; // 0 indexed auto &content = contents[col]; if (col >= numColumns) { - ShowFatalError( - state, format("File \"{}\" : Requested column ({}) exceeds the number of columns ({}).", filePath, col + 1, numColumns)); + ShowFatalError(state, + format("File \"{}\" : Requested column ({}) exceeds the number of columns ({}).", filePath, col + 1, numColumns)); } if (row >= numRows) { - ShowFatalError( - state, format("File \"{}\" : Requested starting row ({}) exceeds the number of rows ({}).", filePath, row + 1, numRows)); + ShowFatalError(state, + format("File \"{}\" : Requested starting row ({}) exceeds the number of rows ({}).", filePath, row + 1, numRows)); } std::vector array(numRows - row); std::transform(content.begin() + row, content.end(), array.begin(), [](std::string_view str) { diff --git a/src/EnergyPlus/FileSystem.hh b/src/EnergyPlus/FileSystem.hh index fc1c926237f..64a274359e4 100644 --- a/src/EnergyPlus/FileSystem.hh +++ b/src/EnergyPlus/FileSystem.hh @@ -317,7 +317,7 @@ namespace FileSystem { std::string toGenericString(fs::path const &p); - fs::path appendSuffixToPath(fs::path const& outputFilePrefixFullPath, const std::string &suffix); + fs::path appendSuffixToPath(fs::path const &outputFilePrefixFullPath, const std::string &suffix); } // namespace FileSystem } // namespace EnergyPlus diff --git a/src/EnergyPlus/WeatherManager.cc b/src/EnergyPlus/WeatherManager.cc index 20f2f26a740..15daa081ab9 100644 --- a/src/EnergyPlus/WeatherManager.cc +++ b/src/EnergyPlus/WeatherManager.cc @@ -8431,8 +8431,7 @@ namespace Weather { if (statFileExists) { auto statFile = state.files.inStatFilePath.try_open(); if (!statFile.good()) { - ShowSevereError(state, - format("CalcAnnualAndMonthlyDryBulbTemp: Could not open file {} for input (read).", statFile.filePath)); + ShowSevereError(state, format("CalcAnnualAndMonthlyDryBulbTemp: Could not open file {} for input (read).", statFile.filePath)); ShowContinueError(state, "Water Mains Temperature will be set to a fixed default value of 10.0 C."); return; } @@ -8481,8 +8480,7 @@ namespace Weather { auto epwFile = state.files.inputWeatherFilePath.try_open(); bool epwHasLeapYear(false); if (!epwFile.good()) { - ShowSevereError(state, - format("CalcAnnualAndMonthlyDryBulbTemp: Could not open file {} for input (read).", epwFile.filePath)); + ShowSevereError(state, format("CalcAnnualAndMonthlyDryBulbTemp: Could not open file {} for input (read).", epwFile.filePath)); ShowContinueError(state, "Water Mains Temperature will be set to a fixed default value of 10.0 C."); return; }