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 SimAirServingZones_hh_INCLUDED
49 : #define SimAirServingZones_hh_INCLUDED
50 :
51 : // C++ Headers
52 : #include <string>
53 :
54 : // EnergyPlus Headers
55 : #include <EnergyPlus/Data/BaseData.hh>
56 : #include <EnergyPlus/DataGlobalConstants.hh>
57 : #include <EnergyPlus/DataHVACControllers.hh>
58 : #include <EnergyPlus/DataHVACSystems.hh>
59 : #include <EnergyPlus/DataZoneEquipment.hh>
60 : #include <EnergyPlus/EnergyPlus.hh>
61 :
62 : namespace EnergyPlus {
63 :
64 : // Forward declarations
65 : struct EnergyPlusData;
66 :
67 : namespace SimAirServingZones {
68 :
69 : constexpr int BeforeBranchSim(1);
70 : constexpr int AfterBranchSim(2);
71 :
72 : // CompType numerics -- for this module
73 : // component types addressed by this module
74 : enum class CompType
75 : {
76 : Invalid = -1,
77 : OAMixer_Num,
78 : Fan_Simple_CV,
79 : Fan_Simple_VAV,
80 : WaterCoil_Cooling,
81 : WaterCoil_SimpleHeat,
82 : SteamCoil_AirHeat,
83 : WaterCoil_DetailedCool,
84 : Coil_ElectricHeat,
85 : Coil_GasHeat,
86 : WaterCoil_CoolingHXAsst,
87 : Coil_DeSuperHeat,
88 : DXSystem,
89 : HeatXchngr,
90 : Desiccant,
91 : Unglazed_SolarCollector,
92 : EvapCooler,
93 : Furnace_UnitarySys_HeatOnly,
94 : Furnace_UnitarySys_HeatCool,
95 : Humidifier,
96 : Duct,
97 : UnitarySystem_BypassVAVSys,
98 : UnitarySystem_MSHeatPump,
99 : Fan_ComponentModel,
100 : DXHeatPumpSystem,
101 : CoilUserDefined,
102 : Fan_System_Object,
103 : UnitarySystemModel,
104 : ZoneVRFasAirLoopEquip,
105 : PVT_AirBased,
106 : CoilSystemWater,
107 : Num
108 : };
109 :
110 : void ManageAirLoops(EnergyPlusData &state,
111 : bool FirstHVACIteration, // TRUE if first full HVAC iteration in an HVAC timestep
112 : bool &SimAir, // TRUE means air loops must be (re)simulated
113 : bool &SimZoneEquipment // TRUE means zone equipment must be (re) simulated
114 : );
115 :
116 : void GetAirPathData(EnergyPlusData &state);
117 :
118 : void InitAirLoops(EnergyPlusData &state, bool FirstHVACIteration); // TRUE if first full HVAC iteration in an HVAC timestep
119 :
120 : void ConnectReturnNodes(EnergyPlusData &state);
121 :
122 : void SimAirLoops(EnergyPlusData &state, bool FirstHVACIteration, bool &SimZoneEquipment);
123 :
124 : void SimAirLoop(EnergyPlusData &state,
125 : bool FirstHVACIteration,
126 : int AirLoopNum,
127 : int AirLoopPass,
128 : int &AirLoopIterMax,
129 : int &AirLoopIterTot,
130 : int &AirLoopNumCalls);
131 :
132 : void SolveAirLoopControllers(
133 : EnergyPlusData &state, bool FirstHVACIteration, int AirLoopNum, bool &AirLoopConvergedFlag, int &IterMax, int &IterTot, int &NumCalls);
134 :
135 : void SolveWaterCoilController(EnergyPlusData &state,
136 : bool FirstHVACIteration,
137 : int AirLoopNum,
138 : std::string const &CompName,
139 : int &CompIndex,
140 : std::string const &ControllerName,
141 : int ControllerIndex,
142 : bool HXAssistedWaterCoil);
143 :
144 : void ReSolveAirLoopControllers(
145 : EnergyPlusData &state, bool FirstHVACIteration, int AirLoopNum, bool &AirLoopConvergedFlag, int &IterMax, int &IterTot, int &NumCalls);
146 :
147 : void SimAirLoopComponents(EnergyPlusData &state,
148 : int AirLoopNum, // Index of the air loop being currently simulated
149 : bool FirstHVACIteration // TRUE if first full HVAC iteration in an HVAC timestep
150 : );
151 :
152 : void SimAirLoopComponent(EnergyPlusData &state,
153 : std::string const &CompName, // the component Name
154 : CompType CompType_Num, // numeric equivalent for component type
155 : bool FirstHVACIteration, // TRUE if first full HVAC iteration in an HVAC timestep
156 : int AirLoopNum, // Primary air loop number
157 : int &CompIndex, // numeric pointer for CompType/CompName -- passed back from other routines
158 : HVACSystemData *CompPointer, // equipment actual pointer
159 : int airLoopNum, // index to AirloopHVAC
160 : int branchNum, // index to AirloopHVAC branch
161 : int compNum // index to AirloopHVAC branch component
162 : );
163 :
164 : void UpdateBranchConnections(EnergyPlusData &state,
165 : int AirLoopNum, // primary air system number
166 : int BranchNum, // branch reference number
167 : int Update // 1=BeforeBranchSim; 2=AfterBranchSim
168 : );
169 :
170 : void ResolveSysFlow(EnergyPlusData &state,
171 : int SysNum, // the primary air system number
172 : bool &SysReSim // Set to TRUE if mass balance fails and re-simulation is needed
173 : );
174 :
175 : void SizeAirLoops(EnergyPlusData &state);
176 :
177 : void SizeAirLoopBranches(EnergyPlusData &state, int AirLoopNum, int BranchNum);
178 :
179 : void SetUpSysSizingArrays(EnergyPlusData &state);
180 :
181 : void SizeSysOutdoorAir(EnergyPlusData &state);
182 :
183 : void UpdateSysSizing(EnergyPlusData &state, Constant::CallIndicator CallIndicator);
184 :
185 : void UpdateSysSizingForScalableInputs(EnergyPlusData &state, int AirLoopNum);
186 :
187 : Real64 GetHeatingSATempForSizing(EnergyPlusData &state, int IndexAirLoop);
188 :
189 : Real64 GetHeatingSATempHumRatForSizing(EnergyPlusData &state, int IndexAirLoop);
190 :
191 : void LimitZoneVentEff(EnergyPlusData &state,
192 : Real64 Xs, // ratio of uncorrected system outdoor air flow rate to the design system supply flow rate
193 : Real64 Voz, // corrected (divided by distribution efficiency) zone outside air flow rate [m3/s]
194 : int CtrlZoneNum, // controlled zone number
195 : Real64 &SystemCoolingEv // system ventilation efficiency
196 : );
197 :
198 : void CheckWaterCoilIsOnAirLoop(EnergyPlusData &state,
199 : SimAirServingZones::CompType CompTypeNum,
200 : std::string const &CompType,
201 : std::string const &CompName,
202 : bool &WaterCoilOnAirLoop);
203 :
204 : bool CheckWaterCoilOnPrimaryAirLoopBranch(EnergyPlusData &state, SimAirServingZones::CompType CompTypeNum, std::string const &CompName);
205 :
206 : bool CheckWaterCoilOnOASystem(EnergyPlusData &state, SimAirServingZones::CompType CompTypeNum, std::string const &CompName);
207 :
208 : bool CheckWaterCoilSystemOnAirLoopOrOASystem(EnergyPlusData &state, SimAirServingZones::CompType CoilTypeNum, std::string const &CompName);
209 :
210 : } // namespace SimAirServingZones
211 :
212 : struct SimAirServingZonesData : BaseGlobalStruct
213 : {
214 :
215 : bool GetAirLoopInputFlag = true; // Flag set to make sure you get input once
216 : int NumOfTimeStepInDay = 0; // number of zone time steps in a day
217 : bool InitAirLoopsOneTimeFlag = true;
218 : int TestUniqueNodesNum = 0;
219 : bool SizeAirLoopsOneTimeFlag = true;
220 : bool InitAirLoopsBranchSizingFlag = true;
221 : bool OutputSetupFlag = false;
222 : bool MyEnvrnFlag = true;
223 :
224 : Array1D<Real64> EvBySysCool; // saved value of SysCoolingEv used in 62.1 tabular report
225 : Array1D<Real64> EvBySysHeat; // saved value of SysHeatingEv used in 62.1 tabular report
226 : Real64 Ep = 1.0; // zone primary air fraction
227 : Real64 Er = 0.0; // zone secondary recirculation fraction
228 : Real64 Fa = 1.0; // temporary variable used in multi-path VRP calc
229 : Real64 Fb = 1.0; // temporary variable used in multi-path VRP calc
230 : Real64 Fc = 1.0; // temporary variable used in multi-path VRP calc
231 : Real64 Xs = 1.0; // uncorrected system outdoor air fraction
232 : Real64 MinHeatingEvz = 1.0; // minimum zone ventilation efficiency for heating (to be used as system efficiency)
233 : Real64 MinCoolingEvz = 1.0; // minimum zone ventilation efficiency for cooling (to be used as system efficiency)
234 : Real64 ZoneOAFrac = 0.0; // zone OA fraction
235 : Real64 ZoneEz = 1.0; // zone air distribution effectiveness
236 : Real64 Vou = 0.0; // Uncorrected outdoor air intake for all zones per ASHRAE std 62.1
237 : Real64 Vot = 0.0; // Required outdoor air intake at primary AHU per ASHRAE std 62.1
238 :
239 : int TUInNode = 0; // inlet node number of a terminal unit
240 : Real64 SumZoneDesFlow = 0.0; // sum of the zone design air mass flow rates for zones served by a system
241 : Real64 OAReliefDiff = 0.0; // local for massflow change across OA system, kg/s
242 : Real64 MassFlowSetToler;
243 : int salIterMax = 0; // Maximum of iteration counters across all air loops
244 : int salIterTot = 0; // Aggregated number of iterations across all air loops
245 : int NumCallsTot = 0; // Aggregated number fo times SimAirLoopComponents() has been invoked across all air loops
246 : int IterMaxSAL2 = 0; // Maximum number of iterations performed by each controller on this air loop
247 : int IterTotSAL2 = 0; // Aggregated number of iterations performed by each controller on this air loop
248 : int NumCallsSAL2 = 0; // Number of times SimAirLoopComponents() has been invoked per air loop for either Solve or ReSolve operations
249 : // TRUE when primary air system & controllers simulation has converged;
250 : bool AirLoopConvergedFlagSAL = false;
251 : // TRUE when speculative warm restart is allowed; FALSE otherwise.
252 : bool DoWarmRestartFlagSAL = false;
253 : // If Status<0, no speculative warm restart attempted.
254 : // If Status==0, warm restart failed.
255 : // If Status>0, warm restart succeeded.
256 : DataHVACControllers::ControllerWarmRestart WarmRestartStatusSAL = DataHVACControllers::ControllerWarmRestart::None;
257 : int IterSALC = 0; // Iteration counter
258 : int ErrCountSALC = 0; // Number of times that the maximum iterations was exceeded
259 : int MaxErrCountSALC = 0; // Number of times that the maximum iterations was exceeded
260 : // A character string equivalent of ErrCount
261 : bool BypassOAControllerSALC; // logical to tell ManageControllers to sim or not sim controller in OA System (don't sim here)
262 : // Iteration counter
263 : int IterSWCC = 0;
264 : // Number of times that the maximum iterations was exceeded
265 : int ErrCountSWCC = 0;
266 : // Number of times that the maximum iterations was exceeded
267 : int MaxErrCountSWCC = 0;
268 : int AirLoopPassSWCC;
269 : bool BypassOAControllerSWCC;
270 : bool BypassOAControllerRSALC; // logical to bypass HVAC controller calcs
271 : Real64 EpSSOA = 1.0; // zone primary air fraction
272 :
273 : // Last saved HVAC time stamp at beginning of step in seconds.
274 : // Used to control when to reset the statistic counters for each new HVAC step.
275 : Real64 SavedPreviousHVACTime = 0.0;
276 :
277 : // Placeholder for environment name used in error reporting
278 : std::string ErrEnvironmentName;
279 : std::string ErrEnvironmentNameSolveWaterCoilController;
280 :
281 796 : void init_state([[maybe_unused]] EnergyPlusData &state) override
282 : {
283 796 : }
284 :
285 0 : void clear_state() override
286 : {
287 0 : this->GetAirLoopInputFlag = true;
288 0 : this->NumOfTimeStepInDay = 0;
289 0 : this->InitAirLoopsOneTimeFlag = true;
290 0 : this->TestUniqueNodesNum = 0;
291 0 : this->SizeAirLoopsOneTimeFlag = true;
292 0 : this->InitAirLoopsBranchSizingFlag = true;
293 0 : this->OutputSetupFlag = false;
294 0 : this->MyEnvrnFlag = true;
295 :
296 0 : this->EvBySysCool.clear();
297 0 : this->EvBySysHeat.clear();
298 0 : this->Ep = 1.0;
299 0 : this->Er = 0.0;
300 0 : this->Fa = 1.0;
301 0 : this->Fb = 1.0;
302 0 : this->Fc = 1.0;
303 0 : this->Xs = 1.0;
304 0 : this->MinHeatingEvz = 1.0;
305 0 : this->MinCoolingEvz = 1.0;
306 0 : this->ZoneOAFrac = 0.0;
307 0 : this->ZoneEz = 1.0;
308 0 : this->Vou = 0.0;
309 0 : this->Vot = 0.0;
310 :
311 0 : this->TUInNode = 0; // inlet node number of a terminal unit
312 0 : this->SumZoneDesFlow = 0.0; // sum of the zone design air mass flow rates for zones served by a system
313 0 : this->OAReliefDiff = 0.0; // local for massflow change across OA system, kg/s
314 0 : this->salIterMax = 0; // Maximum of iteration counters across all air loops
315 0 : this->salIterTot = 0; // Aggregated number of iterations across all air loops
316 0 : this->NumCallsTot = 0; // Aggregated number fo times SimAirLoopComponents() has been invoked across all air loops
317 0 : this->IterMaxSAL2 = 0; // Maximum number of iterations performed by each controller on this air loop
318 0 : this->IterTotSAL2 = 0; // Aggregated number of iterations performed by each controller on this air loop
319 0 : this->NumCallsSAL2 = 0; // Number of times SimAirLoopComponents() has been invoked per air loop for either Solve or ReSolve operations
320 0 : this->AirLoopConvergedFlagSAL = false;
321 0 : this->DoWarmRestartFlagSAL = false;
322 0 : this->WarmRestartStatusSAL = DataHVACControllers::ControllerWarmRestart::None;
323 0 : this->IterSALC = 0; // Iteration counter
324 0 : this->ErrCountSALC = 0; // Number of times that the maximum iterations was exceeded
325 0 : this->MaxErrCountSALC = 0; // Number of times that the maximum iterations was exceeded
326 0 : this->IterSWCC = 0;
327 0 : this->ErrCountSWCC = 0;
328 0 : this->MaxErrCountSWCC = 0;
329 0 : this->EpSSOA = 1.0; // zone primary air fraction
330 0 : this->SavedPreviousHVACTime = 0.0;
331 0 : this->ErrEnvironmentName.clear();
332 0 : this->ErrEnvironmentNameSolveWaterCoilController.clear();
333 0 : }
334 : };
335 :
336 : } // namespace EnergyPlus
337 :
338 : #endif
|