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 Base_hh_INCLUDED
49 : #define Base_hh_INCLUDED
50 :
51 : // EnergyPlus headers
52 : #include <EnergyPlus/AirLoopHVACDOAS.hh>
53 : #include <EnergyPlus/Data/BaseData.hh>
54 : #include <EnergyPlus/DataAirLoop.hh>
55 : #include <EnergyPlus/DataAirSystems.hh>
56 : #include <EnergyPlus/DataHVACGlobals.hh>
57 : #include <EnergyPlus/DataSizing.hh>
58 : #include <EnergyPlus/ReportCoilSelection.hh>
59 : #include <EnergyPlus/api/TypeDefs.h>
60 :
61 : namespace EnergyPlus {
62 :
63 : enum class AutoSizingType
64 : {
65 : // align with DataHVACGlobals so scalable sizing strings can be applied
66 : // this will not be necessary when scalable sizing is moved to BaseSizerWithScalableInputs
67 : Invalid = -1,
68 : CoolingAirFlowSizing = 1,
69 : CoolingWaterflowSizing = 2,
70 : HeatingWaterflowSizing = 3,
71 : CoolingWaterDesAirInletTempSizing = 4,
72 : CoolingWaterDesAirInletHumRatSizing = 5,
73 : CoolingWaterDesWaterInletTempSizing = 6,
74 : CoolingWaterDesAirOutletTempSizing = 7,
75 : CoolingWaterDesAirOutletHumRatSizing = 8,
76 : CoolingWaterNumofTubesPerRowSizing = 9,
77 : HeatingWaterDesAirInletTempSizing = 10,
78 : HeatingWaterDesAirInletHumRatSizing = 11,
79 : HeatingWaterDesCoilLoadUsedForUASizing = 12,
80 : HeatingWaterDesCoilWaterVolFlowUsedForUASizing = 13,
81 : HeatingAirFlowSizing = 14,
82 : HeatingAirflowUASizing = 15,
83 : SystemAirFlowSizing = 16,
84 : CoolingCapacitySizing = 17,
85 : HeatingCapacitySizing = 18,
86 : WaterHeatingCapacitySizing = 19,
87 : WaterHeatingCoilUASizing = 20,
88 : SystemCapacitySizing = 21, // not used
89 : CoolingSHRSizing = 22,
90 : HeatingDefrostSizing = 23, // not used
91 : MaxHeaterOutletTempSizing = 24,
92 : AutoCalculateSizing = 25,
93 : ZoneCoolingLoadSizing = 26,
94 : ZoneHeatingLoadSizing = 27,
95 : MinSATempCoolingSizing = 28, // not used
96 : MaxSATempHeatingSizing = 29, // not used
97 : ASHRAEMinSATCoolingSizing = 30,
98 : ASHRAEMaxSATHeatingSizing = 31,
99 : HeatingCoilDesAirInletTempSizing = 32,
100 : HeatingCoilDesAirOutletTempSizing = 33,
101 : HeatingCoilDesAirInletHumRatSizing = 34,
102 : DesiccantDehumidifierBFPerfDataFaceVelocitySizing = 35,
103 : Num
104 : };
105 :
106 : enum class AutoSizingResultType
107 : {
108 : Invalid = -1,
109 : NoError, // no errors found
110 : ErrorType1, // sizing error
111 : ErrorType2, // uninitialized sizing type
112 : Num
113 : };
114 :
115 77366 : struct BaseSizer
116 : {
117 :
118 : Real64 stdRhoAir = 0.0;
119 :
120 : int zoneAirFlowSizMethod = 0;
121 : bool dataScalableSizingON = false;
122 : bool dataScalableCapSizingON = false;
123 : bool isCoilReportObject = false; // provides access to coil reporting
124 : bool isFanReportObject = false; // provides access to fan reporting
125 : bool initialized = false; // indicates initializeWithinEP was called
126 : AutoSizingResultType errorType = AutoSizingResultType::NoError;
127 : AutoSizingType sizingType = AutoSizingType::Invalid;
128 : std::string sizingString;
129 : std::string sizingStringScalable;
130 : bool overrideSizeString = true;
131 : Real64 originalValue = 0.0;
132 : Real64 autoSizedValue = 0.0;
133 : bool wasAutoSized = false;
134 : bool hardSizeNoDesignRun = false;
135 : bool sizingDesRunThisAirSys = false;
136 : bool sizingDesRunThisZone = false;
137 : bool sizingDesValueFromParent = false;
138 : bool airLoopSysFlag = false;
139 : bool oaSysFlag = false;
140 : int coilType_Num = 0;
141 : std::string compType;
142 : std::string compName;
143 : bool isEpJSON = false;
144 :
145 : bool sysSizingRunDone = false;
146 : bool zoneSizingRunDone = false;
147 : int curSysNum = 0;
148 : int curOASysNum = 0;
149 : int curZoneEqNum = 0;
150 : DataHVACGlobals::AirDuctType curDuctType = DataHVACGlobals::AirDuctType::Invalid;
151 : int curTermUnitSizingNum = 0; // index in zone equipment vector - for single duct, IU, and PIU
152 : int numPrimaryAirSys = 0;
153 : int numSysSizInput = 0;
154 : bool doSystemSizing = false;
155 : int numZoneSizingInput = 0;
156 : bool doZoneSizing = false;
157 : bool autoCalculate = false; // indicator that AutoCalculate is used
158 :
159 : // terminal units
160 : bool termUnitSingDuct = false; // single duct terminal unit
161 : bool termUnitPIU = false; // powered induction unit
162 : bool termUnitIU = false; // induction terminal unit
163 : bool zoneEqFanCoil = false; // fan coil zone equipment
164 : bool otherEqType = false; // this covers the ELSE type switch
165 : bool zoneEqUnitHeater = false; // unit heater zone equipment
166 : bool zoneEqUnitVent = false; // unit ventilator zone equipment
167 : bool zoneEqVentedSlab = false; // ventilated slab zone equipment
168 :
169 : // global sizing data
170 : Real64 minOA = 0.0;
171 :
172 : // global Data* sizing constants
173 : bool dataEMSOverrideON = false;
174 : Real64 dataEMSOverride = 0.0;
175 : bool dataAutosizable = false;
176 : // HeatingWaterflowSizer
177 : Real64 dataConstantUsedForSizing = 0.0;
178 : Real64 dataFractionUsedForSizing = 0.0;
179 : bool dataDXCoolsLowSpeedsAutozize = false;
180 :
181 : // HeatingWaterDesCoilWaterVolFlowUsedForUASizer
182 : int dataPltSizHeatNum = 0;
183 : // HeatingWaterDesCoilWaterVolFlowUsedForUASizer, HeaterWaterflowSizing
184 : int dataWaterLoopNum = 0;
185 : // CoolingWaterflowSizing, CoolingWaterDesAirInletTempSizer
186 : int dataFanIndex = -1;
187 : int dataFanEnumType = -1;
188 : // CoolingWaterflowSizing
189 : Real64 dataWaterCoilSizCoolDeltaT = 0.0;
190 : // HeaterWaterflowSizing
191 : Real64 dataWaterCoilSizHeatDeltaT = 0.0;
192 : Real64 dataCapacityUsedForSizing = 0.0;
193 :
194 : // CoolingWaterDesWaterInletTempSizer, CoolingWaterNumofTubesPerRowSizer
195 : int dataPltSizCoolNum = 0;
196 :
197 : // CoolingWaterDesAirInletHumRatSizer, CoolingWaterDesAirOutletHumRatSizer
198 : Real64 dataDesInletAirHumRat = 0.0;
199 : // CoolingWaterDesAirInletTempSizer
200 : Real64 dataAirFlowUsedForSizing = 0.0;
201 : Real64 dataDesInletAirTemp = 0.0;
202 : bool dataDesAccountForFanHeat = false;
203 : DataSizing::ZoneFanPlacement dataFanPlacement = DataSizing::ZoneFanPlacement::NotSet;
204 :
205 : // CoolingWaterDesAirInletHumRatSizer, HeatingWaterDesAirInletHumRatSizer,
206 : // HeatingWaterDesAirInletTempSizer
207 : Real64 dataFlowUsedForSizing = 0.0;
208 :
209 : // CoolingWaterDesAirOutletHumRatSizer
210 : Real64 dataDesOutletAirHumRat = 0.0;
211 : Real64 dataDesInletWaterTemp = 0.0;
212 : Real64 dataDesOutletAirTemp = 0.0;
213 :
214 : // CoolingWaterNumofTubesPerRowSizer, HeatingWaterDesCoilWaterVolFlowUsedForUASizer
215 : Real64 dataWaterFlowUsedForSizing = 0.0;
216 :
217 : // CoolingSHRSizing
218 : Real64 dataSizingFraction = 1.0;
219 : int dataDXSpeedNum = 0;
220 :
221 : // WaterHeatingCapacitySizing
222 : bool dataDesicRegCoil = false;
223 :
224 : // WaterHeatingCapacitySizing
225 : Real64 dataHeatSizeRatio = 0.0;
226 :
227 : // ASHRAEMinSATCoolingSizing, ASHRAEMaxSATHeatingSizing
228 : int dataZoneUsedForSizing = 0;
229 :
230 : // HeatingCoilDesAirInletTempSizing,
231 : int dataDesicDehumNum = 0;
232 :
233 : // WaterHeatingCoilUASizing
234 : bool dataNomCapInpMeth = false;
235 : int dataCoilNum = 0;
236 : int dataFanOpMode = 0;
237 : Real64 dataDesignCoilCapacity = 0.0;
238 : bool dataErrorsFound = false;
239 :
240 : // CoolingAirFlowSizing
241 : Real64 dataBypassFrac = 0.0;
242 :
243 : bool dataIsDXCoil = false;
244 :
245 : Real64 dataNonZoneNonAirloopValue = 0.0;
246 :
247 : bool printWarningFlag = false;
248 : std::string callingRoutine;
249 : EPVector<DataSizing::SystemSizingInputData> sysSizingInputData;
250 : EPVector<DataSizing::ZoneSizingInputData> zoneSizingInput;
251 : EPVector<DataSizing::ZoneEqSizingData> unitarySysEqSizing;
252 : EPVector<DataSizing::ZoneEqSizingData> oaSysEqSizing;
253 : EPVector<DataSizing::ZoneEqSizingData> zoneEqSizing;
254 : EPVector<DataAirLoop::OutsideAirSysProps> outsideAirSys;
255 : EPVector<DataSizing::TermUnitSizingData> termUnitSizing;
256 : EPVector<DataSizing::ZoneSizingData> termUnitFinalZoneSizing;
257 : EPVector<DataSizing::ZoneSizingData> finalZoneSizing;
258 : EPVector<DataSizing::SystemSizingData> finalSysSizing;
259 : EPVector<DataSizing::PlantSizingData> plantSizData;
260 : EPVector<DataAirSystems::DefinePrimaryAirSystem> primaryAirSystem;
261 : std::vector<AirLoopHVACDOAS::AirLoopDOAS> airloopDOAS;
262 : EPVector<DataAirLoop::AirLoopControlData> airLoopControlInfo;
263 :
264 : // public methods
265 :
266 : virtual void initializeWithinEP(EnergyPlusData &state,
267 : std::string_view const _compType,
268 : std::string_view const _compName,
269 : bool _printWarningFlag,
270 : std::string_view const _callingRoutine);
271 :
272 : virtual Real64 size(EnergyPlusData &state, Real64 originalValue, bool &errorsFound) = 0;
273 :
274 : std::string getLastErrorMessages();
275 :
276 : void overrideSizingString(std::string_view const string);
277 :
278 : protected:
279 : std::string lastErrorMessages;
280 :
281 : void addErrorMessage(std::string const &s);
282 :
283 : void initializeFromAPI(EnergyPlusData &state, Real64 elevation); // don't accidentally call this direct component from outside
284 :
285 : void preSize(EnergyPlusData &state, Real64 originalValue);
286 :
287 : void selectSizerOutput(EnergyPlusData &state, bool &errorsFound);
288 :
289 : void select2StgDXHumCtrlSizerOutput(EnergyPlusData &state, bool &errorsFound);
290 :
291 : bool isValidCoilType(std::string const &compType);
292 :
293 : bool isValidFanType(std::string const &compType);
294 :
295 : bool checkInitialized(EnergyPlusData &state, bool &errorsFound);
296 :
297 : void clearState();
298 :
299 : public:
300 : static void reportSizerOutput(EnergyPlusData &state,
301 : std::string_view CompType,
302 : std::string_view CompName,
303 : std::string_view VarDesc,
304 : Real64 VarValue,
305 : Optional_string_const UsrDesc = _,
306 : Optional<Real64 const> UsrValue = _);
307 :
308 : Real64 setOAFracForZoneEqSizing(EnergyPlusData &state, Real64 desMassFlow, DataSizing::ZoneEqSizingData const &zoneEqSizing);
309 : Real64 setHeatCoilInletTempForZoneEqSizing(Real64 outAirFrac,
310 : DataSizing::ZoneEqSizingData const &zoneEqSizing,
311 : DataSizing::ZoneSizingData const &finalZoneSizing);
312 : Real64 setHeatCoilInletHumRatForZoneEqSizing(Real64 outAirFrac,
313 : DataSizing::ZoneEqSizingData const &zoneEqSizing,
314 : DataSizing::ZoneSizingData const &finalZoneSizing);
315 : Real64 setCoolCoilInletTempForZoneEqSizing(Real64 outAirFrac,
316 : DataSizing::ZoneEqSizingData const &zoneEqSizing,
317 : DataSizing::ZoneSizingData const &finalZoneSizing);
318 : Real64 setCoolCoilInletHumRatForZoneEqSizing(Real64 outAirFrac,
319 : DataSizing::ZoneEqSizingData const &zoneEqSizing,
320 : DataSizing::ZoneSizingData const &finalZoneSizing);
321 : };
322 :
323 : } // namespace EnergyPlus
324 :
325 : #endif
|