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 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/Data/BaseData.hh>
57 : #include <EnergyPlus/EnergyPlus.hh>
58 : #include <EnergyPlus/Plant/Enums.hh>
59 : #include <EnergyPlus/Plant/PlantLocation.hh>
60 :
61 : namespace EnergyPlus {
62 :
63 : // Forward declarations
64 : struct EnergyPlusData;
65 :
66 : struct IntervalHalf
67 : {
68 : // Members
69 : Real64 MaxFlow;
70 : Real64 MinFlow;
71 : Real64 MaxResult;
72 : Real64 MinResult;
73 : Real64 MidFlow;
74 : Real64 MidResult;
75 : bool MaxFlowCalc;
76 : bool MinFlowCalc;
77 : bool MinFlowResult;
78 : bool NormFlowCalc;
79 :
80 : // Default Constructor
81 : IntervalHalf() = default;
82 :
83 : // Member Constructor
84 796 : IntervalHalf(Real64 const MaxFlow,
85 : Real64 const MinFlow,
86 : Real64 const MaxResult,
87 : Real64 const MinResult,
88 : Real64 const MidFlow,
89 : Real64 const MidResult,
90 : bool const MaxFlowCalc,
91 : bool const MinFlowCalc,
92 : bool const MinFlowResult,
93 : bool const NormFlowCalc)
94 796 : : MaxFlow(MaxFlow), MinFlow(MinFlow), MaxResult(MaxResult), MinResult(MinResult), MidFlow(MidFlow), MidResult(MidResult),
95 796 : MaxFlowCalc(MaxFlowCalc), MinFlowCalc(MinFlowCalc), MinFlowResult(MinFlowResult), NormFlowCalc(NormFlowCalc)
96 : {
97 796 : }
98 : };
99 :
100 : struct ZoneEquipControllerProps
101 : {
102 : // Members
103 : Real64 SetPoint; // Desired setpoint;
104 : Real64 MaxSetPoint; // The maximum setpoint; either user input or reset per time step by simulation
105 : Real64 MinSetPoint; // The minimum setpoint; either user input or reset per time step by simulation
106 : Real64 SensedValue; // The sensed control variable of any type
107 : Real64 CalculatedSetPoint; // The Calculated SetPoint or new control actuated value
108 :
109 : // Default Constructor
110 : ZoneEquipControllerProps() = default;
111 :
112 : // Member Constructor
113 796 : ZoneEquipControllerProps(Real64 const SetPoint, // Desired setpoint;
114 : Real64 const MaxSetPoint, // The maximum setpoint; either user input or reset per time step by simulation
115 : Real64 const MinSetPoint, // The minimum setpoint; either user input or reset per time step by simulation
116 : Real64 const SensedValue, // The sensed control variable of any type
117 : Real64 const CalculatedSetPoint // The Calculated SetPoint or new control actuated value
118 : )
119 796 : : SetPoint(SetPoint), MaxSetPoint(MaxSetPoint), MinSetPoint(MinSetPoint), SensedValue(SensedValue), CalculatedSetPoint(CalculatedSetPoint)
120 : {
121 796 : }
122 : };
123 :
124 : void ControlCompOutput(EnergyPlusData &state,
125 : std::string const &CompName, // the component Name
126 : std::string const &CompType, // Type of component
127 : int &CompNum, // Index of component in component array
128 : bool const FirstHVACIteration, // flag for 1st HVAV iteration in the time step
129 : Real64 const QZnReq, // zone load to be met
130 : int const ActuatedNode, // node that controls unit output
131 : Real64 const MaxFlow, // maximum water flow
132 : Real64 const MinFlow, // minimum water flow
133 : Real64 const ControlOffset, // really the tolerance
134 : int &ControlCompTypeNum, // Internal type num for CompType
135 : int &CompErrIndex, // for Recurring error call
136 : ObjexxFCL::Optional_int_const TempInNode = _, // inlet node for output calculation
137 : ObjexxFCL::Optional_int_const TempOutNode = _, // outlet node for output calculation
138 : ObjexxFCL::Optional<Real64 const> AirMassFlow = _, // air mass flow rate
139 : ObjexxFCL::Optional_int_const Action = _, // 1=reverse; 2=normal
140 : ObjexxFCL::Optional_int_const EquipIndex = _, // Identifier for equipment of Outdoor Air Unit "ONLY"
141 : PlantLocation const &plantLoc = {}, // for plant components, Location
142 : ObjexxFCL::Optional_int_const ControlledZoneIndex = _ // controlled zone index for the zone containing the component
143 : );
144 :
145 : bool BBConvergeCheck(int const SimCompNum, Real64 const MaxFlow, Real64 const MinFlow);
146 :
147 : void CheckSysSizing(EnergyPlusData &state,
148 : std::string_view const CompType, // Component Type (e.g. Chiller:Electric)
149 : std::string const &CompName // Component Name (e.g. Big Chiller)
150 : );
151 :
152 : void CheckThisAirSystemForSizing(EnergyPlusData &state, int const AirLoopNum, bool &AirLoopWasSized);
153 :
154 : void CheckZoneSizing(EnergyPlusData &state,
155 : std::string_view CompType, // Component Type (e.g. Chiller:Electric)
156 : std::string_view CompName // Component Name (e.g. Big Chiller)
157 : );
158 :
159 : void CheckThisZoneForSizing(EnergyPlusData &state,
160 : int const ZoneNum, // zone index to be checked
161 : bool &ZoneWasSized);
162 :
163 : void ValidateComponent(EnergyPlusData &state,
164 : std::string_view CompType, // Component Type (e.g. Chiller:Electric)
165 : std::string const &CompName, // Component Name (e.g. Big Chiller)
166 : bool &IsNotOK, // .TRUE. if this component pair is invalid
167 : std::string_view CallString // Context of this pair -- for error message
168 : );
169 :
170 : void ValidateComponent(EnergyPlusData &state,
171 : std::string_view CompType, // Component Type (e.g. Chiller:Electric)
172 : std::string const &CompValType, // Component "name" field type
173 : std::string const &CompName, // Component Name (e.g. Big Chiller)
174 : bool &IsNotOK, // .TRUE. if this component pair is invalid
175 : std::string_view CallString // Context of this pair -- for error message
176 : );
177 :
178 : void CalcBasinHeaterPower(EnergyPlusData &state,
179 : Real64 const Capacity, // Basin heater capacity per degree C below setpoint (W/C)
180 : int const SchedulePtr, // Pointer to basin heater schedule
181 : Real64 const SetPointTemp, // setpoint temperature for basin heater operation (C)
182 : Real64 &Power // Basin heater power (W)
183 : );
184 :
185 : void TestAirPathIntegrity(EnergyPlusData &state, bool &ErrFound);
186 :
187 : void TestSupplyAirPathIntegrity(EnergyPlusData &state, bool &ErrFound);
188 :
189 : void TestReturnAirPathIntegrity(EnergyPlusData &state, bool &ErrFound, Array2S_int ValRetAPaths);
190 :
191 : void CalcComponentSensibleLatentOutput(Real64 const MassFlow, // air mass flow rate, {kg/s}
192 : Real64 const TDB2, // dry-bulb temperature at state 2 {C}
193 : Real64 const W2, // humidity ratio at state 2
194 : Real64 const TDB1, // dry-bulb temperature at at state 1 {C}
195 : Real64 const W1, // humidity ratio at state 1
196 : Real64 &SensibleOutput, // sensible output rate (state 2 -> State 1), {W}
197 : Real64 &LatentOutput, // latent output rate (state 2 -> State 1), {W}
198 : Real64 &TotalOutput // total = sensible + latent putput rate (state 2 -> State 1), {W}
199 : );
200 :
201 : void CalcZoneSensibleLatentOutput(Real64 const MassFlow, // air mass flow rate, {kg/s}
202 : Real64 const TDBEquip, // dry-bulb temperature at equipment outlet {C}
203 : Real64 const WEquip, // humidity ratio at equipment outlet
204 : Real64 const TDBZone, // dry-bulb temperature at zone air node {C}
205 : Real64 const WZone, // humidity ratio at zone air node
206 : Real64 &SensibleOutput, // sensible output rate (state 2 -> State 1), {W}
207 : Real64 &LatentOutput, // latent output rate (state 2 -> State 1), {W}
208 : Real64 &TotalOutput // total = sensible + latent putput rate (state 2 -> State 1), {W}
209 : );
210 :
211 : Real64 calcZoneSensibleOutput(Real64 const MassFlow, // air mass flow rate, {kg/s}
212 : Real64 const TDBEquip, // dry-bulb temperature at equipment outlet {C}
213 : Real64 const TDBZone, // dry-bulb temperature at zone air node {C}
214 : Real64 const WZone);
215 :
216 : struct GeneralRoutinesData : BaseGlobalStruct
217 : {
218 :
219 : bool MyICSEnvrnFlag = true;
220 : IntervalHalf ZoneInterHalf = {0.0, 0.0, 0.0, 0.0, 0.0, 0.0, false, false, false, false};
221 : ZoneEquipControllerProps ZoneController = {0.0, 0.0, 0.0, 0.0, 0.0};
222 :
223 796 : void init_state([[maybe_unused]] EnergyPlusData &state) override
224 : {
225 796 : }
226 :
227 0 : void clear_state() override
228 : {
229 0 : this->MyICSEnvrnFlag = true;
230 0 : }
231 : };
232 :
233 : } // namespace EnergyPlus
234 :
235 : #endif
|