Line data Source code
1 : // EnergyPlus, Copyright (c) 1996-2025, 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 InternalHeatGains_hh_INCLUDED
49 : #define InternalHeatGains_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/EnergyPlus.hh>
58 : #include <EnergyPlus/OutputReportTabular.hh>
59 : #include <GSL/span.h>
60 :
61 : namespace EnergyPlus {
62 :
63 : // Forward declarations
64 : struct EnergyPlusData;
65 :
66 : namespace InternalHeatGains {
67 :
68 : struct GlobalInternalGainMiscObject
69 : {
70 : // Members
71 : std::string Name;
72 : bool ZoneListActive = false;
73 : int spaceOrSpaceListPtr = 0;
74 : int numOfSpaces = 0;
75 : int spaceStartPtr = 0;
76 : bool spaceListActive = false;
77 : EPVector<int> spaceNums; // Indexes to spaces associated with this input object
78 : EPVector<std::string> names; // Names for each instance created from this input object
79 : };
80 :
81 : void ManageInternalHeatGains(EnergyPlusData &state,
82 : ObjexxFCL::Optional_bool_const InitOnly = _); // when true, just calls the get input, if appropriate and returns.
83 :
84 : void GetInternalHeatGainsInput(EnergyPlusData &state);
85 :
86 : void setupIHGZonesAndSpaces(EnergyPlusData &state,
87 : const std::string &objectType,
88 : EPVector<InternalHeatGains::GlobalInternalGainMiscObject> &inputObjects,
89 : int &numInputObjects,
90 : int &numGainInstances,
91 : bool &errors,
92 : const bool zoneListNotAllowed = false);
93 :
94 : void setupIHGOutputs(EnergyPlusData &state);
95 :
96 : void InitInternalHeatGains(EnergyPlusData &state);
97 :
98 : void CheckReturnAirHeatGain(EnergyPlusData &state);
99 :
100 : void CalcZoneITEq(EnergyPlusData &state);
101 :
102 : void ReportInternalHeatGains(EnergyPlusData &state);
103 :
104 : Real64 GetDesignLightingLevelForZone(EnergyPlusData &state, int const WhichZone); // name of zone
105 :
106 : bool CheckThermalComfortSchedules(bool const WorkEffSch, // Blank work efficiency schedule = true
107 : bool const CloInsSch, // Blank clothing insulation schedule = true
108 : bool const AirVeloSch); // Blank air velocity schedule = true
109 :
110 : void CheckLightsReplaceableMinMaxForZone(EnergyPlusData &state, int const WhichZone); // Zone Number
111 :
112 : void UpdateInternalGainValues(EnergyPlusData &state, bool const SuppressRadiationUpdate = false, bool const SumLatentGains = false);
113 :
114 : Real64 zoneSumAllInternalConvectionGains(EnergyPlusData &state,
115 : int const zoneNum); // zone index pointer to sum gains for
116 :
117 : Real64 spaceSumAllInternalConvectionGains(EnergyPlusData &state,
118 : int const spaceNum); // space index pointer to sum gains for
119 :
120 : Real64 SumAllInternalConvectionGainsExceptPeople(EnergyPlusData &state,
121 : int const ZoneNum); // zone index pointer for which zone to sum gains for
122 :
123 : Real64 SumInternalConvectionGainsByTypes(
124 : EnergyPlusData &state,
125 : int const ZoneNum, // zone index pointer for which zone to sum gains for
126 : gsl::span<const DataHeatBalance::IntGainType> GainTypeARR, // variable length 1-d array of enum valued gain types
127 : int const spaceIndex = 0); // space index pointer, sum gains only for this space
128 :
129 : int GetInternalGainDeviceIndex(EnergyPlusData &state,
130 : int const ZoneNum, // zone index pointer for which zone to sum gains for
131 : DataHeatBalance::IntGainType const IntGainType, // zone internal gain type enum
132 : std::string_view const IntGainName); // Internal gain name
133 :
134 : Real64 SumInternalConvectionGainsByIndices(
135 : EnergyPlusData &state,
136 : int const NumGains, // number of device gains to sum
137 : const Array1D_int &DeviceSpaceARR, // variable length 1-d array of integer space index pointers to include in summation
138 : const Array1D_int &DeviceIndexARR, // variable length 1-d array of integer device index pointers to include in summation
139 : const Array1D<Real64> &FractionARR // array of fractional multipliers to apply to devices
140 : );
141 :
142 : Real64 SumInternalLatentGainsByIndices(
143 : EnergyPlusData &state,
144 : int const NumGains, // number of device gains to sum
145 : const Array1D_int &DeviceSpaceARR, // variable length 1-d array of integer space index pointers to include in summation
146 : const Array1D_int &DeviceIndexARR, // variable length 1-d array of integer device index pointers to include in summation
147 : const Array1D<Real64> &FractionARR // array of fractional multipliers to apply to devices
148 : );
149 :
150 : Real64 SumReturnAirConvectionGainsByIndices(
151 : EnergyPlusData &state,
152 : int const NumGains, // number of device gains to sum
153 : const Array1D_int &DeviceSpaceARR, // variable length 1-d array of integer space index pointers to include in summation
154 : const Array1D_int &DeviceIndexARR, // variable length 1-d array of integer device index pointers to include in summation
155 : const Array1D<Real64> &FractionARR // array of fractional multipliers to apply to devices
156 : );
157 :
158 : Real64 zoneSumAllReturnAirConvectionGains(EnergyPlusData &state,
159 : int const zoneNum, // zone index pointer to sum gains for
160 : int const returnNodeNum // return air node number
161 : );
162 :
163 : Real64 spaceSumAllReturnAirConvectionGains(EnergyPlusData &state,
164 : int const spaceNum, // space index pointer to sum gains for
165 : int const returnNodeNum // return air node number
166 : );
167 :
168 : Real64 SumReturnAirConvectionGainsByTypes(
169 : EnergyPlusData &state,
170 : int const ZoneNum, // zone index pointer for which zone to sum gains for
171 : gsl::span<const DataHeatBalance::IntGainType> GainTypeARR, // variable length 1-d array of enum valued gain types
172 : int const spaceIndex = 0); // space index pointer, sum gains only for this space
173 :
174 : Real64 SumAllSpaceInternalRadiationGains(EnergyPlusData &state,
175 : int const SpaceNum // space index pointer for which space to sum gains for
176 : );
177 :
178 : Real64
179 : SumInternalRadiationGainsByTypes(EnergyPlusData &state,
180 : int const ZoneNum, // zone index pointer for which zone to sum gains for
181 : gsl::span<const DataHeatBalance::IntGainType> GainTypeARR, // variable length 1-d array of enum valued gain types
182 : int const spaceIndex = 0); // space index pointer, sum gains only for this space
183 :
184 : Real64 SumEnclosureInternalRadiationGainsByTypes(
185 : EnergyPlusData &state,
186 : int const enclosureNum, // enclosure to sum gains for
187 : gsl::span<const DataHeatBalance::IntGainType> GainTypeARR); // variable length 1-d array of enum valued gain types
188 :
189 : void SumAllInternalLatentGains(EnergyPlusData &state,
190 : int const ZoneNum // zone index pointer for which zone to sum gains for
191 : );
192 :
193 : // Added for hybrid model -- calculate the latent gain from all sources except for people
194 : void SumAllInternalLatentGainsExceptPeople(EnergyPlusData &state,
195 : int const ZoneNum // zone index pointer for which zone to sum gains for
196 : );
197 :
198 : Real64
199 : SumInternalLatentGainsByTypes(EnergyPlusData &state,
200 : int const ZoneNum, // zone index pointer for which zone to sum gains for
201 : gsl::span<const DataHeatBalance::IntGainType> GainTypeARR, // variable length 1-d array of enum valued gain types
202 : int const spaceIndex = 0); // space index pointer, sum gains only for this space
203 :
204 : Real64 SumAllReturnAirLatentGains(EnergyPlusData &state,
205 : int const ZoneNum, // zone index pointer for which zone to sum gains for
206 : int const ReturnNodeNum // return air node number
207 : );
208 :
209 : Real64 SumAllInternalCO2Gains(EnergyPlusData &state,
210 : int const ZoneNum // zone index pointer for which zone to sum gains for
211 : );
212 :
213 : // Added for hybrid model -- Overload function for calculating CO2 gains except people
214 : Real64 SumAllInternalCO2GainsExceptPeople(EnergyPlusData &state,
215 : int const ZoneNum // zone index pointer for which zone to sum gains for
216 : );
217 :
218 : Real64
219 : SumInternalCO2GainsByTypes(EnergyPlusData &state,
220 : int const ZoneNum, // zone index pointer for which zone to sum gains for
221 : gsl::span<const DataHeatBalance::IntGainType> GainTypeARR // variable length 1-d array of integer valued gain types
222 : );
223 :
224 : Real64 SumAllInternalGenericContamGains(EnergyPlusData &state,
225 : int const ZoneNum // zone index pointer for which zone to sum gains for
226 : );
227 :
228 : void GatherComponentLoadsIntGain(EnergyPlusData &state);
229 :
230 : void gatherCompLoadIntGain2(EnergyPlusData &state,
231 : OutputReportTabular::compLoadsSpaceZone &szCompLoadDayTS,
232 : int const zoneNum,
233 : int const spaceNum = 0);
234 :
235 : } // namespace InternalHeatGains
236 :
237 : struct InternalHeatGainsData : BaseGlobalStruct
238 : {
239 :
240 : bool GetInternalHeatGainsInputFlag = true; // Controls the GET routine calling (limited to first time)
241 : bool ErrorsFound = false; // if errors were found in the input
242 :
243 : // Declared here because they are needed later for the demand manager, other types of internal gain inputs are local
244 : EPVector<InternalHeatGains::GlobalInternalGainMiscObject> lightsObjects;
245 : EPVector<InternalHeatGains::GlobalInternalGainMiscObject> zoneElectricObjects;
246 :
247 2126 : void init_constant_state([[maybe_unused]] EnergyPlusData &state) override
248 : {
249 2126 : }
250 :
251 1152 : void init_state([[maybe_unused]] EnergyPlusData &state) override
252 : {
253 1152 : }
254 :
255 2100 : void clear_state() override
256 : {
257 2100 : this->GetInternalHeatGainsInputFlag = true;
258 2100 : this->ErrorsFound = false;
259 2100 : }
260 : };
261 :
262 : } // namespace EnergyPlus
263 :
264 : #endif
|