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