Line data Source code
1 : // EnergyPlus, Copyright (c) 1996-2024, The Board of Trustees of the University of Illinois,
2 : // The Regents of the University of California, through Lawrence Berkeley National Laboratory
3 : // (subject to receipt of any required approvals from the U.S. Dept. of Energy), Oak Ridge
4 : // National Laboratory, managed by UT-Battelle, Alliance for Sustainable Energy, LLC, and other
5 : // contributors. All rights reserved.
6 : //
7 : // NOTICE: This Software was developed under funding from the U.S. Department of Energy and the
8 : // U.S. Government consequently retains certain rights. As such, the U.S. Government has been
9 : // granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable,
10 : // worldwide license in the Software to reproduce, distribute copies to the public, prepare
11 : // derivative works, and perform publicly and display publicly, and to permit others to do so.
12 : //
13 : // Redistribution and use in source and binary forms, with or without modification, are permitted
14 : // provided that the following conditions are met:
15 : //
16 : // (1) Redistributions of source code must retain the above copyright notice, this list of
17 : // conditions and the following disclaimer.
18 : //
19 : // (2) Redistributions in binary form must reproduce the above copyright notice, this list of
20 : // conditions and the following disclaimer in the documentation and/or other materials
21 : // provided with the distribution.
22 : //
23 : // (3) Neither the name of the University of California, Lawrence Berkeley National Laboratory,
24 : // the University of Illinois, U.S. Dept. of Energy nor the names of its contributors may be
25 : // used to endorse or promote products derived from this software without specific prior
26 : // written permission.
27 : //
28 : // (4) Use of EnergyPlus(TM) Name. If Licensee (i) distributes the software in stand-alone form
29 : // without changes from the version obtained under this License, or (ii) Licensee makes a
30 : // reference solely to the software portion of its product, Licensee must refer to the
31 : // software as "EnergyPlus version X" software, where "X" is the version number Licensee
32 : // obtained under this License and may not use a different name for the software. Except as
33 : // specifically required in this Section (4), Licensee shall not use in a company name, a
34 : // product name, in advertising, publicity, or other promotional activities any name, trade
35 : // name, trademark, logo, or other designation of "EnergyPlus", "E+", "e+" or confusingly
36 : // similar designation, without the U.S. Department of Energy's prior written consent.
37 : //
38 : // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
39 : // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
40 : // AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
41 : // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
42 : // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
43 : // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
44 : // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
45 : // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
46 : // POSSIBILITY OF SUCH DAMAGE.
47 :
48 : #ifndef ZoneEquipmentManager_hh_INCLUDED
49 : #define ZoneEquipmentManager_hh_INCLUDED
50 :
51 : // ObjexxFCL Headers
52 : #include <ObjexxFCL/Array1D.hh>
53 : #include <ObjexxFCL/Optional.hh>
54 :
55 : // EnergyPlus Headers
56 : #include <EnergyPlus/Data/BaseData.hh>
57 : #include <EnergyPlus/DataGlobalConstants.hh>
58 : #include <EnergyPlus/DataGlobals.hh>
59 : #include <EnergyPlus/DataHeatBalance.hh>
60 : #include <EnergyPlus/DataSizing.hh>
61 : #include <EnergyPlus/DataZoneEnergyDemands.hh>
62 : #include <EnergyPlus/DataZoneEquipment.hh>
63 : #include <EnergyPlus/EnergyPlus.hh>
64 :
65 : namespace EnergyPlus {
66 :
67 : // Forward declarations
68 : struct EnergyPlusData;
69 :
70 : namespace ZoneEquipmentManager {
71 :
72 : struct SimulationOrder
73 : {
74 : std::string EquipTypeName = "";
75 : DataZoneEquipment::ZoneEquipType equipType = DataZoneEquipment::ZoneEquipType::Invalid;
76 : std::string EquipName = "";
77 : int EquipPtr = 0;
78 : int CoolingPriority = 0;
79 : int HeatingPriority = 0;
80 : };
81 :
82 : void ManageZoneEquipment(EnergyPlusData &state,
83 : bool FirstHVACIteration,
84 : bool &SimZone, // Set to false at the end of the routine
85 : bool &SimAir // Eventually set to true via SimZoneEquipment if AirLoop must be resimulated
86 : );
87 :
88 : void GetZoneEquipment(EnergyPlusData &state);
89 :
90 : void InitZoneEquipment(EnergyPlusData &state, bool FirstHVACIteration); // unused 1208
91 :
92 : void sizeZoneSpaceEquipmentPart1(EnergyPlusData &state,
93 : DataZoneEquipment::EquipConfiguration &ZoneEquipConfig,
94 : DataSizing::ZoneSizingData &zsCalcSizing,
95 : DataZoneEnergyDemands::ZoneSystemSensibleDemand &zsEnergyDemand,
96 : DataZoneEnergyDemands::ZoneSystemMoistureDemand &zsMoistureDemand,
97 : DataHeatBalance::ZoneData &zoneOrSpace,
98 : int zoneNum,
99 : int spaceNum = 0);
100 :
101 : void sizeZoneSpaceEquipmentPart2(EnergyPlusData &state,
102 : DataZoneEquipment::EquipConfiguration &zoneEquipConfig,
103 : DataSizing::ZoneSizingData &zsCalcSizing,
104 : int zoneNum,
105 : int spaceNum = 0);
106 :
107 : void SizeZoneEquipment(EnergyPlusData &state);
108 :
109 : void SetUpZoneSizingArrays(EnergyPlusData &state);
110 :
111 : void fillZoneSizingFromInput(EnergyPlusData &state,
112 : DataSizing::ZoneSizingInputData const &zoneSizingInput,
113 : Array2D<DataSizing::ZoneSizingData> &zsSizing,
114 : Array2D<DataSizing::ZoneSizingData> &zsCalcSizing,
115 : DataSizing::ZoneSizingData &zsFinalSizing,
116 : DataSizing::ZoneSizingData &zsCalcFinalSizing,
117 : std::string_view const zoneOrSpaceName,
118 : int const zoneOrSpaceNum);
119 :
120 : void RezeroZoneSizingArrays(EnergyPlusData &state);
121 :
122 : void UpdateZoneSizing(EnergyPlusData &state, Constant::CallIndicator CallIndicator);
123 :
124 : void updateZoneSizingBeginDay(EnergyPlusData &state, DataSizing::ZoneSizingData &zsCalcSizing);
125 :
126 : void updateZoneSizingDuringDay(DataSizing::ZoneSizingData &zsSizing,
127 : DataSizing::ZoneSizingData &zsCalcSizing,
128 : Real64 const tstatHi,
129 : Real64 const tstatLo,
130 : Real64 &sizTstatHi,
131 : Real64 &sizTstatLo,
132 : int const timeStepInDay,
133 : Real64 const fracTimeStepZone);
134 :
135 : void updateZoneSizingEndDayMovingAvg(DataSizing::ZoneSizingData &zsCalcSizing, int const numTimeStepsInAvg);
136 :
137 : void updateZoneSizingEndDay(DataSizing::ZoneSizingData &zsCalcSizing,
138 : DataSizing::ZoneSizingData &zsCalcFinalSizing,
139 : int const numTimeStepInDay,
140 : DataSizing::DesDayWeathData const &desDayWeath,
141 : Real64 const stdRhoAir);
142 :
143 : void updateZoneSizingEndZoneSizingCalc1(EnergyPlusData &state, int const zoneNum);
144 :
145 : void updateZoneSizingEndZoneSizingCalc2(EnergyPlusData &state, DataSizing::ZoneSizingData &zsCalcSizing);
146 :
147 : void writeZszSpsz(EnergyPlusData &state,
148 : EnergyPlus::InputOutputFile &outputFile,
149 : int const numSpacesOrZones,
150 : Array1D<DataZoneEquipment::EquipConfiguration> const zsEquipConfig,
151 : EPVector<DataSizing::ZoneSizingData> const &zsCalcFinalSizing,
152 : Array2D<DataSizing::ZoneSizingData> const &zsCalcSizing);
153 :
154 : std::string sizingPeakTimeStamp(EnergyPlusData &state, int timeStepIndex);
155 :
156 : void updateZoneSizingEndZoneSizingCalc3(DataSizing::ZoneSizingData &zsCalcFinalSizing,
157 : Array2D<DataSizing::ZoneSizingData> &zsCalcSizing,
158 : bool &anyLatentLoad,
159 : int const zoneOrSpaceNum);
160 :
161 : void updateZoneSizingEndZoneSizingCalc4(DataSizing::ZoneSizingData &zsSizing, DataSizing::ZoneSizingData const &zsCalcSizing);
162 :
163 : void updateZoneSizingEndZoneSizingCalc5(DataSizing::ZoneSizingData &zsFinalSizing, DataSizing::ZoneSizingData const &zsCalcFinalSizing);
164 :
165 : void updateZoneSizingEndZoneSizingCalc6(DataSizing::ZoneSizingData &zsSizing,
166 : DataSizing::ZoneSizingData const &zsCalcSizing,
167 : int const numTimeStepsInDay);
168 :
169 : void updateZoneSizingEndZoneSizingCalc7(EnergyPlusData &state,
170 : DataSizing::ZoneSizingData &zsFinalSizing,
171 : DataSizing::ZoneSizingData &zsCalcFinalSizing,
172 : Array2D<DataSizing::ZoneSizingData> &zsSizing,
173 : Array2D<DataSizing::ZoneSizingData> &zsCalcSizing,
174 : int const zoneOrSpaceNum);
175 :
176 : void SimZoneEquipment(EnergyPlusData &state, bool FirstHVACIteration, bool &SimAir);
177 :
178 : void SetZoneEquipSimOrder(EnergyPlusData &state, int ControlledZoneNum);
179 :
180 : void InitSystemOutputRequired(EnergyPlusData &state, int ZoneNum, bool FirstHVACIteration, bool ResetSimOrder = false);
181 :
182 : void initOutputRequired(EnergyPlusData &state,
183 : int const ZoneNum,
184 : DataZoneEnergyDemands::ZoneSystemSensibleDemand &energy,
185 : DataZoneEnergyDemands::ZoneSystemMoistureDemand &moisture,
186 : bool const FirstHVACIteration,
187 : bool const ResetSimOrder,
188 : int spaceNum = 0);
189 :
190 : void DistributeSystemOutputRequired(EnergyPlusData &state, int ZoneNum, bool FirstHVACIteration);
191 :
192 : void distributeOutputRequired(EnergyPlusData &state,
193 : int const ZoneNum,
194 : DataZoneEnergyDemands::ZoneSystemSensibleDemand &energy,
195 : DataZoneEnergyDemands::ZoneSystemMoistureDemand &moisture);
196 :
197 : void updateSystemOutputRequired(EnergyPlusData &state,
198 : int const ZoneNum,
199 : Real64 const SysOutputProvided, // sensible output provided by zone equipment (W)
200 : Real64 const LatOutputProvided, // latent output provided by zone equipment (kg/s)
201 : DataZoneEnergyDemands::ZoneSystemSensibleDemand &energy,
202 : DataZoneEnergyDemands::ZoneSystemMoistureDemand &moisture,
203 : int const EquipPriorityNum = -1 // optional index in PrioritySimOrder for this update
204 : );
205 :
206 : void adjustSystemOutputRequired(Real64 const sensibleRatio, // sensible load adjustment
207 : Real64 const latentRatio, // latent load adjustment
208 : DataZoneEnergyDemands::ZoneSystemSensibleDemand &energy,
209 : DataZoneEnergyDemands::ZoneSystemMoistureDemand &moisture,
210 : int const equipPriorityNum // index in PrioritySimOrder
211 : );
212 :
213 : void CalcZoneMassBalance(EnergyPlusData &state, bool FirstHVACIteration);
214 :
215 : void CalcZoneInfiltrationFlows(EnergyPlusData &state,
216 : int ZoneNum, // current zone index
217 : Real64 &ZoneReturnAirMassFlowRate // zone total zone return air mass flow rate
218 : );
219 :
220 : void CalcAirFlowSimple(EnergyPlusData &state,
221 : int SysTimestepLoop = 0, // System time step index
222 : bool AdjustZoneMixingFlowFlag = false, // flags to adjust zone mxing mass flow rate
223 : bool AdjustZoneInfiltrationFlowFlag = false // flags to djust zone infiltration air flow rate
224 : );
225 :
226 : void GetStandAloneERVNodes(EnergyPlusData &state, DataHeatBalance::ZoneAirBalanceData &thisZoneAirBalance);
227 :
228 : void CalcZoneMixingFlowRateOfReceivingZone(EnergyPlusData &state, int ZoneNum, Real64 &ZoneMixingAirMassFlowRate);
229 :
230 : void CalcZoneMixingFlowRateOfSourceZone(EnergyPlusData &state, int ZoneNum);
231 :
232 : void CalcZoneLeavingConditions(EnergyPlusData &state, bool FirstHVACIteration);
233 :
234 : void UpdateZoneEquipment(EnergyPlusData &state, bool &SimAir);
235 :
236 : void CalcDOASSupCondsForSizing(EnergyPlusData &state,
237 : Real64 OutDB, // outside air temperature [C]
238 : Real64 OutHR, // outside humidity ratio [kg Water / kg Dry Air]
239 : DataSizing::DOASControl DOASControl, // dedicated outside air control strategy
240 : Real64 DOASLowTemp, // DOAS low setpoint [C]
241 : Real64 DOASHighTemp, // DOAS high setpoint [C]
242 : Real64 W90H, // humidity ratio at DOAS high setpoint temperature and 90% relative humidity [kg Water / kg Dry Air]
243 : Real64 W90L, // humidity ratio at DOAS low setpoint temperature and 90% relative humidity [kg Water / kg Dry Air]
244 : Real64 &DOASSupTemp, // DOAS supply temperature [C]
245 : Real64 &DOASSupHR // DOAS Supply Humidity ratio [kg Water / kg Dry Air]
246 : );
247 :
248 : void AutoCalcDOASControlStrategy(EnergyPlusData &state);
249 :
250 : void ReportInfiltrations(EnergyPlusData &state);
251 :
252 : void ReportZoneSizingDOASInputs(EnergyPlusData &state,
253 : std::string const &ZoneName, // the name of the zone
254 : std::string const &DOASCtrlStrategy, // DOAS control strategy
255 : Real64 DOASLowTemp, // DOAS design low setpoint temperature [C]
256 : Real64 DOASHighTemp, // DOAS design high setpoint temperature [C]
257 : bool &headerAlreadyPrinted);
258 :
259 : } // namespace ZoneEquipmentManager
260 :
261 : struct ZoneEquipmentManagerData : BaseGlobalStruct
262 : {
263 :
264 : Array1D<Real64> AvgData; // scratch array for storing averaged data -- keep on state to avoid it being recreated
265 : int NumOfTimeStepInDay = 0; // number of zone time steps in a day
266 : bool GetZoneEquipmentInputFlag = true;
267 : bool SizeZoneEquipmentOneTimeFlag = true;
268 :
269 : Array1D<ZoneEquipmentManager::SimulationOrder> PrioritySimOrder;
270 :
271 : bool InitZoneEquipmentOneTimeFlag = true;
272 : bool InitZoneEquipmentEnvrnFlag = true;
273 : bool FirstPassZoneEquipFlag = true; // indicates first pass through zone equipment, used to reset selected ZoneEqSizing variables
274 :
275 796 : void init_state([[maybe_unused]] EnergyPlusData &state) override
276 : {
277 796 : }
278 :
279 0 : void clear_state() override
280 : {
281 0 : new (this) ZoneEquipmentManagerData();
282 0 : }
283 : };
284 :
285 : } // namespace EnergyPlus
286 :
287 : #endif
|