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 WaterUse_hh_INCLUDED
49 : #define WaterUse_hh_INCLUDED
50 :
51 : // ObjexxFCL Headers
52 : #include <ObjexxFCL/Array1D.hh>
53 :
54 : // EnergyPlus Headers
55 : #include <EnergyPlus/Data/BaseData.hh>
56 : #include <EnergyPlus/DataGlobals.hh>
57 : #include <EnergyPlus/EnergyPlus.hh>
58 : #include <EnergyPlus/Plant/PlantLocation.hh>
59 : #include <EnergyPlus/PlantComponent.hh>
60 :
61 : namespace EnergyPlus {
62 :
63 : // Forward declarations
64 : struct EnergyPlusData;
65 :
66 : namespace WaterUse {
67 :
68 : enum class HeatRecovHX
69 : {
70 : Invalid = -1,
71 : Ideal,
72 : CounterFlow,
73 : CrossFlow,
74 : Num
75 : };
76 :
77 : enum class HeatRecovConfig
78 : {
79 : Invalid = -1,
80 : Plant,
81 : Equipment,
82 : PlantAndEquip,
83 : Num
84 : };
85 :
86 2823 : struct WaterEquipmentType
87 : {
88 : std::string Name; // Name of DHW
89 : std::string EndUseSubcatName;
90 : int Connections = 0; // Index for WATER USE CONNECTIONS object
91 : Real64 PeakVolFlowRate = 0.0; // Peak volumetric flow rate, also water consumption rate (m3/s)
92 : int FlowRateFracSchedule = 0; // Pointer to schedule object
93 : Real64 ColdVolFlowRate = 0.0;
94 : Real64 HotVolFlowRate = 0.0;
95 : Real64 TotalVolFlowRate = 0.0; // Volumetric flow rate, also water consumption rate (m3/s)
96 : Real64 ColdMassFlowRate = 0.0;
97 : Real64 HotMassFlowRate = 0.0;
98 : Real64 TotalMassFlowRate = 0.0; // Mass flow rate (kg/s)
99 : Real64 DrainMassFlowRate = 0.0;
100 : int ColdTempSchedule = 0; // Index for schedule object
101 : int HotTempSchedule = 0; // Index for schedule object
102 : int TargetTempSchedule = 0; // Index for schedule object
103 : Real64 ColdTemp = 0.0; // Cold supply water temperature (C)
104 : Real64 HotTemp = 0.0; // Hot supply water temperature (C)
105 : Real64 TargetTemp = 0.0; // Target (mixed) water temperature (C)
106 : Real64 MixedTemp = 0.0; // Actual outlet (mixed) water temperature (C)
107 : Real64 DrainTemp = 0.0;
108 : int CWHWTempErrorCount = 0; // - counter if hot water temp is less than cold water temp
109 : int CWHWTempErrIndex = 0; // - index to recurring error structure for hot water temp
110 : int TargetHWTempErrorCount = 0; // - counter for target water temp error
111 : int TargetHWTempErrIndex = 0; // - index to recurring error structure for target water temp
112 : int TargetCWTempErrorCount = 0; // - counter for target water temp error
113 : int TargetCWTempErrIndex = 0; // - index to recurring error structure for target water temp
114 : int Zone = 0; // Index for zone object
115 : int SensibleFracSchedule = 0; // Pointer to schedule object
116 : Real64 SensibleRate = 0.0;
117 : Real64 SensibleEnergy = 0.0;
118 : Real64 SensibleRateNoMultiplier = 0.0;
119 : int LatentFracSchedule = 0; // Pointer to schedule object
120 : Real64 LatentRate = 0.0;
121 : Real64 LatentEnergy = 0.0;
122 : Real64 LatentRateNoMultiplier = 0.0;
123 : Real64 MoistureRate = 0.0;
124 : Real64 MoistureMass = 0.0;
125 : Real64 ColdVolume = 0.0; // Water consumption (m3)
126 : Real64 HotVolume = 0.0; // Water consumption (m3)
127 : Real64 TotalVolume = 0.0; // Water consumption (m3)
128 : Real64 Power = 0.0; // Heating rate required to meet the mixed water temperature (W)
129 : Real64 Energy = 0.0; // Heating energy required to meet the mixed water temperature (J)
130 : bool setupMyOutputVars = true;
131 : bool allowHotControl = false; // only certain configurations will use hot water flow and/or hot water temp schedule
132 :
133 : // Reset Some Values to Zeros
134 359810 : void reset()
135 : {
136 359810 : SensibleRate = 0.0;
137 359810 : SensibleEnergy = 0.0;
138 359810 : LatentRate = 0.0;
139 359810 : LatentEnergy = 0.0;
140 359810 : MixedTemp = 0.0;
141 359810 : TotalMassFlowRate = 0.0;
142 359810 : DrainTemp = 0.0;
143 359810 : }
144 :
145 : void CalcEquipmentFlowRates(EnergyPlusData &state);
146 :
147 : void CalcEquipmentDrainTemp(EnergyPlusData &state);
148 :
149 : void setupOutputVars(EnergyPlusData &state);
150 : };
151 :
152 2836 : struct WaterConnectionsType : PlantComponent
153 : {
154 : std::string Name; // Name of DHW
155 : bool Init = true; // Flag for initialization: TRUE means do the init
156 : bool InitSizing = true; // Flag for initialization of plant sizing
157 : bool StandAlone = false; // Flag for operation with no plant connections
158 : int InletNode = 0; // Hot water demand node
159 : int OutletNode = 0; // Cold water supply node
160 : int SupplyTankNum = 0;
161 : int RecoveryTankNum = 0;
162 : int TankDemandID = 0; // array to request flow from supply tank
163 : int TankSupplyID = 0; // array to send flow to recovery tank
164 : bool HeatRecovery = false;
165 : HeatRecovHX HeatRecoveryHX = HeatRecovHX::Ideal;
166 : HeatRecovConfig HeatRecoveryConfig = HeatRecovConfig::Plant;
167 : Real64 HXUA = 0.0;
168 : Real64 Effectiveness = 0.0;
169 : Real64 RecoveryRate = 0.0;
170 : Real64 RecoveryEnergy = 0.0;
171 : Real64 MainsMassFlowRate = 0.0; // Mass flow rate (kg/s)
172 : Real64 TankMassFlowRate = 0.0; // Mass flow rate (kg/s)
173 : Real64 ColdMassFlowRate = 0.0; // Mass flow rate (kg/s) cold = mains + tank
174 : Real64 HotMassFlowRate = 0.0; // Mass flow rate (kg/s)
175 : Real64 TotalMassFlowRate = 0.0; // Mass flow rate (kg/s) total = cold + hot
176 : Real64 DrainMassFlowRate = 0.0;
177 : Real64 RecoveryMassFlowRate = 0.0;
178 : Real64 PeakVolFlowRate = 0.0; // Volumetric flow rate, also water consumption rate (m3/s)
179 : Real64 MainsVolFlowRate = 0.0; // Volumetric flow rate, also water consumption rate (m3/s)
180 : Real64 TankVolFlowRate = 0.0; // Volumetric flow rate, also water consumption rate (m3/s)
181 : Real64 ColdVolFlowRate = 0.0; // Volumetric flow rate, also water consumption rate (m3/s)
182 : Real64 HotVolFlowRate = 0.0; // Volumetric flow rate, also water consumption rate (m3/s)
183 : Real64 TotalVolFlowRate = 0.0; // Volumetric flow rate, also water consumption rate (m3/s)
184 : Real64 DrainVolFlowRate = 0.0;
185 : Real64 PeakMassFlowRate = 0.0; // Peak Mass flow rate for MassFlowRateMax
186 : int ColdTempSchedule = 0; // Index for schedule object
187 : int HotTempSchedule = 0; // Index for schedule object
188 : Real64 MainsTemp = 0.0; // Cold supply water temperature (C)
189 : Real64 TankTemp = 0.0; // Cold supply water temperature (C)
190 : Real64 ColdSupplyTemp = 0.0; // cold from mains, schedule, or tank, depending
191 : Real64 ColdTemp = 0.0; // Cold supply water temperature (C) actual cold (could be reheated)
192 : Real64 HotTemp = 0.0; // Hot supply water temperature (C)
193 : Real64 DrainTemp = 0.0;
194 : Real64 RecoveryTemp = 0.0;
195 : Real64 ReturnTemp = 0.0;
196 : Real64 WasteTemp = 0.0;
197 : Real64 TempError = 0.0;
198 : Real64 MainsVolume = 0.0; // Water consumption (m3)
199 : Real64 TankVolume = 0.0; // Water consumption (m3)
200 : Real64 ColdVolume = 0.0; // Water consumption (m3)
201 : Real64 HotVolume = 0.0; // Water consumption (m3)
202 : Real64 TotalVolume = 0.0; // Water consumption (m3)
203 : Real64 Power = 0.0; // Heating rate required to raise temperature from cold to hot (W)
204 : Real64 Energy = 0.0; // Heating energy required to raise temperature from cold to hot (J)
205 : int NumWaterEquipment = 0;
206 : int MaxIterationsErrorIndex = 0; // recurring error index
207 : Array1D_int myWaterEquipArr;
208 : PlantLocation plantLoc{};
209 : bool MyEnvrnFlag = true;
210 :
211 : static PlantComponent *factory(EnergyPlusData &state, std::string const &objectName);
212 :
213 : void simulate([[maybe_unused]] EnergyPlusData &state,
214 : const PlantLocation &calledFromLocation,
215 : bool FirstHVACIteration,
216 : Real64 &CurLoad,
217 : bool RunFlag) override;
218 :
219 : void InitConnections(EnergyPlusData &state);
220 :
221 : void CalcConnectionsFlowRates(EnergyPlusData &state, bool FirstHVACIteration);
222 :
223 : void CalcConnectionsDrainTemp(EnergyPlusData &state);
224 :
225 : void CalcConnectionsHeatRecovery(EnergyPlusData &state);
226 :
227 : void UpdateWaterConnections(EnergyPlusData &state);
228 :
229 : void ReportWaterUse(EnergyPlusData &state);
230 :
231 : void setupOutputVars([[maybe_unused]] EnergyPlusData &state);
232 :
233 : void oneTimeInit(EnergyPlusData &state) override;
234 :
235 : void oneTimeInit_new(EnergyPlusData &state) override;
236 : };
237 :
238 : void SimulateWaterUse(EnergyPlusData &state, bool FirstHVACIteration);
239 :
240 : void GetWaterUseInput(EnergyPlusData &state);
241 :
242 : void ReportStandAloneWaterUse(EnergyPlusData &state);
243 :
244 : void CalcWaterUseZoneGains(EnergyPlusData &state);
245 :
246 : } // namespace WaterUse
247 :
248 1542 : struct WaterUseData : BaseGlobalStruct
249 : {
250 :
251 : int numWaterEquipment = 0;
252 : int numWaterConnections = 0;
253 : bool getWaterUseInputFlag = true;
254 : bool MyEnvrnFlagLocal = true;
255 : Array1D_bool CheckEquipName;
256 : EPVector<WaterUse::WaterEquipmentType> WaterEquipment;
257 : EPVector<WaterUse::WaterConnectionsType> WaterConnections;
258 :
259 0 : void clear_state() override
260 : {
261 0 : new (this) WaterUseData();
262 0 : }
263 : };
264 :
265 : } // namespace EnergyPlus
266 :
267 : #endif
|