diff --git a/src/EnergyPlus/HVACVariableRefrigerantFlow.cc b/src/EnergyPlus/HVACVariableRefrigerantFlow.cc index b6888cca627..4d38e629d91 100644 --- a/src/EnergyPlus/HVACVariableRefrigerantFlow.cc +++ b/src/EnergyPlus/HVACVariableRefrigerantFlow.cc @@ -7921,50 +7921,27 @@ void SizeVRF(EnergyPlusData &state, int const VRFTUNum) } // initialize capacity sizing variables: cooling - SizingMethod = CoolingCapacitySizing; - // capacity sizing methods (HeatingDesignCapacity, CapacityPerFloorArea, FractionOfAutosizedCoolingCapacity, and - // FractionOfAutosizedHeatingCapacity ) - int CapSizingMethod = state.dataSize->ZoneHVACSizing(zoneHVACIndex).CoolingCapMethod; - EqSizing.SizingMethod(SizingMethod) = CapSizingMethod; - if (CapSizingMethod == CoolingDesignCapacity || CapSizingMethod == CapacityPerFloorArea || - CapSizingMethod == FractionOfAutosizedCoolingCapacity) { - if (CapSizingMethod == HeatingDesignCapacity) { - if (state.dataSize->ZoneHVACSizing(zoneHVACIndex).ScaledCoolingCapacity > 0.0) { - EqSizing.CoolingCapacity = true; - EqSizing.DesCoolingLoad = state.dataSize->ZoneHVACSizing(zoneHVACIndex).ScaledCoolingCapacity; - } - } else if (CapSizingMethod == CapacityPerFloorArea) { - EqSizing.CoolingCapacity = true; - EqSizing.DesCoolingLoad = state.dataSize->ZoneHVACSizing(zoneHVACIndex).ScaledCoolingCapacity * - state.dataHeatBal->Zone(state.dataSize->DataZoneNumber).FloorArea; - state.dataSize->DataScalableCapSizingON = true; - } else if (CapSizingMethod == FractionOfAutosizedCoolingCapacity) { - state.dataSize->DataFracOfAutosizedCoolingCapacity = state.dataSize->ZoneHVACSizing(zoneHVACIndex).ScaledCoolingCapacity; - state.dataSize->DataScalableCapSizingON = true; - } - } + initCapSizingVars(state, + CoolingCapacitySizing, + state.dataSize->ZoneHVACSizing(zoneHVACIndex).CoolingCapMethod, + EqSizing.SizingMethod(SizingMethod), + state.dataSize->ZoneHVACSizing(zoneHVACIndex).ScaledCoolingCapacity, + EqSizing.CoolingCapacity, + EqSizing.DesCoolingLoad, + state.dataSize->DataScalableCapSizingON, + state.dataSize->DataFracOfAutosizedCoolingCapacity); // initialize capacity sizing variables: heating - SizingMethod = HeatingCapacitySizing; - CapSizingMethod = state.dataSize->ZoneHVACSizing(zoneHVACIndex).HeatingCapMethod; - EqSizing.SizingMethod(SizingMethod) = CapSizingMethod; - if (CapSizingMethod == HeatingDesignCapacity || CapSizingMethod == CapacityPerFloorArea || - CapSizingMethod == FractionOfAutosizedHeatingCapacity) { - if (CapSizingMethod == HeatingDesignCapacity) { - if (state.dataSize->ZoneHVACSizing(zoneHVACIndex).ScaledHeatingCapacity > 0.0) { - EqSizing.HeatingCapacity = true; - EqSizing.DesHeatingLoad = state.dataSize->ZoneHVACSizing(zoneHVACIndex).ScaledHeatingCapacity; - } - } else if (CapSizingMethod == CapacityPerFloorArea) { - EqSizing.HeatingCapacity = true; - EqSizing.DesHeatingLoad = state.dataSize->ZoneHVACSizing(zoneHVACIndex).ScaledHeatingCapacity * - state.dataHeatBal->Zone(state.dataSize->DataZoneNumber).FloorArea; - state.dataSize->DataScalableCapSizingON = true; - } else if (CapSizingMethod == FractionOfAutosizedHeatingCapacity) { - state.dataSize->DataFracOfAutosizedHeatingCapacity = state.dataSize->ZoneHVACSizing(zoneHVACIndex).ScaledHeatingCapacity; - state.dataSize->DataScalableCapSizingON = true; - } - } + initCapSizingVars(state, + HeatingCapacitySizing, + state.dataSize->ZoneHVACSizing(zoneHVACIndex).HeatingCapMethod, + EqSizing.SizingMethod(SizingMethod), + state.dataSize->ZoneHVACSizing(zoneHVACIndex).ScaledHeatingCapacity, + EqSizing.HeatingCapacity, + EqSizing.DesHeatingLoad, + state.dataSize->DataScalableCapSizingON, + state.dataSize->DataFracOfAutosizedHeatingCapacity); + } else { // no scalable sizing method has been specified. Sizing proceeds using the method // specified in the zoneHVAC object @@ -8856,6 +8833,41 @@ void SizeVRF(EnergyPlusData &state, int const VRFTUNum) state.dataSize->DataScalableCapSizingON = false; } +void initCapSizingVars(EnergyPlusData &state, + int sizingMethod, + int capSizingMethod, + int &eqSizingMethod, + Real64 scaledCapacity, + bool &modeCapacity, + Real64 &designLoad, + bool &scalableCapSizingOn, + Real64 &fracOfAutosizedCapacity) +{ + using namespace DataSizing; + using HVAC::CoolingCapacitySizing; + using HVAC::HeatingCapacitySizing; + + eqSizingMethod = capSizingMethod; + if (capSizingMethod == CoolingDesignCapacity || capSizingMethod == HeatingDesignCapacity || capSizingMethod == CapacityPerFloorArea || + capSizingMethod == FractionOfAutosizedCoolingCapacity || capSizingMethod == FractionOfAutosizedHeatingCapacity) { + if ((capSizingMethod == CoolingDesignCapacity && sizingMethod == CoolingCapacitySizing) || + (capSizingMethod == HeatingDesignCapacity && sizingMethod == HeatingCapacitySizing)) { + if (scaledCapacity > 0.0) { + modeCapacity = true; + designLoad = scaledCapacity; + } + } else if (capSizingMethod == CapacityPerFloorArea) { + modeCapacity = true; + designLoad = scaledCapacity * state.dataHeatBal->Zone(state.dataSize->DataZoneNumber).FloorArea; + scalableCapSizingOn = true; + } else if ((capSizingMethod == FractionOfAutosizedCoolingCapacity && sizingMethod == CoolingCapacitySizing) || + (capSizingMethod == FractionOfAutosizedHeatingCapacity && sizingMethod == HeatingCapacitySizing)) { + fracOfAutosizedCapacity = scaledCapacity; + scalableCapSizingOn = true; + } + } +} + void VRFCondenserEquipment::SizeVRFCondenser(EnergyPlusData &state) { diff --git a/src/EnergyPlus/HVACVariableRefrigerantFlow.hh b/src/EnergyPlus/HVACVariableRefrigerantFlow.hh index 8487e49cfab..98274f5d7b2 100644 --- a/src/EnergyPlus/HVACVariableRefrigerantFlow.hh +++ b/src/EnergyPlus/HVACVariableRefrigerantFlow.hh @@ -910,6 +910,16 @@ namespace HVACVariableRefrigerantFlow { void SizeVRF(EnergyPlusData &state, int const VRFTUNum); + void initCapSizingVars(EnergyPlusData &state, + int sizingMethod, + int capSizingMethod, + int &eqSizingMethod, + Real64 scaledCapacity, + bool &modeCapacity, + Real64 &designLoad, + bool &scalableCapSizingOn, + Real64 &fracOfAutosizedCapacity); + void SimVRF(EnergyPlusData &state, int VRFTUNum, bool FirstHVACIteration, diff --git a/testfiles/VariableRefrigerantFlow_5Zone.idf b/testfiles/VariableRefrigerantFlow_5Zone.idf index 65aa9b449a9..5614a596223 100644 --- a/testfiles/VariableRefrigerantFlow_5Zone.idf +++ b/testfiles/VariableRefrigerantFlow_5Zone.idf @@ -1,7 +1,7 @@ ! VariableRefrigerantFlow_5Zone.idf ! Basic file description: 1 story building divided into 4 exterior and one interior conditioned zones and return plenum. ! -! Highlights: Varible Refrigerant Flow AC system +! Highlights: Variable Refrigerant Flow AC system ! ! Simulation Location/Run: Miami Intl Ap FL USA TMY3 722020, 2 design days, 2 run periods, ! @@ -519,11 +519,37 @@ 20, !- Zone Terminal Unit Off Parasitic Electric Energy Use {W} , !- Rated Heating Capacity Sizing Ratio {W/W} TU1-NightCycleManagerList, !- Availability Manager List Name - , !- Design Specification ZoneHVAC Sizing Object Name + VRFSizingRules1, !- Design Specification ZoneHVAC Sizing Object Name , !- Supplemental Heating Coil Object Type , !- Supplemental Heating Coil Name ; !- Maximum Supply Air Temperature from Supplemental Heater {C} + DesignSpecification:ZoneHVAC:Sizing, + VRFSizingRules1, !- Name + SupplyAirFlowRate, !- Cooling Supply Air Flow Rate Method + autosize, !- Cooling Supply Air Flow Rate {m3/s} + , !- Cooling Supply Air Flow Rate Per Floor Area {m3/s-m2} + , !- Cooling Fraction of Autosized Cooling Supply Air Flow Rate + , !- Cooling Supply Air Flow Rate Per Unit Cooling Capacity {m3/s-W} + SupplyAirFlowRate, !- No Load Supply Air Flow Rate Method + 0.0, !- No Load Supply Air Flow Rate {m3/s} + , !- No Load Supply Air Flow Rate Per Floor Area {m3/s-m2} + , !- No Load Fraction of Cooling Supply Air Flow Rate + , !- No Load Fraction of Heating Supply Air Flow Rate + SupplyAirFlowRate, !- Heating Supply Air Flow Rate Method + autosize, !- Heating Supply Air Flow Rate {m3/s} + , !- Heating Supply Air Flow Rate Per Floor Area {m3/s-m2} + , !- Heating Fraction of Heating Supply Air Flow Rate + , !- Heating Supply Air Flow Rate Per Unit Heating Capacity {m3/s-W} + CoolingDesignCapacity, !- Cooling Design Capacity Method + autosize, !- Cooling Design Capacity {W} + , !- Cooling Design Capacity Per Floor Area {W/m2} + , !- Fraction of Autosized Cooling Design Capacity + CapacityPerFloorArea, !- Heating Design Capacity Method + , !- Heating Design Capacity {W} + 156.89549, !- Heating Design Capacity Per Floor Area {W/m2} + ; !- Fraction of Autosized Heating Design Capacity + AvailabilityManagerAssignmentList, TU1-NightCycleManagerList, !- Name AvailabilityManager:NightCycle, !- Availability Manager 1 Object Type diff --git a/testfiles/VariableRefrigerantFlow_5Zone_wAirloop.idf b/testfiles/VariableRefrigerantFlow_5Zone_wAirloop.idf index 9002468b97a..15d70ffb322 100644 --- a/testfiles/VariableRefrigerantFlow_5Zone_wAirloop.idf +++ b/testfiles/VariableRefrigerantFlow_5Zone_wAirloop.idf @@ -1,7 +1,7 @@ ! VariableRefrigerantFlow_5Zone.idf ! Basic file description: 1 story building divided into 4 exterior and one interior conditioned zones and return plenum. ! -! Highlights: Varible Refrigerant Flow AC system +! Highlights: Variable Refrigerant Flow AC system ! ! Simulation Location/Run: Miami Intl Ap FL USA TMY3 722020, 2 design days, 2 run periods, ! diff --git a/tst/EnergyPlus/unit/HVACVariableRefrigerantFlow.unit.cc b/tst/EnergyPlus/unit/HVACVariableRefrigerantFlow.unit.cc index 135170a65fd..20cb07e6a73 100644 --- a/tst/EnergyPlus/unit/HVACVariableRefrigerantFlow.unit.cc +++ b/tst/EnergyPlus/unit/HVACVariableRefrigerantFlow.unit.cc @@ -25571,4 +25571,204 @@ TEST_F(EnergyPlusFixture, VRFTest_TU_HeatRecoveryCheck) EXPECT_FALSE(state->dataHVACVarRefFlow->VRF(vrf3).HeatRecoveryUsed); } +TEST_F(EnergyPlusFixture, VRFTest_initCapSizingVars) +{ + // Test for #10638 + using namespace DataSizing; + using HVAC::AutoCalculateSizing; + using HVAC::CoolingCapacitySizing; + using HVAC::HeatingCapacitySizing; + + int testSizingMethod; + int testCapSizingMethod; + int testEqSizingMethod; + Real64 testScaledCapacity; + bool testModeCapacity; + Real64 testDesignLoad; + bool testScalableCapSizingOn; + Real64 testFracOfAutosizedCapacity; + Real64 allowedTolerance = 0.0001; + int expectedEqSizingMethod; + Real64 expectedScaledCapacity; + Real64 expectedDesignLoad; + Real64 expectedFracOfAutosizedCapacity; + + state->dataSize->DataZoneNumber = 1; + state->dataHeatBal->Zone.allocate(1); + state->dataHeatBal->Zone(1).FloorArea = 2.0; + + // Test 1: no valid sizing chosen--nothing changes from what things are previously set to + testSizingMethod = AutoCalculateSizing; + testCapSizingMethod = None; + testEqSizingMethod = -1; + testScaledCapacity = 12.0; + testModeCapacity = false; + testDesignLoad = 123.0; + testScalableCapSizingOn = false; + testFracOfAutosizedCapacity = 1234.0; + expectedScaledCapacity = 12.0; + expectedDesignLoad = 123.0; + expectedFracOfAutosizedCapacity = 1234.0; + initCapSizingVars(*state, + testSizingMethod, + testCapSizingMethod, + testEqSizingMethod, + testScaledCapacity, + testModeCapacity, + testDesignLoad, + testScalableCapSizingOn, + testFracOfAutosizedCapacity); + EXPECT_FALSE(testModeCapacity); + EXPECT_FALSE(testScalableCapSizingOn); + EXPECT_EQ(testEqSizingMethod, None); + EXPECT_NEAR(testScaledCapacity, expectedScaledCapacity, allowedTolerance); + EXPECT_NEAR(testDesignLoad, expectedDesignLoad, allowedTolerance); + EXPECT_NEAR(testFracOfAutosizedCapacity, expectedFracOfAutosizedCapacity, allowedTolerance); + + // Test 2a: CoolingCapacitySizing with CoolingDesignCapacity--set ModeCapacity to true and DesignLoad to ScaledCapacity + testSizingMethod = CoolingCapacitySizing; + testCapSizingMethod = CoolingDesignCapacity; + testEqSizingMethod = -1; + testScaledCapacity = 12.0; + testModeCapacity = false; + testDesignLoad = 123.0; + testScalableCapSizingOn = false; + testFracOfAutosizedCapacity = 1234.0; + expectedScaledCapacity = 12.0; + expectedDesignLoad = 12.0; + expectedFracOfAutosizedCapacity = 1234.0; + expectedEqSizingMethod = CoolingDesignCapacity; + initCapSizingVars(*state, + testSizingMethod, + testCapSizingMethod, + testEqSizingMethod, + testScaledCapacity, + testModeCapacity, + testDesignLoad, + testScalableCapSizingOn, + testFracOfAutosizedCapacity); + EXPECT_TRUE(testModeCapacity); + EXPECT_FALSE(testScalableCapSizingOn); + EXPECT_EQ(testEqSizingMethod, expectedEqSizingMethod); + EXPECT_NEAR(testScaledCapacity, expectedScaledCapacity, allowedTolerance); + EXPECT_NEAR(testDesignLoad, expectedDesignLoad, allowedTolerance); + EXPECT_NEAR(testFracOfAutosizedCapacity, expectedFracOfAutosizedCapacity, allowedTolerance); + + // Test 2b: HeatingCapacitySizing with HeatingDesignCapacity--set ModeCapacity to true and DesignLoad to ScaledCapacity + testSizingMethod = HeatingCapacitySizing; + testCapSizingMethod = HeatingDesignCapacity; + testEqSizingMethod = -1; + testScaledCapacity = 12.0; + testModeCapacity = false; + testDesignLoad = 123.0; + testScalableCapSizingOn = false; + testFracOfAutosizedCapacity = 1234.0; + expectedScaledCapacity = 12.0; + expectedDesignLoad = 12.0; + expectedFracOfAutosizedCapacity = 1234.0; + expectedEqSizingMethod = HeatingDesignCapacity; + initCapSizingVars(*state, + testSizingMethod, + testCapSizingMethod, + testEqSizingMethod, + testScaledCapacity, + testModeCapacity, + testDesignLoad, + testScalableCapSizingOn, + testFracOfAutosizedCapacity); + EXPECT_TRUE(testModeCapacity); + EXPECT_FALSE(testScalableCapSizingOn); + EXPECT_EQ(testEqSizingMethod, expectedEqSizingMethod); + EXPECT_NEAR(testScaledCapacity, expectedScaledCapacity, allowedTolerance); + EXPECT_NEAR(testDesignLoad, expectedDesignLoad, allowedTolerance); + EXPECT_NEAR(testFracOfAutosizedCapacity, expectedFracOfAutosizedCapacity, allowedTolerance); + + // Test 3: CapacityPerFloorArea (both heating and cooling are the same)--set ModeCapacity and scalable to true and DesignLoad to ScaledCapacity + testSizingMethod = HeatingCapacitySizing; + testCapSizingMethod = CapacityPerFloorArea; + testEqSizingMethod = -1; + testScaledCapacity = 12.0; + testModeCapacity = false; + testDesignLoad = 123.0; + testScalableCapSizingOn = false; + testFracOfAutosizedCapacity = 1234.0; + expectedScaledCapacity = 12.0; + expectedDesignLoad = 24.0; + expectedFracOfAutosizedCapacity = 1234.0; + expectedEqSizingMethod = CapacityPerFloorArea; + initCapSizingVars(*state, + testSizingMethod, + testCapSizingMethod, + testEqSizingMethod, + testScaledCapacity, + testModeCapacity, + testDesignLoad, + testScalableCapSizingOn, + testFracOfAutosizedCapacity); + EXPECT_TRUE(testModeCapacity); + EXPECT_TRUE(testScalableCapSizingOn); + EXPECT_EQ(testEqSizingMethod, expectedEqSizingMethod); + EXPECT_NEAR(testScaledCapacity, expectedScaledCapacity, allowedTolerance); + EXPECT_NEAR(testDesignLoad, expectedDesignLoad, allowedTolerance); + EXPECT_NEAR(testFracOfAutosizedCapacity, expectedFracOfAutosizedCapacity, allowedTolerance); + + // Test 4a: CoolingCapacitySizing with FractionOfAutosizedCoolingCapacity--set ModeCapacity to true and DesignLoad to ScaledCapacity + testSizingMethod = CoolingCapacitySizing; + testCapSizingMethod = FractionOfAutosizedCoolingCapacity; + testEqSizingMethod = -1; + testScaledCapacity = 12.0; + testModeCapacity = false; + testDesignLoad = 123.0; + testScalableCapSizingOn = false; + testFracOfAutosizedCapacity = 1234.0; + expectedScaledCapacity = 12.0; + expectedDesignLoad = 123.0; + expectedFracOfAutosizedCapacity = 12.0; + expectedEqSizingMethod = FractionOfAutosizedCoolingCapacity; + initCapSizingVars(*state, + testSizingMethod, + testCapSizingMethod, + testEqSizingMethod, + testScaledCapacity, + testModeCapacity, + testDesignLoad, + testScalableCapSizingOn, + testFracOfAutosizedCapacity); + EXPECT_FALSE(testModeCapacity); + EXPECT_TRUE(testScalableCapSizingOn); + EXPECT_EQ(testEqSizingMethod, expectedEqSizingMethod); + EXPECT_NEAR(testScaledCapacity, expectedScaledCapacity, allowedTolerance); + EXPECT_NEAR(testDesignLoad, expectedDesignLoad, allowedTolerance); + EXPECT_NEAR(testFracOfAutosizedCapacity, expectedFracOfAutosizedCapacity, allowedTolerance); + + // Test 4b: HeatingCapacitySizing with FractionOfAutosizedHeatingCapacity--set ModeCapacity to true and DesignLoad to ScaledCapacity + testSizingMethod = HeatingCapacitySizing; + testCapSizingMethod = FractionOfAutosizedHeatingCapacity; + testEqSizingMethod = -1; + testScaledCapacity = 12.0; + testModeCapacity = false; + testDesignLoad = 123.0; + testScalableCapSizingOn = false; + testFracOfAutosizedCapacity = 1234.0; + expectedScaledCapacity = 12.0; + expectedDesignLoad = 123.0; + expectedFracOfAutosizedCapacity = 12.0; + expectedEqSizingMethod = FractionOfAutosizedHeatingCapacity; + initCapSizingVars(*state, + testSizingMethod, + testCapSizingMethod, + testEqSizingMethod, + testScaledCapacity, + testModeCapacity, + testDesignLoad, + testScalableCapSizingOn, + testFracOfAutosizedCapacity); + EXPECT_FALSE(testModeCapacity); + EXPECT_TRUE(testScalableCapSizingOn); + EXPECT_EQ(testEqSizingMethod, expectedEqSizingMethod); + EXPECT_NEAR(testScaledCapacity, expectedScaledCapacity, allowedTolerance); + EXPECT_NEAR(testDesignLoad, expectedDesignLoad, allowedTolerance); + EXPECT_NEAR(testFracOfAutosizedCapacity, expectedFracOfAutosizedCapacity, allowedTolerance); +} + } // end of namespace EnergyPlus