From 9d0bef8e98c1ebb9f6ae598c12479493e6481d22 Mon Sep 17 00:00:00 2001 From: Julien Marrec Date: Tue, 20 Aug 2024 11:30:05 +0200 Subject: [PATCH 1/6] Improve an existing unit test (I plan to use a variation of this) --- tst/EnergyPlus/unit/WindowAC.unit.cc | 39 ++++++++++++++++++++++++---- 1 file changed, 34 insertions(+), 5 deletions(-) diff --git a/tst/EnergyPlus/unit/WindowAC.unit.cc b/tst/EnergyPlus/unit/WindowAC.unit.cc index 8051717dbf3..4de5002608f 100644 --- a/tst/EnergyPlus/unit/WindowAC.unit.cc +++ b/tst/EnergyPlus/unit/WindowAC.unit.cc @@ -53,6 +53,7 @@ #include #include #include +#include #include #include #include @@ -60,6 +61,7 @@ #include #include #include +#include #include using namespace EnergyPlus; @@ -215,9 +217,9 @@ TEST_F(EnergyPlusFixture, WindowAC_VStest1) " HPCoolingEIRFTemp4, !- Name", " 0.0001514017, !- Coefficient1 Constant", " 0.0655062896, !- Coefficient2 x", - " -0.0020370821, !- Coefficient3 x**2", - " 0.0067823041, !- Coefficient4 y", - " 0.0004087196, !- Coefficient5 y**2", + " -0.0020370821, !- Coefficient3 x**2", + " 0.0067823041, !- Coefficient4 y", + " 0.0004087196, !- Coefficient5 y**2", " -0.0003552302, !- Coefficient6 x*y", " 13.89, !- Minimum Value of x", " 22.22, !- Maximum Value of x", @@ -467,9 +469,36 @@ TEST_F(EnergyPlusFixture, WindowAC_VStest1) // check input processing EXPECT_EQ(compIndex, 1); - EXPECT_EQ(state->dataWindowAC->WindAC(1).DXCoilType_Num, HVAC::Coil_CoolingAirToAirVariableSpeed); + // MixTemp = 24.00, MixHumRat = 0.008, SupTemp = 12, SupHumRat = 0.008 + double constexpr expected_full_airflow = 0.041484382187390034; + double constexpr expected_full_cap = 622.50474573886743; + + auto const &windowAC = state->dataWindowAC->WindAC(compIndex); + + ASSERT_GT(windowAC.FanIndex, 0); + auto const &fan = state->dataFans->fans(windowAC.FanIndex); + + auto const &finalZoneSizing = state->dataSize->FinalZoneSizing(1); + + EXPECT_NEAR(expected_full_airflow, finalZoneSizing.DesCoolVolFlow, 0.0001); + + EXPECT_EQ(windowAC.HVACSizingIndex, 0); + + EXPECT_EQ(windowAC.DXCoilType_Num, HVAC::Coil_CoolingAirToAirVariableSpeed); + ASSERT_GT(windowAC.DXCoilIndex, 0); + auto const &varSpeedCoil = state->dataVariableSpeedCoils->VarSpeedCoil(windowAC.DXCoilIndex); + // check Sizing - EXPECT_NEAR(state->dataWindowAC->WindAC(1).MaxAirVolFlow, 0.0415, 0.0001); + EXPECT_NEAR(expected_full_airflow, windowAC.MaxAirVolFlow, 0.0001); + EXPECT_NEAR(expected_full_airflow, fan->maxAirFlowRate, 0.0001); + EXPECT_NEAR(expected_full_cap, varSpeedCoil.RatedCapCoolTotal, 0.001); + + // VSD Sizing forces it back to Catalog data based on Nominal Speed Level + double constexpr vsd_coil_norm_speed_tot_cap = 36991.44197; // Speed 1 Reference Unit Gross Rated Total Cooling Capacity {w} + double constexpr vsd_coil_norm_speed_airflow = 3.776; // Speed 1 Reference Unit Gross Rated Cooling COP {dimensionless} + double constexpr vsd_coil_norm_speed_airflow_per_cap = vsd_coil_norm_speed_airflow / vsd_coil_norm_speed_tot_cap; + EXPECT_NEAR(vsd_coil_norm_speed_airflow_per_cap, varSpeedCoil.MSRatedAirVolFlowPerRatedTotCap(1), 0.0001); + EXPECT_NEAR(expected_full_cap * vsd_coil_norm_speed_airflow_per_cap, varSpeedCoil.RatedAirVolFlowRate, 0.0001); state->dataZoneEnergyDemand->ZoneSysEnergyDemand(1).RemainingOutputReqToCoolSP = -295.0; state->dataZoneEnergyDemand->CurDeadBandOrSetback(1) = false; From dddaa5a13f7463bc3e5e0d139f1c301eded173d6 Mon Sep 17 00:00:00 2001 From: Julien Marrec Date: Tue, 20 Aug 2024 12:41:01 +0200 Subject: [PATCH 2/6] New unit test for #10663 --- tst/EnergyPlus/unit/WindowAC.unit.cc | 484 +++++++++++++++++++++++++++ 1 file changed, 484 insertions(+) diff --git a/tst/EnergyPlus/unit/WindowAC.unit.cc b/tst/EnergyPlus/unit/WindowAC.unit.cc index 4de5002608f..06af8be59f9 100644 --- a/tst/EnergyPlus/unit/WindowAC.unit.cc +++ b/tst/EnergyPlus/unit/WindowAC.unit.cc @@ -514,3 +514,487 @@ TEST_F(EnergyPlusFixture, WindowAC_VStest1) EXPECT_EQ("N/A", OutputReportPredefined::RetrievePreDefTableEntry(*state, state->dataOutRptPredefined->pdchZnHtDesDay, "WEST ZONE")); EXPECT_EQ("N/A", OutputReportPredefined::RetrievePreDefTableEntry(*state, state->dataOutRptPredefined->pdchZnHtPkTime, "WEST ZONE")); } + +TEST_F(EnergyPlusFixture, WindowAC_DesignSpecificationZoneHVACSizing) +{ + // this unit test runs the window air conditioner with a Coil:Cooling:DX:VariableSpeed coil + // set up minimal zone, zone equipment, and ZoneHVAC:WindowAirConditioner, check input processing, check sizing, check simulation results + // This adds a DesignSpecification:ZoneHVAC:Sizing too + + std::string const idf_objects = delimited_string({ + " Timestep,6;", + + " Site:Location,", + " CHICAGO_IL_USA TMY2-94846, !- Name", + " 41.78, !- Latitude {deg}", + " -87.75, !- Longitude {deg}", + " -6.00, !- Time Zone {hr}", + " 190.00; !- Elevation {m}", + + " SimulationControl,", + " Yes, !- Do Zone Sizing Calculation", + " No, !- Do System Sizing Calculation", + " No, !- Do Plant Sizing Calculation", + " No, !- Run Simulation for Sizing Periods", + " Yes; !- Run Simulation for Weather File Run Periods", + + " SizingPeriod:DesignDay,", + " CHICAGO_IL_USA Annual Cooling 1% Design Conditions DB/MCWB, !- Name", + " 7, !- Month", + " 21, !- Day of Month", + " SummerDesignDay, !- Day Type", + " 31.5, !- Maximum Dry-Bulb Temperature {C}", + " 10.7, !- Daily Dry-Bulb Temperature Range {deltaC}", + " , !- Dry-Bulb Temperature Range Modifier Type", + " , !- Dry-Bulb Temperature Range Modifier Day Schedule Name", + " Wetbulb, !- Humidity Condition Type", + " 23.0, !- Wetbulb or DewPoint at Maximum Dry-Bulb {C}", + " , !- Humidity Condition Day Schedule Name", + " , !- Humidity Ratio at Maximum Dry-Bulb {kgWater/kgDryAir}", + " , !- Enthalpy at Maximum Dry-Bulb {J/kg}", + " , !- Daily Wet-Bulb Temperature Range {deltaC}", + " 99063., !- Barometric Pressure {Pa}", + " 5.3, !- Wind Speed {m/s}", + " 230, !- Wind Direction {deg}", + " No, !- Rain Indicator", + " No, !- Snow Indicator", + " No, !- Daylight Saving Time Indicator", + " ASHRAEClearSky, !- Solar Model Indicator", + " , !- Beam Solar Day Schedule Name", + " , !- Diffuse Solar Day Schedule Name", + " , !- ASHRAE Clear Sky Optical Depth for Beam Irradiance (taub) {dimensionless}", + " , !- ASHRAE Clear Sky Optical Depth for Diffuse Irradiance (taud){dimensionless}", + " 1.0; !- Sky Clearness", + + " ZoneHVAC:WindowAirConditioner,", + " Zone1WindAC, !- Name", + " , !- Availability Schedule Name", + " autosize, !- Maximum Supply Air Flow Rate {m3/s}", + " autosize, !- Maximum Outdoor Air Flow Rate {m3/s}", + " Zone1WindACAirInletNode, !- Air Inlet Node Name", + " Zone1WindACAirOutletNode,!- Air Outlet Node Name", + " OutdoorAir:Mixer, !- Outdoor Air Mixer Object Type", + " Zone1WindACOAMixer, !- Outdoor Air Mixer Name", + " Fan:OnOff, !- Supply Air Fan Object Type", + " Zone1WindACFan, !- Supply Air Fan Name", + " Coil:Cooling:DX:VariableSpeed, !- Cooling Coil Object Type", + " Zone1WindAC_VS_DXCoil, !- DX Cooling Coil Name", + " , !- Supply Air Fan Operating Mode Schedule Name", + " BlowThrough, !- Fan Placement", + " 0.001, !- Cooling Convergence Tolerance", + " , !- Availability Manager List Name", + " WindowACSizing; !- Design Specification ZoneHVAC Sizing Object Name", + + // NOTE: Only difference here is that I'm settting a DesignSpecification:ZoneHVAC:Sizing + " DesignSpecification:ZoneHVAC:Sizing,", + " WindowACSizing, !- Name", + " FractionOfAutosizedCoolingAirflow, !- Cooling Supply Air Flow Rate Method", + " , !- Cooling Supply Air Flow Rate {m3/s}", + " , !- Cooling Supply Air Flow Rate Per Floor Area {m3/s-m2}", + " 0.5, !- Cooling Fraction of Autosized Cooling Supply Air Flow Rate", + " , !- Cooling Supply Air Flow Rate Per Unit Cooling Capacity {m3/s-W}", + " FractionOfAutosizedCoolingAirflow, !- No Load Supply Air Flow Rate Method", + " , !- No Load Supply Air Flow Rate {m3/s}", + " , !- No Load Supply Air Flow Rate Per Floor Area {m3/s-m2}", + " 0.5, !- No Load Fraction of Cooling Supply Air Flow Rate", + " , !- No Load Fraction of Heating Supply Air Flow Rate", + " None, !- Heating Supply Air Flow Rate Method", + " , !- 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}", + " FractionOfAutosizedCoolingCapacity, !- Cooling Design Capacity Method", + " , !- Cooling Design Capacity {W}", + " , !- Cooling Design Capacity Per Floor Area {W/m2}", + " 0.5; !- Fraction of Autosized Cooling Design Capacity", + + " Schedule:Compact,", + " CYCLINGFANSCH, !- Name", + " FRACTION, !- Schedule Type Limits Name", + " Through: 12/31, !- Field 1", + " For: Alldays, !- Field 2", + " Until: 24:00,0.00; !- Field 3", + + " OutdoorAir:Mixer,", + " Zone1WindACOAMixer, !- Name", + " Zone1WindACOAMixerOutletNode, !- Mixed Air Node Name", + " Zone1WindACOAInNode, !- Outdoor Air Stream Node Name", + " Zone1WindACExhNode, !- Relief Air Stream Node Name", + " Zone1WindACAirInletNode; !- Return Air Stream Node Name", + + " Fan:OnOff,", + " Zone1WindACFan, !- Name", + " , !- Availability Schedule Name", + " 0.5, !- Fan Total Efficiency", + " 75.0, !- Pressure Rise {Pa}", + " autosize, !- Maximum Flow Rate {m3/s}", + " 0.9, !- Motor Efficiency", + " 1.0, !- Motor In Airstream Fraction", + " Zone1WindACOAMixerOutletNode, !- Air Inlet Node Name", + " Zone1WindACFanOutletNode;!- Air Outlet Node Name", + + " Coil:Cooling:DX:VariableSpeed,", + " Zone1WindAC_VS_DXCoil, !- Name", + " Zone1WindACFanOutletNode, !- Indoor Air Inlet Node Name", + " Zone1WindACAirOutletNode, !- Indoor Air Outlet Node Name", + " 1, !- Number of Speeds {dimensionless}", + " 1, !- Nominal Speed Level {dimensionless}", + " AUTOSIZE, !- Gross Rated Total Cooling Capacity At Selected Nominal Speed Level {w}", + " AUTOSIZE, !- Rated Air Flow Rate At Selected Nominal Speed Level {m3/s}", + " 0.0, !- Nominal Time for Condensate to Begin Leaving the Coil {s}", + " 0.0, !- Initial Moisture Evaporation Rate Divided by Steady-State AC Latent Capacity {dimensionless}", + " , !- Maximum Cycling Rate", + " , !- Latent Capacity Time Constant", + " , !- Fan Delay Time", + " HPACCOOLPLFFPLR, !- Energy Part Load Fraction Curve Name", + " , !- Condenser Air Inlet Node Name", + " AirCooled, !- Condenser Type", + " , !- Evaporative Condenser Pump Rated Power Consumption {W}", + " 0.0, !- Crankcase Heater Capacity {W}", + " , !- Crankcase Heater Capacity Function of Temperature Curve Name", + " 10.0, !- Maximum Outdoor Dry-Bulb Temperature for Crankcase Heater Operation {C}", + " , !- Minimum Outdoor Dry-Bulb Temperature for Compressor Operation {C}", + " , !- Supply Water Storage Tank Name", + " , !- Condensate Collection Water Storage Tank Name", + " , !- Basin Heater Capacity {W/K}", + " , !- Basin Heater Setpoint Temperature {C}", + " , !- Basin Heater Operating Schedule Name", + " 36991.44197, !- Speed 1 Reference Unit Gross Rated Total Cooling Capacity {w}", + " 0.75, !- Speed 1 Reference Unit Gross Rated Sensible Heat Ratio {dimensionless}", + " 3.866381837, !- Speed 1 Reference Unit Gross Rated Cooling COP {dimensionless}", + " 3.776, !- Speed 1 Reference Unit Rated Air Flow Rate {m3/s}", + " 773.3, !- Speed 1 2017 Rated Evaporator Fan Power Per Volume Flow Rate [W/(m3/s)]", + " 934.4, !- Speed 1 2023 Rated Evaporator Fan Power Per Volume Flow Rate [W/(m3/s)]", + " 10.62, !- Speed 1 Reference Unit Rated Condenser Air Flow Rate {m3/s}", + " , !- Speed 1 Reference Unit Rated Pad Effectiveness of Evap Precooling {dimensionless}", + " HPCoolingCAPFTemp4, !- Speed 1 Total Cooling Capacity Function of Temperature Curve Name", + " HPACFFF, !- Speed 1 Total Cooling Capacity Function of Air Flow Fraction Curve Name", + " HPCoolingEIRFTemp4, !- Speed 1 Energy Input Ratio Function of Temperature Curve Name", + " HPACFFF; !- Speed 1 Energy Input Ratio Function of Air Flow Fraction Curve Name", + + " Curve:Quadratic,", + " HPACCOOLPLFFPLR, !- Name", + " 1.0, !- Coefficient1 Constant", + " 0.0, !- Coefficient2 x", + " 0.0, !- Coefficient3 x**2", + " 0.5, !- Minimum Value of x", + " 1.5; !- Maximum Value of x ", + + " Curve:Cubic,", + " HPACFFF, !- Name", + " 1.0, !- Coefficient1 Constant", + " 0.0, !- Coefficient2 x", + " 0.0, !- Coefficient3 x**2", + " 0.0, !- Coefficient4 x**3", + " 0.5, !- Minimum Value of x", + " 1.5; !- Maximum Value of x", + + " Curve:Biquadratic,", + " HPCoolingEIRFTemp4, !- Name", + " 0.0001514017, !- Coefficient1 Constant", + " 0.0655062896, !- Coefficient2 x", + " -0.0020370821, !- Coefficient3 x**2", + " 0.0067823041, !- Coefficient4 y", + " 0.0004087196, !- Coefficient5 y**2", + " -0.0003552302, !- Coefficient6 x*y", + " 13.89, !- Minimum Value of x", + " 22.22, !- Maximum Value of x", + " 12.78, !- Minimum Value of y", + " 51.67, !- Maximum Value of y", + " 0.5141, !- Minimum Curve Output", + " 1.7044, !- Maximum Curve Output", + " Temperature, !- Input Unit Type for X", + " Temperature, !- Input Unit Type for Y", + " Dimensionless; !- Output Unit Type", + + " Curve:Biquadratic,", + " HPCoolingCAPFTemp4, !- Name", + " 1.3544202152, !- Coefficient1 Constant", + " -0.0493402773, !- Coefficient2 x", + " 0.0022649843, !- Coefficient3 x**2", + " 0.0008517727, !- Coefficient4 y", + " -0.0000426316, !- Coefficient5 y**2", + " -0.0003364517, !- Coefficient6 x*y", + " 13.89, !- Minimum Value of x", + " 22.22, !- Maximum Value of x", + " 12.78, !- Minimum Value of y", + " 51.67, !- Maximum Value of y", + " 0.7923, !- Minimum Curve Output", + " 1.2736, !- Maximum Curve Output", + " Temperature, !- Input Unit Type for X", + " Temperature, !- Input Unit Type for Y", + " Dimensionless; !- Output Unit Type", + + " ZoneHVAC:EquipmentConnections,", + " West Zone, !- Zone Name", + " Zone1Equipment, !- Zone Conditioning Equipment List Name", + " Zone1Inlets, !- Zone Air Inlet Node or NodeList Name", + " Zone1Exhausts, !- Zone Air Exhaust Node or NodeList Name", + " Zone 1 Node, !- Zone Air Node Name", + " Zone 1 Outlet Node; !- Zone Return Air Node Name", + + " ZoneHVAC:EquipmentList,", + " Zone1Equipment, !- Name", + " SequentialLoad, !- Load Distribution Scheme", + " ZoneHVAC:WindowAirConditioner, !- Zone Equipment 1 Object Type", + " Zone1WindAC, !- Zone Equipment 1 Name", + " 1, !- Zone Equipment 1 Cooling Sequence", + " 1; !- Zone Equipment 1 Heating or No-Load Sequence", + + " NodeList,", + " Zone1Exhausts, !- Name", + " Zone1WindACAirInletNode; !- Node 1 Name", + + " OutdoorAir:NodeList,", + " OutsideAirInletNodes; !- Node or NodeList Name 1", + + " NodeList,", + " OutsideAirInletNodes, !- Name", + " Zone1WindACOAInNode; !- Node 1 Name", + + " NodeList,", + " Zone1Inlets, !- Name", + " Zone1WindACAirOutletNode;!- Node 1 Name", + + " ZoneControl:Thermostat,", + " Zone 1 Thermostat, !- Name", + " West Zone, !- Zone or ZoneList Name", + " Zone Control Type Sched, !- Control Type Schedule Name", + " ThermostatSetpoint:SingleHeating, !- Control 1 Object Type", + " Heating Setpoint with SB,!- Control 1 Name", + " ThermostatSetpoint:SingleCooling, !- Control 2 Object Type", + " Cooling Setpoint with SB;!- Control 2 Name", + + " Schedule:Compact,", + " ZONE CONTROL TYPE SCHED, !- Name", + " CONTROL TYPE, !- Schedule Type Limits Name", + " Through: 3/31, !- Field 1", + " For: Alldays, !- Field 2", + " Until: 24:00,1, !- Field 3", + " Through: 9/30, !- Field 5", + " For: Alldays, !- Field 6", + " Until: 24:00,2, !- Field 7", + " Through: 12/31, !- Field 9", + " For: Alldays, !- Field 10", + " Until: 24:00,1; !- Field 11", + + " ThermostatSetpoint:SingleHeating,", + " Heating Setpoint with SB,!- Name", + " Heating Setpoints; !- Setpoint Temperature Schedule Name", + + " ThermostatSetpoint:SingleCooling,", + " Cooling Setpoint with SB,!- Name", + " Cooling Setpoints; !- Setpoint Temperature Schedule Name", + + " Schedule:Compact,", + " HEATING SETPOINTS, !- Name", + " TEMPERATURE, !- Schedule Type Limits Name", + " Through: 12/31, !- Field 1", + " For: Weekdays Weekends Holidays CustomDay1 CustomDay2, !- Field 2", + " Until: 7:00,15.00, !- Field 3", + " Until: 17:00,20.00, !- Field 5", + " Until: 24:00,15.00, !- Field 7", + " For: SummerDesignDay, !- Field 9", + " Until: 24:00,15.00, !- Field 10", + " For: WinterDesignDay, !- Field 12", + " Until: 24:00,20.00; !- Field 13", + + " Schedule:Compact,", + " COOLING SETPOINTS, !- Name", + " TEMPERATURE, !- Schedule Type Limits Name", + " Through: 12/31, !- Field 1", + " For: Weekdays Weekends Holidays CustomDay1 CustomDay2, !- Field 2", + " Until: 7:00,30.00, !- Field 3", + " Until: 17:00,24.00, !- Field 5", + " Until: 24:00,30.00, !- Field 7", + " For: SummerDesignDay, !- Field 9", + " Until: 24:00,24.00, !- Field 10", + " For: WinterDesignDay, !- Field 12", + " Until: 24:00,50.00; !- Field 13", + + " Sizing:Zone,", + " West Zone, !- Zone or ZoneList Name", + " SupplyAirTemperature, !- Zone Cooling Design Supply Air Temperature Input Method", + " 12., !- Zone Cooling Design Supply Air Temperature {C}", + " , !- Zone Cooling Design Supply Air Temperature Difference {deltaC}", + " SupplyAirTemperature, !- Zone Heating Design Supply Air Temperature Input Method", + " 50., !- Zone Heating Design Supply Air Temperature {C}", + " , !- Zone Heating Design Supply Air Temperature Difference {deltaC}", + " 0.008, !- Zone Cooling Design Supply Air Humidity Ratio {kgWater/kgDryAir}", + " 0.008, !- Zone Heating Design Supply Air Humidity Ratio {kgWater/kgDryAir}", + " SZ DSOA West Zone, !- Design Specification Outdoor Air Object Name", + " 0.0, !- Zone Heating Sizing Factor", + " 0.0, !- Zone Cooling Sizing Factor", + " DesignDay, !- Cooling Design Air Flow Method", + " 0, !- Cooling Design Air Flow Rate {m3/s}", + " , !- Cooling Minimum Air Flow per Zone Floor Area {m3/s-m2}", + " , !- Cooling Minimum Air Flow {m3/s}", + " , !- Cooling Minimum Air Flow Fraction", + " DesignDay, !- Heating Design Air Flow Method", + " 0, !- Heating Design Air Flow Rate {m3/s}", + " , !- Heating Maximum Air Flow per Zone Floor Area {m3/s-m2}", + " , !- Heating Maximum Air Flow {m3/s}", + " ; !- Heating Maximum Air Flow Fraction", + + " DesignSpecification:OutdoorAir,", + " SZ DSOA West Zone, !- Name", + " flow/person, !- Outdoor Air Method", + " 0.00944, !- Outdoor Air Flow per Person {m3/s-person}", + " 0.0, !- Outdoor Air Flow per Zone Floor Area {m3/s-m2}", + " 0.0; !- Outdoor Air Flow per Zone {m3/s}", + + " Zone,", + " West Zone, !- Name", + " 0, !- Direction of Relative North {deg}", + " 0, !- X Origin {m}", + " 0, !- Y Origin {m}", + " 0, !- Z Origin {m}", + " 1, !- Type", + " 1, !- Multiplier", + " 3.048, !- Ceiling Height {m}", + " 40.; !- Volume {m3}", + + " BuildingSurface:Detailed,", + " Zn001:Wall001, !- Name", + " Wall, !- Surface Type", + " EXTWALL80, !- Construction Name", + " West Zone, !- Zone Name", + " , !- Space Name", + " Outdoors, !- Outside Boundary Condition", + " , !- Outside Boundary Condition Object", + " SunExposed, !- Sun Exposure", + " WindExposed, !- Wind Exposure", + " 0.5000000, !- View Factor to Ground", + " 4, !- Number of Vertices", + " 0,0,3.048000, !- X,Y,Z ==> Vertex 1 {m}", + " 0,0,0, !- X,Y,Z ==> Vertex 2 {m}", + " 6.096000,0,0, !- X,Y,Z ==> Vertex 3 {m}", + " 6.096000,0,3.048000; !- X,Y,Z ==> Vertex 4 {m}", + + " Material,", + " A1 - 1 IN STUCCO, !- Name", + " Smooth, !- Roughness", + " 2.5389841E-02, !- Thickness {m}", + " 0.6918309, !- Conductivity {W/m-K}", + " 1858.142, !- Density {kg/m3}", + " 836.8000, !- Specific Heat {J/kg-K}", + " 0.9000000, !- Thermal Absorptance", + " 0.9200000, !- Solar Absorptance", + " 0.9200000; !- Visible Absorptance", + + " Material,", + " C4 - 4 IN COMMON BRICK, !- Name", + " Rough, !- Roughness", + " 0.1014984, !- Thickness {m}", + " 0.7264224, !- Conductivity {W/m-K}", + " 1922.216, !- Density {kg/m3}", + " 836.8000, !- Specific Heat {J/kg-K}", + " 0.9000000, !- Thermal Absorptance", + " 0.7600000, !- Solar Absorptance", + " 0.7600000; !- Visible Absorptance", + + " Material,", + " E1 - 3 / 4 IN PLASTER OR GYP BOARD, !- Name", + " Smooth, !- Roughness", + " 1.9050000E-02, !- Thickness {m}", + " 0.7264224, !- Conductivity {W/m-K}", + " 1601.846, !- Density {kg/m3}", + " 836.8000, !- Specific Heat {J/kg-K}", + " 0.9000000, !- Thermal Absorptance", + " 0.9200000, !- Solar Absorptance", + " 0.9200000; !- Visible Absorptance", + + " Construction,", + " EXTWALL80, !- Name", + " A1 - 1 IN STUCCO, !- Outside Layer", + " C4 - 4 IN COMMON BRICK, !- Layer 2", + " E1 - 3 / 4 IN PLASTER OR GYP BOARD; !- Layer 3", + + }); + + ASSERT_TRUE(process_idf(idf_objects)); + + state->dataGlobal->NumOfTimeStepInHour = 6; // must initialize this to get schedules initialized + state->dataGlobal->MinutesPerTimeStep = 10; // must initialize this to get schedules initialized + ScheduleManager::ProcessScheduleInput(*state); // read schedule data + + bool errorsFound(false); + HeatBalanceManager::GetProjectControlData(*state, errorsFound); // read project control data + EXPECT_FALSE(errorsFound); + // OutputProcessor::TimeValue.allocate(2); + state->dataGlobal->DDOnlySimulation = true; + + SimulationManager::GetProjectData(*state); + OutputReportPredefined::SetPredefinedTables(*state); + HeatBalanceManager::SetPreConstructionInputParameters(*state); // establish array bounds for constructions early + + state->dataGlobal->BeginSimFlag = true; + state->dataGlobal->BeginEnvrnFlag = true; + state->dataGlobal->ZoneSizingCalc = true; + EnergyPlus::createFacilityElectricPowerServiceObject(*state); + + SizingManager::ManageSizing(*state); + + SimulationManager::SetupSimulation(*state, errorsFound); + // + + Real64 qDotMet(0.0); // Watts total cap + Real64 lDotProvid(0.0); // latent removal kg/s + int compIndex(0); + WindowAC::SimWindowAC(*state, "ZONE1WINDAC", 1, true, qDotMet, lDotProvid, compIndex); + // check input processing + EXPECT_EQ(compIndex, 1); + + double constexpr expected_full_airflow = 0.041484382187390034; + double constexpr scaler_cooling_saf = 0.5; + double constexpr scaler_cooling_cap = 0.5; + double constexpr expected_full_cap = 622.50474573886743; + + auto const &windowAC = state->dataWindowAC->WindAC(compIndex); + + ASSERT_GT(windowAC.FanIndex, 0); + auto const &fan = state->dataFans->fans(windowAC.FanIndex); + + auto const &finalZoneSizing = state->dataSize->FinalZoneSizing(1); + + EXPECT_NEAR(expected_full_airflow, finalZoneSizing.DesCoolVolFlow, 0.0001); + + ASSERT_GT(windowAC.HVACSizingIndex, 0); + auto const &zoneHVACSizing = state->dataSize->ZoneHVACSizing(windowAC.HVACSizingIndex); + + EXPECT_EQ(DataSizing::FractionOfAutosizedCoolingAirflow, zoneHVACSizing.CoolingSAFMethod); + EXPECT_EQ(scaler_cooling_saf, zoneHVACSizing.MaxCoolAirVolFlow); + EXPECT_EQ(DataSizing::FractionOfAutosizedCoolingCapacity, zoneHVACSizing.CoolingCapMethod); + EXPECT_EQ(scaler_cooling_cap, zoneHVACSizing.ScaledCoolingCapacity); + + EXPECT_EQ(windowAC.DXCoilType_Num, HVAC::Coil_CoolingAirToAirVariableSpeed); + ASSERT_GT(windowAC.DXCoilIndex, 0); + auto const &varSpeedCoil = state->dataVariableSpeedCoils->VarSpeedCoil(windowAC.DXCoilIndex); + + // check Sizing + EXPECT_NEAR(expected_full_airflow * scaler_cooling_saf, windowAC.MaxAirVolFlow, 0.0001); + EXPECT_NEAR(expected_full_airflow * scaler_cooling_saf, fan->maxAirFlowRate, 0.0001); + + EXPECT_NEAR(622.505, varSpeedCoil.RatedCapCoolTotal, 0.001); + + // VSD Sizing forces it back to Catalog data based on Nominal Speed Level + double constexpr vsd_coil_norm_speed_tot_cap = 36991.44197; // Speed 1 Reference Unit Gross Rated Total Cooling Capacity {w} + double constexpr vsd_coil_norm_speed_airflow = 3.776; // Speed 1 Reference Unit Gross Rated Cooling COP {dimensionless} + double constexpr vsd_coil_norm_speed_airflow_per_cap = vsd_coil_norm_speed_airflow / vsd_coil_norm_speed_tot_cap; + EXPECT_NEAR(vsd_coil_norm_speed_airflow_per_cap, varSpeedCoil.MSRatedAirVolFlowPerRatedTotCap(1), 0.0001); + EXPECT_NEAR(expected_full_cap * vsd_coil_norm_speed_airflow_per_cap, varSpeedCoil.RatedAirVolFlowRate, 0.0001); + + state->dataZoneEnergyDemand->ZoneSysEnergyDemand(1).RemainingOutputReqToCoolSP = -295.0; + state->dataZoneEnergyDemand->CurDeadBandOrSetback(1) = false; + + WindowAC::SimWindowAC(*state, "ZONE1WINDAC", 1, true, qDotMet, lDotProvid, compIndex); + // check output + EXPECT_NEAR(-295.0, qDotMet, 0.1); + + // #8124 Retrieve zero value data without heating loads + EXPECT_EQ("0.0", OutputReportPredefined::RetrievePreDefTableEntry(*state, state->dataOutRptPredefined->pdchZnHtCalcDesLd, "WEST ZONE")); + EXPECT_EQ("0.0", OutputReportPredefined::RetrievePreDefTableEntry(*state, state->dataOutRptPredefined->pdchZnHtCalcDesAirFlow, "WEST ZONE")); + EXPECT_EQ("0.0", OutputReportPredefined::RetrievePreDefTableEntry(*state, state->dataOutRptPredefined->pdchZnHtUserDesAirFlow, "WEST ZONE")); + EXPECT_EQ("N/A", OutputReportPredefined::RetrievePreDefTableEntry(*state, state->dataOutRptPredefined->pdchZnHtDesDay, "WEST ZONE")); + EXPECT_EQ("N/A", OutputReportPredefined::RetrievePreDefTableEntry(*state, state->dataOutRptPredefined->pdchZnHtPkTime, "WEST ZONE")); +} From 52ffb003dde28bf6318e210982cb88d30dd9958a Mon Sep 17 00:00:00 2001 From: Julien Marrec Date: Mon, 19 Aug 2024 18:11:52 +0200 Subject: [PATCH 3/6] Take a reference directly --- src/EnergyPlus/WindowAC.cc | 44 ++++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/src/EnergyPlus/WindowAC.cc b/src/EnergyPlus/WindowAC.cc index 21fc96df840..50e720604b2 100644 --- a/src/EnergyPlus/WindowAC.cc +++ b/src/EnergyPlus/WindowAC.cc @@ -892,8 +892,6 @@ namespace WindowAC { // METHODOLOGY EMPLOYED: // Obtains flow rates from the zone or system sizing arrays - auto &ZoneEqSizing(state.dataSize->ZoneEqSizing); - // Using/Aliasing using namespace DataSizing; using HVAC::CoolingCapacitySizing; @@ -941,6 +939,8 @@ namespace WindowAC { state.dataSize->DataFanIndex = state.dataWindowAC->WindAC(WindACNum).FanIndex; state.dataSize->DataFanPlacement = state.dataWindowAC->WindAC(WindACNum).fanPlace; + auto &zoneEqSizing = state.dataSize->ZoneEqSizing(state.dataSize->CurZoneEqNum); + if (state.dataSize->CurZoneEqNum > 0) { if (state.dataWindowAC->WindAC(WindACNum).HVACSizingIndex > 0) { zoneHVACIndex = state.dataWindowAC->WindAC(WindACNum).HVACSizingIndex; @@ -948,20 +948,20 @@ namespace WindowAC { SizingMethod = HVAC::CoolingAirflowSizing; PrintFlag = true; SAFMethod = state.dataSize->ZoneHVACSizing(zoneHVACIndex).CoolingSAFMethod; - ZoneEqSizing(state.dataSize->CurZoneEqNum).SizingMethod(SizingMethod) = SAFMethod; + zoneEqSizing.SizingMethod(SizingMethod) = SAFMethod; if (SAFMethod == None || SAFMethod == SupplyAirFlowRate || SAFMethod == FlowPerFloorArea || SAFMethod == FractionOfAutosizedCoolingAirflow) { if (SAFMethod == SupplyAirFlowRate) { if (state.dataSize->ZoneHVACSizing(zoneHVACIndex).MaxCoolAirVolFlow > 0.0) { - ZoneEqSizing(state.dataSize->CurZoneEqNum).AirVolFlow = state.dataSize->ZoneHVACSizing(zoneHVACIndex).MaxCoolAirVolFlow; - ZoneEqSizing(state.dataSize->CurZoneEqNum).SystemAirFlow = true; + zoneEqSizing.AirVolFlow = state.dataSize->ZoneHVACSizing(zoneHVACIndex).MaxCoolAirVolFlow; + zoneEqSizing.SystemAirFlow = true; } TempSize = state.dataSize->ZoneHVACSizing(zoneHVACIndex).MaxCoolAirVolFlow; } else if (SAFMethod == FlowPerFloorArea) { - ZoneEqSizing(state.dataSize->CurZoneEqNum).SystemAirFlow = true; - ZoneEqSizing(state.dataSize->CurZoneEqNum).AirVolFlow = state.dataSize->ZoneHVACSizing(zoneHVACIndex).MaxCoolAirVolFlow * + zoneEqSizing.SystemAirFlow = true; + zoneEqSizing.AirVolFlow = state.dataSize->ZoneHVACSizing(zoneHVACIndex).MaxCoolAirVolFlow * state.dataHeatBal->Zone(state.dataSize->DataZoneNumber).FloorArea; - TempSize = ZoneEqSizing(state.dataSize->CurZoneEqNum).AirVolFlow; + TempSize = zoneEqSizing.AirVolFlow; state.dataSize->DataScalableSizingON = true; } else if (SAFMethod == FractionOfAutosizedCoolingAirflow) { state.dataSize->DataFracOfAutosizedCoolingAirflow = state.dataSize->ZoneHVACSizing(zoneHVACIndex).MaxCoolAirVolFlow; @@ -973,7 +973,9 @@ namespace WindowAC { bool errorsFound = false; CoolingAirFlowSizer sizingCoolingAirFlow; std::string stringOverride = "Maximum Supply Air Flow Rate [m3/s]"; - if (state.dataGlobal->isEpJSON) stringOverride = "maximum_supply_air_flow_rate [m3/s]"; + if (state.dataGlobal->isEpJSON) { + stringOverride = "maximum_supply_air_flow_rate [m3/s]"; + } sizingCoolingAirFlow.overrideSizingString(stringOverride); // sizingCoolingAirFlow.setHVACSizingIndexData(FanCoil(FanCoilNum).HVACSizingIndex); sizingCoolingAirFlow.initializeWithinEP(state, CompType, CompName, PrintFlag, RoutineName); @@ -999,7 +1001,9 @@ namespace WindowAC { errorsFound = false; CoolingAirFlowSizer sizingCoolingAirFlow; std::string stringOverride = "Maximum Supply Air Flow Rate [m3/s]"; - if (state.dataGlobal->isEpJSON) stringOverride = "maximum_supply_air_flow_rate [m3/s]"; + if (state.dataGlobal->isEpJSON) { + stringOverride = "maximum_supply_air_flow_rate [m3/s]"; + } sizingCoolingAirFlow.overrideSizingString(stringOverride); // sizingCoolingAirFlow.setHVACSizingIndexData(FanCoil(FanCoilNum).HVACSizingIndex); sizingCoolingAirFlow.initializeWithinEP(state, CompType, CompName, PrintFlag, RoutineName); @@ -1009,20 +1013,18 @@ namespace WindowAC { // initialize capacity sizing variables: cooling CapSizingMethod = state.dataSize->ZoneHVACSizing(zoneHVACIndex).CoolingCapMethod; - ZoneEqSizing(state.dataSize->CurZoneEqNum).SizingMethod(SizingMethod) = CapSizingMethod; + zoneEqSizing.SizingMethod(SizingMethod) = CapSizingMethod; if (CapSizingMethod == CoolingDesignCapacity || CapSizingMethod == CapacityPerFloorArea || CapSizingMethod == FractionOfAutosizedCoolingCapacity) { if (CapSizingMethod == HeatingDesignCapacity) { if (state.dataSize->ZoneHVACSizing(zoneHVACIndex).ScaledCoolingCapacity > 0.0) { - ZoneEqSizing(state.dataSize->CurZoneEqNum).CoolingCapacity = true; - ZoneEqSizing(state.dataSize->CurZoneEqNum).DesCoolingLoad = - state.dataSize->ZoneHVACSizing(zoneHVACIndex).ScaledCoolingCapacity; + zoneEqSizing.CoolingCapacity = true; + zoneEqSizing.DesCoolingLoad = state.dataSize->ZoneHVACSizing(zoneHVACIndex).ScaledCoolingCapacity; } } else if (CapSizingMethod == CapacityPerFloorArea) { - ZoneEqSizing(state.dataSize->CurZoneEqNum).CoolingCapacity = true; - ZoneEqSizing(state.dataSize->CurZoneEqNum).DesCoolingLoad = - state.dataSize->ZoneHVACSizing(zoneHVACIndex).ScaledCoolingCapacity * - state.dataHeatBal->Zone(state.dataSize->DataZoneNumber).FloorArea; + zoneEqSizing.CoolingCapacity = true; + zoneEqSizing.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; @@ -1030,7 +1032,7 @@ namespace WindowAC { } } } else { - // no scalble sizing method has been specified. Sizing proceeds using the method + // no scalable sizing method has been specified. Sizing proceeds using the method // specified in the zoneHVAC object // N1 , \field Maximum Supply Air Flow Rate FieldNum = 1; @@ -1067,8 +1069,8 @@ namespace WindowAC { } if (state.dataSize->CurZoneEqNum > 0) { - ZoneEqSizing(state.dataSize->CurZoneEqNum).OAVolFlow = state.dataWindowAC->WindAC(WindACNum).OutAirVolFlow; - ZoneEqSizing(state.dataSize->CurZoneEqNum).AirVolFlow = state.dataWindowAC->WindAC(WindACNum).MaxAirVolFlow; + zoneEqSizing.OAVolFlow = state.dataWindowAC->WindAC(WindACNum).OutAirVolFlow; + zoneEqSizing.AirVolFlow = state.dataWindowAC->WindAC(WindACNum).MaxAirVolFlow; } state.dataSize->DataScalableCapSizingON = false; From 5dbc7b13c8597788540474a075a5eab678a3ce12 Mon Sep 17 00:00:00 2001 From: Julien Marrec Date: Tue, 20 Aug 2024 12:15:46 +0200 Subject: [PATCH 4/6] Revamp the routine to take more references to shorten the code, scope the variables, initialize them, don't check 4 times if CurZoneEqNum is > 0 --- src/EnergyPlus/WindowAC.cc | 149 +++++++++++++++++-------------------- 1 file changed, 68 insertions(+), 81 deletions(-) diff --git a/src/EnergyPlus/WindowAC.cc b/src/EnergyPlus/WindowAC.cc index 50e720604b2..de437978e55 100644 --- a/src/EnergyPlus/WindowAC.cc +++ b/src/EnergyPlus/WindowAC.cc @@ -900,30 +900,19 @@ namespace WindowAC { static constexpr std::string_view RoutineName("SizeWindowAC: "); // include trailing blank space // SUBROUTINE LOCAL VARIABLE DECLARATIONS: - Real64 MaxAirVolFlowDes; // Autosized maximum air flow for reporting - Real64 MaxAirVolFlowUser; // Hardsized maximum air flow for reporting - Real64 OutAirVolFlowDes; // Autosized outdoor air flow for reporting - Real64 OutAirVolFlowUser; // Hardsized outdoor ari flow for reporting - bool IsAutoSize; // Indicator to autosize - std::string CompName; // component name - std::string CompType; // component type - std::string SizingString; // input field sizing description (e.g., Nominal Capacity) - Real64 TempSize; // autosized value of coil input field - int FieldNum = 2; // IDD numeric field number where input field description is found - int SizingMethod; // Integer representation of sizing method name (e.g., CoolingAirflowSizing, HeatingAirflowSizing, CoolingCapacitySizing, - // HeatingCapacitySizing, etc.) - bool PrintFlag; // TRUE when sizing information is reported in the eio file - int zoneHVACIndex; // index of zoneHVAC equipment sizing specification - int SAFMethod(0); // supply air flow rate sizing method (SupplyAirFlowRate, FlowPerFloorArea, FractionOfAutosizedCoolingAirflow, - // FractionOfAutosizedHeatingAirflow ...) - int CapSizingMethod(0); // capacity sizing methods (HeatingDesignCapacity, CapacityPerFloorArea, FractionOfAutosizedCoolingCapacity, and - // FractionOfAutosizedHeatingCapacity ) - - IsAutoSize = false; - MaxAirVolFlowDes = 0.0; - MaxAirVolFlowUser = 0.0; - OutAirVolFlowDes = 0.0; - OutAirVolFlowUser = 0.0; + auto &windowAC = state.dataWindowAC->WindAC(WindACNum); + + Real64 MaxAirVolFlowDes = 0.0; // Autosized maximum air flow for reporting + Real64 MaxAirVolFlowUser = 0.0; // Hardsized maximum air flow for reporting + Real64 OutAirVolFlowDes = 0.0; // Autosized outdoor air flow for reporting + Real64 OutAirVolFlowUser = 0.0; // Hardsized outdoor ari flow for reporting + bool IsAutoSize = false; // Indicator to autosize + std::string const CompType = "ZoneHVAC:WindowAirConditioner"; // component name + std::string const CompName = windowAC.Name; // component type + Real64 TempSize = AutoSize; // autosized value of coil input field + int FieldNum = 2; // IDD numeric field number where input field description is found + bool PrintFlag = false; // TRUE when sizing information is reported in the eio file + state.dataSize->DataFracOfAutosizedCoolingAirflow = 1.0; state.dataSize->DataFracOfAutosizedHeatingAirflow = 1.0; state.dataSize->DataFracOfAutosizedCoolingCapacity = 1.0; @@ -932,43 +921,47 @@ namespace WindowAC { state.dataSize->ZoneHeatingOnlyFan = false; state.dataSize->ZoneCoolingOnlyFan = true; state.dataSize->DataScalableCapSizingON = false; - CompType = "ZoneHVAC:WindowAirConditioner"; - CompName = state.dataWindowAC->WindAC(WindACNum).Name; - state.dataSize->DataZoneNumber = state.dataWindowAC->WindAC(WindACNum).ZonePtr; - state.dataSize->DataFanType = state.dataWindowAC->WindAC(WindACNum).fanType; - state.dataSize->DataFanIndex = state.dataWindowAC->WindAC(WindACNum).FanIndex; - state.dataSize->DataFanPlacement = state.dataWindowAC->WindAC(WindACNum).fanPlace; - - auto &zoneEqSizing = state.dataSize->ZoneEqSizing(state.dataSize->CurZoneEqNum); + state.dataSize->DataZoneNumber = windowAC.ZonePtr; + state.dataSize->DataFanType = windowAC.fanType; + state.dataSize->DataFanIndex = windowAC.FanIndex; + state.dataSize->DataFanPlacement = windowAC.fanPlace; if (state.dataSize->CurZoneEqNum > 0) { - if (state.dataWindowAC->WindAC(WindACNum).HVACSizingIndex > 0) { - zoneHVACIndex = state.dataWindowAC->WindAC(WindACNum).HVACSizingIndex; + auto &zoneEqSizing = state.dataSize->ZoneEqSizing(state.dataSize->CurZoneEqNum); + + if (windowAC.HVACSizingIndex > 0) { // N1 , \field Maximum Supply Air Flow Rate - SizingMethod = HVAC::CoolingAirflowSizing; + + auto const &zoneHVACSizing = state.dataSize->ZoneHVACSizing(windowAC.HVACSizingIndex); + + // Integer representation of sizing method name (e.g., CoolingAirflowSizing, HeatingAirflowSizing, CoolingCapacitySizing, + // HeatingCapacitySizing, etc. + int SizingMethod = HVAC::CoolingAirflowSizing; PrintFlag = true; - SAFMethod = state.dataSize->ZoneHVACSizing(zoneHVACIndex).CoolingSAFMethod; + // supply air flow rate sizing method (SupplyAirFlowRate, FlowPerFloorArea, FractionOfAutosizedCoolingAirflow, + // FractionOfAutosizedHeatingAirflow) + int const SAFMethod = zoneHVACSizing.CoolingSAFMethod; zoneEqSizing.SizingMethod(SizingMethod) = SAFMethod; if (SAFMethod == None || SAFMethod == SupplyAirFlowRate || SAFMethod == FlowPerFloorArea || SAFMethod == FractionOfAutosizedCoolingAirflow) { if (SAFMethod == SupplyAirFlowRate) { - if (state.dataSize->ZoneHVACSizing(zoneHVACIndex).MaxCoolAirVolFlow > 0.0) { - zoneEqSizing.AirVolFlow = state.dataSize->ZoneHVACSizing(zoneHVACIndex).MaxCoolAirVolFlow; + if (zoneHVACSizing.MaxCoolAirVolFlow > 0.0) { + zoneEqSizing.AirVolFlow = zoneHVACSizing.MaxCoolAirVolFlow; zoneEqSizing.SystemAirFlow = true; } - TempSize = state.dataSize->ZoneHVACSizing(zoneHVACIndex).MaxCoolAirVolFlow; + TempSize = zoneHVACSizing.MaxCoolAirVolFlow; } else if (SAFMethod == FlowPerFloorArea) { zoneEqSizing.SystemAirFlow = true; - zoneEqSizing.AirVolFlow = state.dataSize->ZoneHVACSizing(zoneHVACIndex).MaxCoolAirVolFlow * - state.dataHeatBal->Zone(state.dataSize->DataZoneNumber).FloorArea; + zoneEqSizing.AirVolFlow = + zoneHVACSizing.MaxCoolAirVolFlow * state.dataHeatBal->Zone(state.dataSize->DataZoneNumber).FloorArea; TempSize = zoneEqSizing.AirVolFlow; state.dataSize->DataScalableSizingON = true; } else if (SAFMethod == FractionOfAutosizedCoolingAirflow) { - state.dataSize->DataFracOfAutosizedCoolingAirflow = state.dataSize->ZoneHVACSizing(zoneHVACIndex).MaxCoolAirVolFlow; + state.dataSize->DataFracOfAutosizedCoolingAirflow = zoneHVACSizing.MaxCoolAirVolFlow; TempSize = AutoSize; state.dataSize->DataScalableSizingON = true; } else { - TempSize = state.dataSize->ZoneHVACSizing(zoneHVACIndex).MaxCoolAirVolFlow; + TempSize = zoneHVACSizing.MaxCoolAirVolFlow; } bool errorsFound = false; CoolingAirFlowSizer sizingCoolingAirFlow; @@ -977,25 +970,25 @@ namespace WindowAC { stringOverride = "maximum_supply_air_flow_rate [m3/s]"; } sizingCoolingAirFlow.overrideSizingString(stringOverride); - // sizingCoolingAirFlow.setHVACSizingIndexData(FanCoil(FanCoilNum).HVACSizingIndex); + // sizingCoolingAirFlow.setHVACSizingIndexData(windowAC.HVACSizingIndex); sizingCoolingAirFlow.initializeWithinEP(state, CompType, CompName, PrintFlag, RoutineName); - state.dataWindowAC->WindAC(WindACNum).MaxAirVolFlow = sizingCoolingAirFlow.size(state, TempSize, errorsFound); + windowAC.MaxAirVolFlow = sizingCoolingAirFlow.size(state, TempSize, errorsFound); } else if (SAFMethod == FlowPerCoolingCapacity) { - SizingMethod = CoolingCapacitySizing; + SizingMethod = HVAC::CoolingCapacitySizing; TempSize = AutoSize; PrintFlag = false; state.dataSize->DataScalableSizingON = true; state.dataSize->DataFlowUsedForSizing = state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).DesCoolVolFlow; - if (state.dataSize->ZoneHVACSizing(zoneHVACIndex).CoolingCapMethod == FractionOfAutosizedCoolingCapacity) { - state.dataSize->DataFracOfAutosizedCoolingCapacity = state.dataSize->ZoneHVACSizing(zoneHVACIndex).ScaledCoolingCapacity; + if (zoneHVACSizing.CoolingCapMethod == FractionOfAutosizedCoolingCapacity) { + state.dataSize->DataFracOfAutosizedCoolingCapacity = zoneHVACSizing.ScaledCoolingCapacity; } bool errorsFound = false; CoolingCapacitySizer sizerCoolingCapacity; - sizerCoolingCapacity.overrideSizingString(SizingString); + sizerCoolingCapacity.overrideSizingString(""); sizerCoolingCapacity.initializeWithinEP(state, CompType, CompName, PrintFlag, RoutineName); state.dataSize->DataCapacityUsedForSizing = sizerCoolingCapacity.size(state, TempSize, errorsFound); - state.dataSize->DataFlowPerCoolingCapacity = state.dataSize->ZoneHVACSizing(zoneHVACIndex).MaxCoolAirVolFlow; + state.dataSize->DataFlowPerCoolingCapacity = zoneHVACSizing.MaxCoolAirVolFlow; PrintFlag = true; TempSize = AutoSize; errorsFound = false; @@ -1005,29 +998,31 @@ namespace WindowAC { stringOverride = "maximum_supply_air_flow_rate [m3/s]"; } sizingCoolingAirFlow.overrideSizingString(stringOverride); - // sizingCoolingAirFlow.setHVACSizingIndexData(FanCoil(FanCoilNum).HVACSizingIndex); + // sizingCoolingAirFlow.setHVACSizingIndexData(windowAC.HVACSizingIndex); sizingCoolingAirFlow.initializeWithinEP(state, CompType, CompName, PrintFlag, RoutineName); - state.dataWindowAC->WindAC(WindACNum).MaxAirVolFlow = sizingCoolingAirFlow.size(state, TempSize, errorsFound); + windowAC.MaxAirVolFlow = sizingCoolingAirFlow.size(state, TempSize, errorsFound); } // DataScalableSizingON = false; // initialize capacity sizing variables: cooling - CapSizingMethod = state.dataSize->ZoneHVACSizing(zoneHVACIndex).CoolingCapMethod; + // capacity sizing methods (HeatingDesignCapacity, CapacityPerFloorArea, FractionOfAutosizedCoolingCapacity, and + // FractionOfAutosizedHeatingCapacity ) + int const CapSizingMethod = zoneHVACSizing.CoolingCapMethod; zoneEqSizing.SizingMethod(SizingMethod) = CapSizingMethod; if (CapSizingMethod == CoolingDesignCapacity || CapSizingMethod == CapacityPerFloorArea || CapSizingMethod == FractionOfAutosizedCoolingCapacity) { if (CapSizingMethod == HeatingDesignCapacity) { - if (state.dataSize->ZoneHVACSizing(zoneHVACIndex).ScaledCoolingCapacity > 0.0) { + if (zoneHVACSizing.ScaledCoolingCapacity > 0.0) { zoneEqSizing.CoolingCapacity = true; - zoneEqSizing.DesCoolingLoad = state.dataSize->ZoneHVACSizing(zoneHVACIndex).ScaledCoolingCapacity; + zoneEqSizing.DesCoolingLoad = zoneHVACSizing.ScaledCoolingCapacity; } } else if (CapSizingMethod == CapacityPerFloorArea) { zoneEqSizing.CoolingCapacity = true; - zoneEqSizing.DesCoolingLoad = state.dataSize->ZoneHVACSizing(zoneHVACIndex).ScaledCoolingCapacity * - state.dataHeatBal->Zone(state.dataSize->DataZoneNumber).FloorArea; + zoneEqSizing.DesCoolingLoad = + zoneHVACSizing.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->DataFracOfAutosizedCoolingCapacity = zoneHVACSizing.ScaledCoolingCapacity; state.dataSize->DataScalableCapSizingON = true; } } @@ -1037,40 +1032,32 @@ namespace WindowAC { // N1 , \field Maximum Supply Air Flow Rate FieldNum = 1; PrintFlag = true; - SizingString = state.dataWindowAC->WindACNumericFields(WindACNum).FieldNames(FieldNum) + " [m3/s]"; - TempSize = state.dataWindowAC->WindAC(WindACNum).MaxAirVolFlow; + std::string stringOverride = state.dataWindowAC->WindACNumericFields(WindACNum).FieldNames(FieldNum) + " [m3/s]"; + TempSize = windowAC.MaxAirVolFlow; bool errorsFound = false; SystemAirFlowSizer sizerSystemAirFlow; - sizerSystemAirFlow.overrideSizingString(SizingString); - // sizerSystemAirFlow.setHVACSizingIndexData(FanCoil(FanCoilNum).HVACSizingIndex); + sizerSystemAirFlow.overrideSizingString(stringOverride); + // sizerSystemAirFlow.setHVACSizingIndexData(windowAC.HVACSizingIndex); sizerSystemAirFlow.initializeWithinEP(state, CompType, CompName, PrintFlag, RoutineName); - state.dataWindowAC->WindAC(WindACNum).MaxAirVolFlow = sizerSystemAirFlow.size(state, TempSize, errorsFound); + windowAC.MaxAirVolFlow = sizerSystemAirFlow.size(state, TempSize, errorsFound); } - } - - if (state.dataWindowAC->WindAC(WindACNum).OutAirVolFlow == AutoSize) { - if (state.dataSize->CurZoneEqNum > 0) { + if (windowAC.OutAirVolFlow == AutoSize) { - CheckZoneSizing(state, - state.dataWindowAC->cWindowAC_UnitTypes(state.dataWindowAC->WindAC(WindACNum).UnitType), - state.dataWindowAC->WindAC(WindACNum).Name); - state.dataWindowAC->WindAC(WindACNum).OutAirVolFlow = - min(state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).MinOA, state.dataWindowAC->WindAC(WindACNum).MaxAirVolFlow); - if (state.dataWindowAC->WindAC(WindACNum).OutAirVolFlow < SmallAirVolFlow) { - state.dataWindowAC->WindAC(WindACNum).OutAirVolFlow = 0.0; + CheckZoneSizing(state, state.dataWindowAC->cWindowAC_UnitTypes(windowAC.UnitType), windowAC.Name); + windowAC.OutAirVolFlow = min(state.dataSize->FinalZoneSizing(state.dataSize->CurZoneEqNum).MinOA, windowAC.MaxAirVolFlow); + if (windowAC.OutAirVolFlow < SmallAirVolFlow) { + windowAC.OutAirVolFlow = 0.0; } BaseSizer::reportSizerOutput(state, - state.dataWindowAC->cWindowAC_UnitTypes(state.dataWindowAC->WindAC(WindACNum).UnitType), - state.dataWindowAC->WindAC(WindACNum).Name, + state.dataWindowAC->cWindowAC_UnitTypes(windowAC.UnitType), + windowAC.Name, "Maximum Outdoor Air Flow Rate [m3/s]", - state.dataWindowAC->WindAC(WindACNum).OutAirVolFlow); + windowAC.OutAirVolFlow); } - } - if (state.dataSize->CurZoneEqNum > 0) { - zoneEqSizing.OAVolFlow = state.dataWindowAC->WindAC(WindACNum).OutAirVolFlow; - zoneEqSizing.AirVolFlow = state.dataWindowAC->WindAC(WindACNum).MaxAirVolFlow; + zoneEqSizing.OAVolFlow = windowAC.OutAirVolFlow; + zoneEqSizing.AirVolFlow = windowAC.MaxAirVolFlow; } state.dataSize->DataScalableCapSizingON = false; From f472e96ac9b2188de62330fdc603ec5f3fb45779 Mon Sep 17 00:00:00 2001 From: Julien Marrec Date: Mon, 19 Aug 2024 18:30:30 +0200 Subject: [PATCH 5/6] Fix existing logic error related to Cooling Capacity sizing --- src/EnergyPlus/WindowAC.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/EnergyPlus/WindowAC.cc b/src/EnergyPlus/WindowAC.cc index de437978e55..585cfc90d8e 100644 --- a/src/EnergyPlus/WindowAC.cc +++ b/src/EnergyPlus/WindowAC.cc @@ -1011,7 +1011,7 @@ namespace WindowAC { zoneEqSizing.SizingMethod(SizingMethod) = CapSizingMethod; if (CapSizingMethod == CoolingDesignCapacity || CapSizingMethod == CapacityPerFloorArea || CapSizingMethod == FractionOfAutosizedCoolingCapacity) { - if (CapSizingMethod == HeatingDesignCapacity) { + if (CapSizingMethod == CoolingDesignCapacity) { if (zoneHVACSizing.ScaledCoolingCapacity > 0.0) { zoneEqSizing.CoolingCapacity = true; zoneEqSizing.DesCoolingLoad = zoneHVACSizing.ScaledCoolingCapacity; From a5d32dea2e5a7ea6c68c38b6f073176a9cdc9ce1 Mon Sep 17 00:00:00 2001 From: Julien Marrec Date: Tue, 20 Aug 2024 12:29:41 +0200 Subject: [PATCH 6/6] Set CoolingAirFlow flag in WindowAC so fan is sized by the WindowAC --- src/EnergyPlus/WindowAC.cc | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/EnergyPlus/WindowAC.cc b/src/EnergyPlus/WindowAC.cc index 585cfc90d8e..43031b68f84 100644 --- a/src/EnergyPlus/WindowAC.cc +++ b/src/EnergyPlus/WindowAC.cc @@ -1058,6 +1058,9 @@ namespace WindowAC { zoneEqSizing.OAVolFlow = windowAC.OutAirVolFlow; zoneEqSizing.AirVolFlow = windowAC.MaxAirVolFlow; + // Make the Fan be sized by this + zoneEqSizing.CoolingAirFlow = true; + zoneEqSizing.CoolingAirVolFlow = windowAC.MaxAirVolFlow; } state.dataSize->DataScalableCapSizingON = false;