Line data Source code
1 : // EnergyPlus, Copyright (c) 1996-2023, 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 GeneralRoutines_hh_INCLUDED
49 : #define GeneralRoutines_hh_INCLUDED
50 :
51 : // ObjexxFCL Headers
52 : #include <ObjexxFCL/Array2S.hh>
53 : #include <ObjexxFCL/Optional.hh>
54 :
55 : // EnergyPlus Headers
56 : #include <EnergyPlus/ConvectionCoefficients.hh>
57 : #include <EnergyPlus/Data/BaseData.hh>
58 : #include <EnergyPlus/DataSurfaces.hh>
59 : #include <EnergyPlus/EnergyPlus.hh>
60 : #include <EnergyPlus/Plant/Enums.hh>
61 : #include <EnergyPlus/Plant/PlantLocation.hh>
62 :
63 : namespace EnergyPlus {
64 :
65 : // Forward declarations
66 : struct EnergyPlusData;
67 :
68 : struct IntervalHalf
69 : {
70 : // Members
71 : Real64 MaxFlow;
72 : Real64 MinFlow;
73 : Real64 MaxResult;
74 : Real64 MinResult;
75 : Real64 MidFlow;
76 : Real64 MidResult;
77 : bool MaxFlowCalc;
78 : bool MinFlowCalc;
79 : bool MinFlowResult;
80 : bool NormFlowCalc;
81 :
82 : // Default Constructor
83 : IntervalHalf() = default;
84 :
85 : // Member Constructor
86 771 : IntervalHalf(Real64 const MaxFlow,
87 : Real64 const MinFlow,
88 : Real64 const MaxResult,
89 : Real64 const MinResult,
90 : Real64 const MidFlow,
91 : Real64 const MidResult,
92 : bool const MaxFlowCalc,
93 : bool const MinFlowCalc,
94 : bool const MinFlowResult,
95 : bool const NormFlowCalc)
96 771 : : MaxFlow(MaxFlow), MinFlow(MinFlow), MaxResult(MaxResult), MinResult(MinResult), MidFlow(MidFlow), MidResult(MidResult),
97 771 : MaxFlowCalc(MaxFlowCalc), MinFlowCalc(MinFlowCalc), MinFlowResult(MinFlowResult), NormFlowCalc(NormFlowCalc)
98 : {
99 771 : }
100 : };
101 :
102 : struct ZoneEquipControllerProps
103 : {
104 : // Members
105 : Real64 SetPoint; // Desired setpoint;
106 : Real64 MaxSetPoint; // The maximum setpoint; either user input or reset per time step by simulation
107 : Real64 MinSetPoint; // The minimum setpoint; either user input or reset per time step by simulation
108 : Real64 SensedValue; // The sensed control variable of any type
109 : Real64 CalculatedSetPoint; // The Calculated SetPoint or new control actuated value
110 :
111 : // Default Constructor
112 : ZoneEquipControllerProps() = default;
113 :
114 : // Member Constructor
115 771 : ZoneEquipControllerProps(Real64 const SetPoint, // Desired setpoint;
116 : Real64 const MaxSetPoint, // The maximum setpoint; either user input or reset per time step by simulation
117 : Real64 const MinSetPoint, // The minimum setpoint; either user input or reset per time step by simulation
118 : Real64 const SensedValue, // The sensed control variable of any type
119 : Real64 const CalculatedSetPoint // The Calculated SetPoint or new control actuated value
120 : )
121 771 : : SetPoint(SetPoint), MaxSetPoint(MaxSetPoint), MinSetPoint(MinSetPoint), SensedValue(SensedValue), CalculatedSetPoint(CalculatedSetPoint)
122 : {
123 771 : }
124 : };
125 :
126 : void ControlCompOutput(EnergyPlusData &state,
127 : std::string const &CompName, // the component Name
128 : std::string const &CompType, // Type of component
129 : int &CompNum, // Index of component in component array
130 : bool const FirstHVACIteration, // flag for 1st HVAV iteration in the time step
131 : Real64 const QZnReq, // zone load to be met
132 : int const ActuatedNode, // node that controls unit output
133 : Real64 const MaxFlow, // maximum water flow
134 : Real64 const MinFlow, // minimum water flow
135 : Real64 const ControlOffset, // really the tolerance
136 : int &ControlCompTypeNum, // Internal type num for CompType
137 : int &CompErrIndex, // for Recurring error call
138 : Optional_int_const TempInNode = _, // inlet node for output calculation
139 : Optional_int_const TempOutNode = _, // outlet node for output calculation
140 : Optional<Real64 const> AirMassFlow = _, // air mass flow rate
141 : Optional_int_const Action = _, // 1=reverse; 2=normal
142 : Optional_int_const EquipIndex = _, // Identifier for equipment of Outdoor Air Unit "ONLY"
143 : PlantLocation const &plantLoc = {}, // for plant components, Location
144 : Optional_int_const ControlledZoneIndex = _ // controlled zone index for the zone containing the component
145 : );
146 :
147 : bool BBConvergeCheck(int const SimCompNum, Real64 const MaxFlow, Real64 const MinFlow);
148 :
149 : void CheckSysSizing(EnergyPlusData &state,
150 : std::string const &CompType, // Component Type (e.g. Chiller:Electric)
151 : std::string const &CompName // Component Name (e.g. Big Chiller)
152 : );
153 :
154 : void CheckThisAirSystemForSizing(EnergyPlusData &state, int const AirLoopNum, bool &AirLoopWasSized);
155 :
156 : void CheckZoneSizing(EnergyPlusData &state,
157 : std::string const &CompType, // Component Type (e.g. Chiller:Electric)
158 : std::string const &CompName // Component Name (e.g. Big Chiller)
159 : );
160 :
161 : void CheckThisZoneForSizing(EnergyPlusData &state,
162 : int const ZoneNum, // zone index to be checked
163 : bool &ZoneWasSized);
164 :
165 : void ValidateComponent(EnergyPlusData &state,
166 : std::string_view CompType, // Component Type (e.g. Chiller:Electric)
167 : std::string const &CompName, // Component Name (e.g. Big Chiller)
168 : bool &IsNotOK, // .TRUE. if this component pair is invalid
169 : std::string const &CallString // Context of this pair -- for error message
170 : );
171 :
172 : void ValidateComponent(EnergyPlusData &state,
173 : std::string const &CompType, // Component Type (e.g. Chiller:Electric)
174 : std::string const &CompValType, // Component "name" field type
175 : std::string const &CompName, // Component Name (e.g. Big Chiller)
176 : bool &IsNotOK, // .TRUE. if this component pair is invalid
177 : std::string const &CallString // Context of this pair -- for error message
178 : );
179 :
180 : void CalcPassiveExteriorBaffleGap(EnergyPlusData &state,
181 : const Array1D_int &SurfPtrARR, // Array of indexes pointing to Surface structure in DataSurfaces
182 : Real64 const VentArea, // Area available for venting the gap [m2]
183 : Real64 const Cv, // Oriface coefficient for volume-based discharge, wind-driven [--]
184 : Real64 const Cd, // oriface coefficient for discharge, buoyancy-driven [--]
185 : Real64 const HdeltaNPL, // Height difference from neutral pressure level [m]
186 : Real64 const SolAbs, // solar absorptivity of baffle [--]
187 : Real64 const AbsExt, // thermal absorptance/emittance of baffle material [--]
188 : Real64 const Tilt, // Tilt of gap [Degrees]
189 : Real64 const AspRat, // aspect ratio of gap Height/gap [--]
190 : Real64 const GapThick, // Thickness of air space between baffle and underlying heat transfer surface
191 : DataSurfaces::SurfaceRoughness const Roughness, // Roughness index (1-6), see DataHeatBalance parameters
192 : Real64 const QdotSource, // Source/sink term, e.g. electricity exported from solar cell [W]
193 : Real64 &TsBaffle, // Temperature of baffle (both sides) use lagged value on input [C]
194 : Real64 &TaGap, // Temperature of air gap (assumed mixed) use lagged value on input [C]
195 : Optional<Real64> HcGapRpt = _,
196 : Optional<Real64> HrGapRpt = _,
197 : Optional<Real64> IscRpt = _,
198 : Optional<Real64> MdotVentRpt = _,
199 : Optional<Real64> VdotWindRpt = _,
200 : Optional<Real64> VdotBuoyRpt = _);
201 :
202 : //****************************************************************************
203 :
204 : void PassiveGapNusseltNumber(Real64 const AspRat, // Aspect Ratio of Gap height to gap width
205 : Real64 const Tilt, // Tilt of gap, degrees
206 : Real64 const Tso, // Temperature of gap surface closest to outside (K)
207 : Real64 const Tsi, // Temperature of gap surface closest to zone (K)
208 : Real64 const Gr, // Gap gas Grashof number
209 : Real64 &gNu // Gap gas Nusselt number
210 : );
211 :
212 : void CalcBasinHeaterPower(EnergyPlusData &state,
213 : Real64 const Capacity, // Basin heater capacity per degree C below setpoint (W/C)
214 : int const SchedulePtr, // Pointer to basin heater schedule
215 : Real64 const SetPointTemp, // setpoint temperature for basin heater operation (C)
216 : Real64 &Power // Basin heater power (W)
217 : );
218 :
219 : void TestAirPathIntegrity(EnergyPlusData &state, bool &ErrFound);
220 :
221 : void TestSupplyAirPathIntegrity(EnergyPlusData &state, bool &ErrFound);
222 :
223 : void TestReturnAirPathIntegrity(EnergyPlusData &state, bool &ErrFound, Array2S_int ValRetAPaths);
224 :
225 : void CalcComponentSensibleLatentOutput(Real64 const MassFlow, // air mass flow rate, {kg/s}
226 : Real64 const TDB2, // dry-bulb temperature at state 2 {C}
227 : Real64 const W2, // humidity ratio at state 2
228 : Real64 const TDB1, // dry-bulb temperature at at state 1 {C}
229 : Real64 const W1, // humidity ratio at state 1
230 : Real64 &SensibleOutput, // sensible output rate (state 2 -> State 1), {W}
231 : Real64 &LatentOutput, // latent output rate (state 2 -> State 1), {W}
232 : Real64 &TotalOutput // total = sensible + latent putput rate (state 2 -> State 1), {W}
233 : );
234 :
235 : void CalcZoneSensibleLatentOutput(Real64 const MassFlow, // air mass flow rate, {kg/s}
236 : Real64 const TDBEquip, // dry-bulb temperature at equipment outlet {C}
237 : Real64 const WEquip, // humidity ratio at equipment outlet
238 : Real64 const TDBZone, // dry-bulb temperature at zone air node {C}
239 : Real64 const WZone, // humidity ratio at zone air node
240 : Real64 &SensibleOutput, // sensible output rate (state 2 -> State 1), {W}
241 : Real64 &LatentOutput, // latent output rate (state 2 -> State 1), {W}
242 : Real64 &TotalOutput // total = sensible + latent putput rate (state 2 -> State 1), {W}
243 : );
244 :
245 : Real64 calcZoneSensibleOutput(Real64 const MassFlow, // air mass flow rate, {kg/s}
246 : Real64 const TDBEquip, // dry-bulb temperature at equipment outlet {C}
247 : Real64 const TDBZone, // dry-bulb temperature at zone air node {C}
248 : Real64 const WZone);
249 :
250 771 : struct GeneralRoutinesData : BaseGlobalStruct
251 : {
252 :
253 : bool MyICSEnvrnFlag = true;
254 : IntervalHalf ZoneInterHalf = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, false, false, false, false};
255 : ZoneEquipControllerProps ZoneController = {0.0, 0.0, 0.0, 0.0, 0.0};
256 :
257 0 : void clear_state() override
258 : {
259 0 : this->MyICSEnvrnFlag = true;
260 0 : }
261 : };
262 :
263 : } // namespace EnergyPlus
264 :
265 : #endif
|