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 UnitHeater_hh_INCLUDED
49 : #define UnitHeater_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/DataGlobals.hh>
58 : #include <EnergyPlus/EnergyPlus.hh>
59 : #include <EnergyPlus/FluidProperties.hh>
60 :
61 : namespace EnergyPlus {
62 :
63 : // Forward declarations
64 : struct EnergyPlusData;
65 :
66 : namespace UnitHeater {
67 :
68 : enum class HCoilType
69 : {
70 : Invalid = -1,
71 : Electric,
72 : Gas,
73 : WaterHeatingCoil,
74 : SteamCoil,
75 : Num
76 : };
77 :
78 : static constexpr std::array<std::string_view, static_cast<int>(HCoilType::Num)> HCoilTypeNamesUC{
79 : "COIL:HEATING:ELECTRIC",
80 : "COIL:HEATING:FUEL",
81 : "COIL:HEATING:WATER",
82 : "COIL:HEATING:STEAM",
83 : };
84 :
85 : struct UnitHeaterData
86 : {
87 : // Members
88 : // Input data
89 : std::string Name; // name of unit
90 : Sched::Schedule *availSched = nullptr; // availability schedule
91 : int AirInNode; // inlet air node number
92 : int AirOutNode; // outlet air node number
93 : HVAC::FanType fanType; // Fan type number (see DataHVACGlobals)
94 : std::string FanName; // name of fan
95 : int Fan_Index;
96 : Sched::Schedule *fanOpModeSched = nullptr; // fan operating mode schedule
97 : Sched::Schedule *fanAvailSched = nullptr; // fan availability schedule
98 : int ControlCompTypeNum;
99 : int CompErrIndex;
100 : Real64 MaxAirVolFlow; // m3/s
101 : Real64 MaxAirMassFlow; // kg/s
102 : std::string FanOperatesDuringNoHeating; // Indicates whether fan operates or not during no heating
103 : int FanOutletNode; // outlet node number for fan exit
104 : // (assumes fan is upstream of heating coil)
105 : HVAC::FanOp fanOp = HVAC::FanOp::Invalid; // mode of operation; 1=cycling fan, cycling coil, 2=continuous fan, cycling coil
106 : HCoilType Type; // type of heating coil (water, gas, electric, etc.)
107 : std::string HCoilTypeCh; // actual object name
108 : std::string HCoilName; // name of heating coil
109 : int HCoil_Index;
110 : DataPlant::PlantEquipmentType HeatingCoilType;
111 : Fluid::RefrigProps *HCoil_fluid = nullptr;
112 : Real64 MaxVolHotWaterFlow; // m3/s
113 : Real64 MaxVolHotSteamFlow; // m3/s
114 : Real64 MaxHotWaterFlow; // kg/s
115 : Real64 MaxHotSteamFlow; // m3/s
116 : Real64 MinVolHotWaterFlow; // m3/s
117 : Real64 MinVolHotSteamFlow; // m3/s
118 : Real64 MinHotWaterFlow; // kg/s
119 : Real64 MinHotSteamFlow; // kg/s
120 : int HotControlNode; // hot water control node, inlet of coil
121 : Real64 HotControlOffset; // control tolerance
122 : int HotCoilOutNodeNum; // outlet of coil
123 : PlantLocation HWplantLoc; // Location of plant component for hot plant coil
124 : Real64 PartLoadFrac; // part load fraction for the unit
125 : // Report data
126 : Real64 HeatPower; // unit heating output in watts
127 : Real64 HeatEnergy; // unit heating output in J
128 : Real64 ElecPower;
129 : Real64 ElecEnergy;
130 : std::string AvailManagerListName; // Name of an availability manager list object
131 : Avail::Status availStatus = Avail::Status::NoAction;
132 : bool FanOffNoHeating; // True when fan is on during no heating load
133 : Real64 FanPartLoadRatio; // fan part-load ratio for time step
134 : int ZonePtr; // pointer to a zone served by a unit heater
135 : int HVACSizingIndex; // index of a HVACSizing object for a unit heater
136 : bool FirstPass; // detects first time through for resetting sizing data
137 :
138 : // Default Constructor
139 9 : UnitHeaterData()
140 27 : : AirInNode(0), AirOutNode(0), fanType(HVAC::FanType::Invalid), Fan_Index(0), ControlCompTypeNum(0), CompErrIndex(0), MaxAirVolFlow(0.0),
141 27 : MaxAirMassFlow(0.0), FanOutletNode(0), HCoil_Index(0), HeatingCoilType(DataPlant::PlantEquipmentType::Invalid), MaxVolHotWaterFlow(0.0),
142 9 : MaxVolHotSteamFlow(0.0), MaxHotWaterFlow(0.0), MaxHotSteamFlow(0.0), MinVolHotWaterFlow(0.0), MinVolHotSteamFlow(0.0),
143 9 : MinHotWaterFlow(0.0), MinHotSteamFlow(0.0), HotControlNode(0), HotControlOffset(0.0), HotCoilOutNodeNum(0), HWplantLoc{},
144 18 : PartLoadFrac(0.0), HeatPower(0.0), HeatEnergy(0.0), ElecPower(0.0), ElecEnergy(0.0), FanOffNoHeating(false), FanPartLoadRatio(0.0),
145 9 : ZonePtr(0), HVACSizingIndex(0), FirstPass(true)
146 : {
147 9 : }
148 : };
149 :
150 : struct UnitHeatNumericFieldData
151 : {
152 : // Members
153 : Array1D_string FieldNames;
154 :
155 : // Default Constructor
156 7 : UnitHeatNumericFieldData()
157 7 : {
158 7 : }
159 : };
160 :
161 : void SimUnitHeater(EnergyPlusData &state,
162 : std::string_view CompName, // name of the fan coil unit
163 : int const ZoneNum, // number of zone being served
164 : bool const FirstHVACIteration, // TRUE if 1st HVAC simulation of system timestep
165 : Real64 &PowerMet, // Sensible power supplied (W)
166 : Real64 &LatOutputProvided, // Latent add/removal supplied by window AC (kg/s), dehumid = negative
167 : int &CompIndex);
168 :
169 : void GetUnitHeaterInput(EnergyPlusData &state);
170 :
171 : void InitUnitHeater(EnergyPlusData &state,
172 : int const UnitHeatNum, // index for the current unit heater
173 : int const ZoneNum, // number of zone being served
174 : bool const FirstHVACIteration // TRUE if 1st HVAC simulation of system timestep
175 : );
176 :
177 : void SizeUnitHeater(EnergyPlusData &state, int const UnitHeatNum);
178 :
179 : void CalcUnitHeater(EnergyPlusData &state,
180 : int &UnitHeatNum, // number of the current fan coil unit being simulated
181 : int const ZoneNum, // number of zone being served
182 : bool const FirstHVACIteration, // TRUE if 1st HVAC simulation of system timestep
183 : Real64 &PowerMet, // Sensible power supplied (W)
184 : Real64 &LatOutputProvided // Latent power supplied (kg/s), negative = dehumidification
185 : );
186 :
187 : void CalcUnitHeaterComponents(EnergyPlusData &state,
188 : int const UnitHeatNum, // Unit index in unit heater array
189 : bool const FirstHVACIteration, // flag for 1st HVAV iteration in the time step
190 : Real64 &LoadMet, // load met by unit (watts)
191 : HVAC::FanOp const fanOp = HVAC::FanOp::Continuous, // fan operating mode
192 : Real64 const PartLoadRatio = 1.0 // part-load ratio
193 : );
194 :
195 : // SUBROUTINE UpdateUnitHeater
196 :
197 : // No update routine needed in this module since all of the updates happen on
198 : // the Node derived type directly and these updates are done by other routines.
199 :
200 : // END SUBROUTINE UpdateUnitHeater
201 :
202 : void ReportUnitHeater(EnergyPlusData &state, int const UnitHeatNum); // Unit index in unit heater array
203 :
204 : int getUnitHeaterIndex(EnergyPlusData &state, std::string_view CompName);
205 : } // namespace UnitHeater
206 :
207 : struct UnitHeatersData : BaseGlobalStruct
208 : {
209 :
210 : // MODULE PARAMETER DEFINITIONS
211 : std::string const cMO_UnitHeater = "ZoneHVAC:UnitHeater";
212 :
213 : // Character parameters for outside air control types:
214 :
215 : bool HCoilOn; // TRUE if the heating coil (gas or electric especially) should be running
216 : int NumOfUnitHeats; // Number of unit heaters in the input file
217 : Real64 QZnReq; // heating or cooling needed by zone [watts]
218 : Array1D_bool MySizeFlag;
219 : Array1D_bool CheckEquipName;
220 :
221 : bool InitUnitHeaterOneTimeFlag = true;
222 : bool GetUnitHeaterInputFlag = true;
223 : bool ZoneEquipmentListChecked = false; // True after the Zone Equipment List has been checked for items
224 : bool SetMassFlowRateToZero = false; // TRUE when mass flow rates need to be set to zero
225 :
226 : // Object Data
227 : EPVector<UnitHeater::UnitHeaterData> UnitHeat;
228 : EPVector<UnitHeater::UnitHeatNumericFieldData> UnitHeatNumericFields;
229 :
230 : Array1D_bool MyEnvrnFlag;
231 : Array1D_bool MyPlantScanFlag;
232 : Array1D_bool MyZoneEqFlag; // used to set up zone equipment availability managers
233 :
234 2126 : void init_constant_state([[maybe_unused]] EnergyPlusData &state) override
235 : {
236 2126 : }
237 :
238 1152 : void init_state([[maybe_unused]] EnergyPlusData &state) override
239 : {
240 1152 : }
241 :
242 2100 : void clear_state() override
243 : {
244 2100 : this->HCoilOn = false;
245 2100 : this->NumOfUnitHeats = 0;
246 2100 : this->QZnReq = 0.0;
247 2100 : this->MySizeFlag.deallocate();
248 2100 : this->CheckEquipName.deallocate();
249 2100 : this->UnitHeat.deallocate();
250 2100 : this->UnitHeatNumericFields.deallocate();
251 2100 : this->InitUnitHeaterOneTimeFlag = true;
252 2100 : this->GetUnitHeaterInputFlag = true;
253 2100 : this->ZoneEquipmentListChecked = false;
254 2100 : this->SetMassFlowRateToZero = false;
255 2100 : this->MyEnvrnFlag.deallocate();
256 2100 : this->MyPlantScanFlag.deallocate();
257 2100 : this->MyZoneEqFlag.deallocate();
258 2100 : }
259 :
260 : // Default Constructor
261 6387 : UnitHeatersData() = default;
262 : };
263 :
264 : } // namespace EnergyPlus
265 :
266 : #endif
|