From 433593a95acc2dfa549ad9044c1f80f86554fc7a Mon Sep 17 00:00:00 2001 From: "Michael J. Witte" Date: Thu, 12 Sep 2024 21:29:54 -0500 Subject: [PATCH 1/4] Avoid wshp array bounds --- src/EnergyPlus/UnitarySystem.cc | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/EnergyPlus/UnitarySystem.cc b/src/EnergyPlus/UnitarySystem.cc index 9da1b5a1573..ae6df3b5661 100644 --- a/src/EnergyPlus/UnitarySystem.cc +++ b/src/EnergyPlus/UnitarySystem.cc @@ -3164,9 +3164,11 @@ namespace UnitarySystems { HVAC::CompressorOp::Off, 0.0, FirstHVACIteration); - state.dataSize->DataConstantUsedForSizing = WaterToAirHeatPumpSimple::GetCoilCapacity( - state, HVAC::cAllCoilTypes(this->m_CoolingCoilType_Num), this->m_CoolingCoilName, ErrFound); - EqSizing.DesCoolingLoad = state.dataSize->DataConstantUsedForSizing; + if (this->m_CoolCoilExists) { + state.dataSize->DataConstantUsedForSizing = WaterToAirHeatPumpSimple::GetCoilCapacity( + state, HVAC::cAllCoilTypes(this->m_CoolingCoilType_Num), this->m_CoolingCoilName, ErrFound); + EqSizing.DesCoolingLoad = state.dataSize->DataConstantUsedForSizing; + } state.dataSize->DataFractionUsedForSizing = 1.0; this->m_DesignCoolingCapacity = DataSizing::AutoSize; // airflow sizing with multispeed fan From 5289b309500a3e5eff61b87570f98be901b9ad94 Mon Sep 17 00:00:00 2001 From: rraustad Date: Wed, 18 Sep 2024 23:32:01 -0400 Subject: [PATCH 2/4] Protect companion coil for heating coil in sizing --- src/EnergyPlus/UnitarySystem.cc | 3 +- src/EnergyPlus/WaterToAirHeatPumpSimple.cc | 152 +++++++++++---------- 2 files changed, 80 insertions(+), 75 deletions(-) diff --git a/src/EnergyPlus/UnitarySystem.cc b/src/EnergyPlus/UnitarySystem.cc index ae6df3b5661..90b05a71aa1 100644 --- a/src/EnergyPlus/UnitarySystem.cc +++ b/src/EnergyPlus/UnitarySystem.cc @@ -3153,7 +3153,7 @@ namespace UnitarySystems { state.dataSize->DataFractionUsedForSizing = 1.0; SizingMethod = HVAC::AutoCalculateSizing; this->m_DesignHeatingCapacity = DataSizing::AutoSize; - if (this->m_CoolingCoilType_Num == HVAC::Coil_CoolingWaterToAirHPSimple) + if (this->m_CoolingCoilType_Num == HVAC::Coil_CoolingWaterToAirHPSimple) { // adjusted cooling coil capacity WaterToAirHeatPumpSimple::SimWatertoAirHPSimple(state, blankString, @@ -3164,7 +3164,6 @@ namespace UnitarySystems { HVAC::CompressorOp::Off, 0.0, FirstHVACIteration); - if (this->m_CoolCoilExists) { state.dataSize->DataConstantUsedForSizing = WaterToAirHeatPumpSimple::GetCoilCapacity( state, HVAC::cAllCoilTypes(this->m_CoolingCoilType_Num), this->m_CoolingCoilName, ErrFound); EqSizing.DesCoolingLoad = state.dataSize->DataConstantUsedForSizing; diff --git a/src/EnergyPlus/WaterToAirHeatPumpSimple.cc b/src/EnergyPlus/WaterToAirHeatPumpSimple.cc index 4da0dc01b80..266aefe6979 100644 --- a/src/EnergyPlus/WaterToAirHeatPumpSimple.cc +++ b/src/EnergyPlus/WaterToAirHeatPumpSimple.cc @@ -2580,86 +2580,92 @@ namespace WaterToAirHeatPumpSimple { // determine adjusted cooling and heating coil capacity simpleWatertoAirHP.RatedCapHeatAtRatedCdts = RatedCapHeatDes * RatedHeatCapTempModFac; - auto &companionCoolingCoil(state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(simpleWatertoAirHP.CompanionCoolingCoilNum)); - if (companionCoolingCoil.WAHPPlantType == DataPlant::PlantEquipmentType::CoilWAHPCoolingEquationFit && - companionCoolingCoil.RatedCapCoolTotal == DataSizing::AutoSize) { - // case 1: companion coil is also of EquationFit type and is being autosized - RatedCapCoolTotalDes = state.dataSize->DXCoolCap; - RatedTotCapTempModFac = companionCoolingCoil.RatedCapCoolAtRatedCdts / RatedCapCoolTotalDes; - RatedCapCoolHeatDD = - simpleWatertoAirHP.RatedCapHeatAtRatedCdts / simpleWatertoAirHP.RatioRatedHeatRatedTotCoolCap / RatedTotCapTempModFac; - RatedCoolPowerTempModFac = companionCoolingCoil.RatedPowerCoolAtRatedCdts / companionCoolingCoil.RatedPowerCool; - if (RatedCapCoolHeatDD > RatedCapCoolTotalDes) { - // total cooling capacity - RatedCapCoolTotalDes = RatedCapCoolHeatDD; - // adjust for system air flow -- capacity is based on heating design day calcs - // adjust by ratio of system to heating air flow rate and temperature delta across the coil at these different airflow - if (HeatingAirVolFlowRateDes > 0) { - RatedCapCoolTotalDes *= (RatedAirVolFlowRateDes / HeatingAirVolFlowRateDes) * HeatdTratio; + if (simpleWatertoAirHP.CompanionCoolingCoilNum > 0) { + auto &companionCoolingCoil(state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(simpleWatertoAirHP.CompanionCoolingCoilNum)); + if (companionCoolingCoil.WAHPPlantType == DataPlant::PlantEquipmentType::CoilWAHPCoolingEquationFit && + companionCoolingCoil.RatedCapCoolTotal == DataSizing::AutoSize) { + // case 1: companion coil is also of EquationFit type and is being autosized + RatedCapCoolTotalDes = state.dataSize->DXCoolCap; + RatedTotCapTempModFac = companionCoolingCoil.RatedCapCoolAtRatedCdts / RatedCapCoolTotalDes; + RatedCapCoolHeatDD = + simpleWatertoAirHP.RatedCapHeatAtRatedCdts / simpleWatertoAirHP.RatioRatedHeatRatedTotCoolCap / RatedTotCapTempModFac; + RatedCoolPowerTempModFac = companionCoolingCoil.RatedPowerCoolAtRatedCdts / companionCoolingCoil.RatedPowerCool; + if (RatedCapCoolHeatDD > RatedCapCoolTotalDes) { + // total cooling capacity + RatedCapCoolTotalDes = RatedCapCoolHeatDD; + // adjust for system air flow -- capacity is based on heating design day calcs + // adjust by ratio of system to heating air flow rate and temperature delta across the coil at these different airflow + if (HeatingAirVolFlowRateDes > 0) { + RatedCapCoolTotalDes *= (RatedAirVolFlowRateDes / HeatingAirVolFlowRateDes) * HeatdTratio; + } + // calculate ajustment factor over previous capacity for sensible capacity adjustment + Real64 CapCoolAdjFac = RatedCapCoolTotalDes / state.dataSize->DXCoolCap; + // update cooling coil rated capacity after adjustments based on heating coil size + state.dataSize->DXCoolCap = RatedCapCoolTotalDes; + // sensible cooling capacity + RatedCapCoolSensDes = companionCoolingCoil.RatedCapCoolSens * CapCoolAdjFac; // Assume that SHR stays the same + companionCoolingCoil.RatedCapCoolSensDesAtRatedCdts *= CapCoolAdjFac; + companionCoolingCoil.RatedCapCoolSens = RatedCapCoolSensDes; + // update Water-to-Air Heat Pumps output reports + OutputReportPredefined::PreDefTableEntry(state, + state.dataOutRptPredefined->pdchWAHPRatedSensCapAtRatedCdts, + companionCoolingCoil.Name, + companionCoolingCoil.RatedCapCoolSensDesAtRatedCdts); + OutputReportPredefined::PreDefTableEntry( + state, state.dataOutRptPredefined->pdchWAHPDD, companionCoolingCoil.Name, "Heating"); + OutputReportPredefined::PreDefTableEntry( + state, state.dataOutRptPredefined->pdchWAHPDD, simpleWatertoAirHP.Name, "Heating"); + // update Cooling Coils output reports + OutputReportPredefined::PreDefTableEntry(state, + state.dataOutRptPredefined->pdchCoolCoilLatCap, + companionCoolingCoil.Name, + RatedCapCoolTotalDes - RatedCapCoolSensDes); + OutputReportPredefined::PreDefTableEntry(state, + state.dataOutRptPredefined->pdchCoolCoilSHR, + companionCoolingCoil.Name, + RatedCapCoolSensDes / RatedCapCoolTotalDes); + OutputReportPredefined::PreDefTableEntry( + state, state.dataOutRptPredefined->pdchCoolCoilSensCap, companionCoolingCoil.Name, RatedCapCoolSensDes); + } else { + OutputReportPredefined::PreDefTableEntry( + state, state.dataOutRptPredefined->pdchWAHPDD, companionCoolingCoil.Name, "Cooling"); + OutputReportPredefined::PreDefTableEntry( + state, state.dataOutRptPredefined->pdchWAHPDD, simpleWatertoAirHP.Name, "Cooling"); } - // calculate ajustment factor over previous capacity for sensible capacity adjustment - Real64 CapCoolAdjFac = RatedCapCoolTotalDes / state.dataSize->DXCoolCap; - // update cooling coil rated capacity after adjustments based on heating coil size - state.dataSize->DXCoolCap = RatedCapCoolTotalDes; - // sensible cooling capacity - RatedCapCoolSensDes = companionCoolingCoil.RatedCapCoolSens * CapCoolAdjFac; // Assume that SHR stays the same - companionCoolingCoil.RatedCapCoolSensDesAtRatedCdts *= CapCoolAdjFac; - companionCoolingCoil.RatedCapCoolSens = RatedCapCoolSensDes; + RatedCapHeatDes = + RatedCapCoolTotalDes * RatedTotCapTempModFac * simpleWatertoAirHP.RatioRatedHeatRatedTotCoolCap / RatedHeatCapTempModFac; + companionCoolingCoil.RatedCapCoolTotal = RatedCapCoolTotalDes; + companionCoolingCoil.RatedCapCoolAtRatedCdts = RatedCapCoolTotalDes * RatedTotCapTempModFac; + companionCoolingCoil.RatedPowerCoolAtRatedCdts = + companionCoolingCoil.RatedCapCoolAtRatedCdts / companionCoolingCoil.RatedCOPCoolAtRatedCdts; + companionCoolingCoil.RatedPowerCool = companionCoolingCoil.RatedPowerCoolAtRatedCdts / RatedCoolPowerTempModFac; // update Water-to-Air Heat Pumps output reports OutputReportPredefined::PreDefTableEntry(state, - state.dataOutRptPredefined->pdchWAHPRatedSensCapAtRatedCdts, + state.dataOutRptPredefined->pdchWAHPRatedCapAtRatedCdts, companionCoolingCoil.Name, - companionCoolingCoil.RatedCapCoolSensDesAtRatedCdts); - OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchWAHPDD, companionCoolingCoil.Name, "Heating"); - OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchWAHPDD, simpleWatertoAirHP.Name, "Heating"); + companionCoolingCoil.RatedCapCoolAtRatedCdts); // update Cooling Coils output reports - OutputReportPredefined::PreDefTableEntry(state, - state.dataOutRptPredefined->pdchCoolCoilLatCap, - companionCoolingCoil.Name, - RatedCapCoolTotalDes - RatedCapCoolSensDes); - OutputReportPredefined::PreDefTableEntry(state, - state.dataOutRptPredefined->pdchCoolCoilSHR, - companionCoolingCoil.Name, - RatedCapCoolSensDes / RatedCapCoolTotalDes); OutputReportPredefined::PreDefTableEntry( - state, state.dataOutRptPredefined->pdchCoolCoilSensCap, companionCoolingCoil.Name, RatedCapCoolSensDes); - } else { - OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchWAHPDD, companionCoolingCoil.Name, "Cooling"); - OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchWAHPDD, simpleWatertoAirHP.Name, "Cooling"); + state, state.dataOutRptPredefined->pdchCoolCoilTotCap, companionCoolingCoil.Name, RatedCapCoolTotalDes); + BaseSizer::reportSizerOutput( + state, + format("COIL:{}:WATERTOAIRHEATPUMP:EQUATIONFIT", WatertoAirHPNamesUC[static_cast(companionCoolingCoil.WAHPType)]), + companionCoolingCoil.Name, + "Design Size Rated Total Cooling Capacity [W]", + companionCoolingCoil.RatedCapCoolTotal); + BaseSizer::reportSizerOutput( + state, + format("COIL:{}:WATERTOAIRHEATPUMP:EQUATIONFIT", WatertoAirHPNamesUC[static_cast(companionCoolingCoil.WAHPType)]), + companionCoolingCoil.Name, + "Design Size Rated Sensible Cooling Capacity [W]", + companionCoolingCoil.RatedCapCoolSens); + } else if (companionCoolingCoil.WAHPPlantType == + DataPlant::PlantEquipmentType::CoilWAHPCoolingEquationFit) { // case 2: companion coil is of EquationFit type but is + // not autosized + RatedCapHeatDes = companionCoolingCoil.RatedCapCoolTotal * simpleWatertoAirHP.RatioRatedHeatRatedTotCoolCap; + } else { // case 3: companion type is different than EquationFit + RatedCapHeatDes = state.dataSize->DXCoolCap; } - RatedCapHeatDes = - RatedCapCoolTotalDes * RatedTotCapTempModFac * simpleWatertoAirHP.RatioRatedHeatRatedTotCoolCap / RatedHeatCapTempModFac; - companionCoolingCoil.RatedCapCoolTotal = RatedCapCoolTotalDes; - companionCoolingCoil.RatedCapCoolAtRatedCdts = RatedCapCoolTotalDes * RatedTotCapTempModFac; - companionCoolingCoil.RatedPowerCoolAtRatedCdts = - companionCoolingCoil.RatedCapCoolAtRatedCdts / companionCoolingCoil.RatedCOPCoolAtRatedCdts; - companionCoolingCoil.RatedPowerCool = companionCoolingCoil.RatedPowerCoolAtRatedCdts / RatedCoolPowerTempModFac; - // update Water-to-Air Heat Pumps output reports - OutputReportPredefined::PreDefTableEntry(state, - state.dataOutRptPredefined->pdchWAHPRatedCapAtRatedCdts, - companionCoolingCoil.Name, - companionCoolingCoil.RatedCapCoolAtRatedCdts); - // update Cooling Coils output reports - OutputReportPredefined::PreDefTableEntry( - state, state.dataOutRptPredefined->pdchCoolCoilTotCap, companionCoolingCoil.Name, RatedCapCoolTotalDes); - BaseSizer::reportSizerOutput( - state, - format("COIL:{}:WATERTOAIRHEATPUMP:EQUATIONFIT", WatertoAirHPNamesUC[static_cast(companionCoolingCoil.WAHPType)]), - companionCoolingCoil.Name, - "Design Size Rated Total Cooling Capacity [W]", - companionCoolingCoil.RatedCapCoolTotal); - BaseSizer::reportSizerOutput( - state, - format("COIL:{}:WATERTOAIRHEATPUMP:EQUATIONFIT", WatertoAirHPNamesUC[static_cast(companionCoolingCoil.WAHPType)]), - companionCoolingCoil.Name, - "Design Size Rated Sensible Cooling Capacity [W]", - companionCoolingCoil.RatedCapCoolSens); - } else if (companionCoolingCoil.WAHPPlantType == - DataPlant::PlantEquipmentType::CoilWAHPCoolingEquationFit) { // case 2: companion coil is of EquationFit type but is - // not autosized - RatedCapHeatDes = companionCoolingCoil.RatedCapCoolTotal * simpleWatertoAirHP.RatioRatedHeatRatedTotCoolCap; - } else { // case 3: companion type is different than EquationFit - RatedCapHeatDes = state.dataSize->DXCoolCap; } // heating capacity final determination simpleWatertoAirHP.RatedCapHeat = RatedCapHeatDes; From ef29015b36dc93a7c7ffd42fe14bb9a4e798bd92 Mon Sep 17 00:00:00 2001 From: rraustad Date: Thu, 19 Sep 2024 13:41:30 -0400 Subject: [PATCH 3/4] Use hard-sized capacity --- src/EnergyPlus/WaterToAirHeatPumpSimple.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/EnergyPlus/WaterToAirHeatPumpSimple.cc b/src/EnergyPlus/WaterToAirHeatPumpSimple.cc index 266aefe6979..a198cc58d8b 100644 --- a/src/EnergyPlus/WaterToAirHeatPumpSimple.cc +++ b/src/EnergyPlus/WaterToAirHeatPumpSimple.cc @@ -2740,7 +2740,7 @@ namespace WaterToAirHeatPumpSimple { // user provided inputs are assumed to be at rated conditions simpleWatertoAirHP.RatedPowerHeat = simpleWatertoAirHP.RatedCapHeat / simpleWatertoAirHP.RatedCOPHeatAtRatedCdts; - simpleWatertoAirHP.RatedCapHeatAtRatedCdts = 0; + simpleWatertoAirHP.RatedCapHeatAtRatedCdts = simpleWatertoAirHP.RatedCapHeat; simpleWatertoAirHP.RatedPowerHeatAtRatedCdts = 0; } // Check that heat pump heating capacity is within 20% of cooling capacity. Check only for heating coil and report both. From 76d18000084f7e63becfe93f700a7af6f85b95d8 Mon Sep 17 00:00:00 2001 From: rraustad Date: Thu, 19 Sep 2024 23:36:53 -0400 Subject: [PATCH 4/4] Revert and correct water flow rate, not surprised of no unit test failures --- src/EnergyPlus/WaterToAirHeatPumpSimple.cc | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/EnergyPlus/WaterToAirHeatPumpSimple.cc b/src/EnergyPlus/WaterToAirHeatPumpSimple.cc index a198cc58d8b..a236032ff54 100644 --- a/src/EnergyPlus/WaterToAirHeatPumpSimple.cc +++ b/src/EnergyPlus/WaterToAirHeatPumpSimple.cc @@ -2740,8 +2740,8 @@ namespace WaterToAirHeatPumpSimple { // user provided inputs are assumed to be at rated conditions simpleWatertoAirHP.RatedPowerHeat = simpleWatertoAirHP.RatedCapHeat / simpleWatertoAirHP.RatedCOPHeatAtRatedCdts; - simpleWatertoAirHP.RatedCapHeatAtRatedCdts = simpleWatertoAirHP.RatedCapHeat; - simpleWatertoAirHP.RatedPowerHeatAtRatedCdts = 0; + simpleWatertoAirHP.RatedCapHeatAtRatedCdts = 0; // not sure why these are set = 0, should be RatedCapHeat? + simpleWatertoAirHP.RatedPowerHeatAtRatedCdts = 0; // should be RatedPowerHeat? } // Check that heat pump heating capacity is within 20% of cooling capacity. Check only for heating coil and report both. if (simpleWatertoAirHP.WAHPType == WatertoAirHP::Heating && simpleWatertoAirHP.CompanionCoolingCoilNum > 0) { @@ -2883,20 +2883,19 @@ namespace WaterToAirHeatPumpSimple { RoutineNameAlt); if (simpleWatertoAirHP.WAHPType == WatertoAirHP::Heating) { - RatedWaterVolFlowRateDes = - simpleWatertoAirHP.RatedCapHeatAtRatedCdts / (state.dataSize->PlantSizData(PltSizNum).DeltaT * Cp * rho); + RatedWaterVolFlowRateDes = simpleWatertoAirHP.RatedCapHeat / (state.dataSize->PlantSizData(PltSizNum).DeltaT * Cp * rho); } else if (simpleWatertoAirHP.WAHPType == WatertoAirHP::Cooling) { // use companion heating coil capacity to calculate volumetric flow rate if (simpleWatertoAirHP.CompanionHeatingCoilNum > 0) { auto &companionHeatingCoil( state.dataWaterToAirHeatPumpSimple->SimpleWatertoAirHP(simpleWatertoAirHP.CompanionHeatingCoilNum)); if (companionHeatingCoil.RatedCapHeat == DataSizing::AutoSize) { - SystemCapacity = simpleWatertoAirHP.RatedCapCoolTotal; + SystemCapacity = simpleWatertoAirHP.RatedCapCoolTotal; // but you should use condenser capacity? } else { SystemCapacity = companionHeatingCoil.RatedCapHeat; } } else { - SystemCapacity = simpleWatertoAirHP.RatedCapCoolAtRatedCdts; + SystemCapacity = simpleWatertoAirHP.RatedCapCoolAtRatedCdts; // RatedCapCoolTotal ? * (1 + 1/COP) ? } RatedWaterVolFlowRateDes = SystemCapacity / (state.dataSize->PlantSizData(PltSizNum).DeltaT * Cp * rho);