Line data Source code
1 : // EnergyPlus, Copyright (c) 1996-2024, 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 SwimmingPool_hh_INCLUDED
49 : #define SwimmingPool_hh_INCLUDED
50 :
51 : // ObjexxFCL Headers
52 : #include <ObjexxFCL/Array1D.hh>
53 :
54 : // EnergyPlus Headers
55 : #include <EnergyPlus/DataGlobals.hh>
56 : #include <EnergyPlus/EnergyPlus.hh>
57 : #include <EnergyPlus/PlantComponent.hh>
58 :
59 : namespace EnergyPlus {
60 :
61 : // Forward declarations
62 : struct EnergyPlusData;
63 :
64 : namespace SwimmingPool {
65 :
66 : struct SwimmingPoolData : PlantComponent
67 : {
68 : // Members
69 : // Input data
70 : std::string Name; // name of swimming pool
71 : std::string SurfaceName; // surface name of pool
72 : int SurfacePtr; // index to surface array
73 : std::string ZoneName; // Name of zone the pool is in
74 : int ZonePtr; // Pointer to this zone in the Zone derived type
75 : std::string WaterInletNodeName; // water inlet node name
76 : int WaterInletNode; // water inlet node number
77 : std::string WaterOutletNodeName; // water outlet node name
78 : int WaterOutletNode; // water outlet node number
79 : PlantLocation HWplantLoc;
80 : Real64 WaterVolFlowMax; // maximum water flow rate for pool, m3/s
81 : Real64 WaterMassFlowRateMax; // maximum water mass flow rate for pool, kg/s
82 : Real64 AvgDepth; // average depth of the pool, m
83 : Real64 ActivityFactor; // Activity factor for the pool
84 : std::string ActivityFactorSchedName; // Activity factor schedule name
85 : int ActivityFactorSchedPtr; // Activity factor schedule pointer
86 : Real64 CurActivityFactor; // Current activity factor value
87 : int MakeupWaterSupplySchedPtr; // Index to schedule for make-up water
88 : Real64 CurMakeupWaterTemp; // Current makeup water temperature
89 : std::string CoverSchedName; // Pool cover schedule name
90 : int CoverSchedPtr; // Index to pool cover schedule
91 : Real64 CurCoverSchedVal; // Current cover schedule value based on schedule
92 : Real64 CoverEvapFactor; // Pool cover evaporation factor
93 : Real64 CoverConvFactor; // Pool cover convective factor
94 : Real64 CoverSWRadFactor; // Pool cover short-wavelength radiation factor
95 : Real64 CoverLWRadFactor; // Pool cover long-wavelength radiation factor
96 : Real64 CurCoverEvapFac; // Current pool cover evaporation factor
97 : Real64 CurCoverConvFac; // Current pool cover convective factor
98 : Real64 CurCoverSWRadFac; // Current pool cover short-wavelength radiation factor
99 : Real64 CurCoverLWRadFac; // Current pool cover long-wavelength radiation factor
100 : Real64 RadConvertToConvect; // LW and SW radiation converted to convective gain by pool cover in W/m2
101 : Real64 MiscPowerFactor; // Pool miscellaneous power equipment consumption coefficient in W/(kg/s)
102 : int SetPtTempSchedPtr; // Schedule pointer for water setpoint temperature
103 : Real64 CurSetPtTemp; // Current water setpoint temperature
104 : Real64 MaxNumOfPeople; // Number of people in the pool as defined by user input
105 : std::string PeopleSchedName; // Name of people schedule
106 : int PeopleSchedPtr; // People schedule index
107 : std::string PeopleHeatGainSchedName; // Name of people heat gain schedule
108 : int PeopleHeatGainSchedPtr; // People heat gain schedule index
109 : Real64 PeopleHeatGain; // Current heat gain from people
110 : int GlycolIndex; // index in fluid property routines for water
111 : Real64 WaterMass; // pool water mass
112 : Real64 SatPressPoolWaterTemp; // Saturation pressure at the pool water temperature
113 : Real64 PartPressZoneAirTemp; // Partial pressure of water vapor in the air
114 : // Report data
115 : Real64 PoolWaterTemp; // Average pool water temperature
116 : Real64 WaterInletTemp; // water inlet temperature
117 : Real64 WaterOutletTemp; // water outlet temperature
118 : Real64 WaterMassFlowRate; // water mass flow rate
119 : Real64 MakeUpWaterMassFlowRate; // makeup water flow rate (addition to the pool)
120 : Real64 MakeUpWaterMass; // makeup water mass added to pool
121 : Real64 MakeUpWaterVolFlowRate; // makeup water volume flow rate
122 : Real64 MakeUpWaterVol; // makeup water volume added to pool
123 : Real64 HeatPower; // heating sent to pool in Watts
124 : Real64 HeatEnergy; // heating sent to pool in Joules
125 : Real64 MiscEquipPower; // power for miscellaneous pool equipment in Watts
126 : Real64 MiscEquipEnergy; // energy for miscellaneous pool equipment in Joules
127 : Real64 RadConvertToConvectRep; // LW and SW radiation converted to convective gain by pool cover (reporting) in W
128 : Real64 EvapHeatLossRate; // Heat lost due to evaporation of pool water as a rate in Watts
129 : Real64 EvapEnergyLoss; // Energy lost due to evaporation in Joules
130 : bool MyOneTimeFlag;
131 : bool MyEnvrnFlagGeneral;
132 : bool MyPlantScanFlagPool;
133 : Real64 QPoolSrcAvg; // Average source over the time step for a particular radiant surface
134 : Real64 HeatTransCoefsAvg; // Average denominator term over the time step for a particular pool
135 : Real64 ZeroPoolSourceSumHATsurf; // Equal to SumHATsurf for all the walls in a zone with no source
136 : // Record keeping variables used to calculate QRadSysSrcAvg locally
137 : Real64 LastQPoolSrc; // Need to keep the last value in case we are still iterating
138 : Real64 LastHeatTransCoefs; // Need to keep the last value in case we are still iterating
139 : Real64 LastSysTimeElapsed; // Need to keep the last value in case we are still iterating
140 : Real64 LastTimeStepSys; // Need to keep the last value in case we are still iterating
141 :
142 : // Default Constructor
143 2 : SwimmingPoolData()
144 2 : : SurfacePtr(0), ZonePtr(0), WaterInletNode(0), WaterOutletNode(0), HWplantLoc{}, WaterVolFlowMax(0.0), WaterMassFlowRateMax(0.0),
145 4 : AvgDepth(0.0), ActivityFactor(0.0), ActivityFactorSchedPtr(0), CurActivityFactor(0.0), MakeupWaterSupplySchedPtr(0),
146 4 : CurMakeupWaterTemp(0.0), CoverSchedPtr(0), CurCoverSchedVal(0.0), CoverEvapFactor(0.0), CoverConvFactor(0.0), CoverSWRadFactor(0.0),
147 2 : CoverLWRadFactor(0.0), CurCoverEvapFac(0.0), CurCoverConvFac(0.0), CurCoverSWRadFac(0.0), CurCoverLWRadFac(0.0),
148 4 : RadConvertToConvect(0.0), MiscPowerFactor(0.0), SetPtTempSchedPtr(0), CurSetPtTemp(23.0), MaxNumOfPeople(0.0), PeopleSchedPtr(0),
149 2 : PeopleHeatGainSchedPtr(0), PeopleHeatGain(0.0), GlycolIndex(0), WaterMass(0.0), SatPressPoolWaterTemp(0.0), PartPressZoneAirTemp(0.0),
150 2 : PoolWaterTemp(23.0), WaterInletTemp(0.0), WaterOutletTemp(0.0), WaterMassFlowRate(0.0), MakeUpWaterMassFlowRate(0.0),
151 2 : MakeUpWaterMass(0.0), MakeUpWaterVolFlowRate(0.0), MakeUpWaterVol(0.0), HeatPower(0.0), HeatEnergy(0.0), MiscEquipPower(0.0),
152 2 : MiscEquipEnergy(0.0), RadConvertToConvectRep(0.0), EvapHeatLossRate(0.0), EvapEnergyLoss(0.0), MyOneTimeFlag(true),
153 2 : MyEnvrnFlagGeneral(true), MyPlantScanFlagPool(true), QPoolSrcAvg(0.0), HeatTransCoefsAvg(0.0), ZeroPoolSourceSumHATsurf(0.0),
154 4 : LastQPoolSrc(0.0), LastHeatTransCoefs(0.0), LastSysTimeElapsed(0.0), LastTimeStepSys(0.0)
155 : {
156 2 : }
157 :
158 : static SwimmingPoolData *factory(EnergyPlusData &state, std::string const &objectName);
159 :
160 : void simulate([[maybe_unused]] EnergyPlusData &state,
161 : const PlantLocation &calledFromLocation,
162 : bool FirstHVACIteration,
163 : Real64 &CurLoad,
164 : bool RunFlag) override;
165 :
166 : void ErrorCheckSetupPoolSurface(
167 : EnergyPlusData &state, std::string_view Alpha1, std::string_view Alpha2, std::string_view cAlphaField2, bool &ErrorsFound);
168 :
169 : void initialize(EnergyPlusData &state, bool FirstHVACIteration // true during the first HVAC iteration
170 : );
171 :
172 : void setupOutputVars(EnergyPlusData &state);
173 :
174 : void initSwimmingPoolPlantLoopIndex(EnergyPlusData &state);
175 :
176 : void initSwimmingPoolPlantNodeFlow(EnergyPlusData &state) const;
177 :
178 : void calculate(EnergyPlusData &state);
179 :
180 : void calcMassFlowRate(EnergyPlusData &state,
181 : Real64 &massFlowRate, // Mass Flow Rate (to be calculated)
182 : Real64 TH22, // Pool water temperature from previous time step
183 : Real64 TLoopInletTemp //
184 : );
185 :
186 : void calcSwimmingPoolEvap(EnergyPlusData &state,
187 : Real64 &EvapRate, // Evaporation rate
188 : int SurfNum, // Surface index
189 : Real64 MAT, // mean air temperature
190 : Real64 HumRat // zone air humidity ratio
191 : );
192 :
193 : void update(EnergyPlusData &state);
194 :
195 : void oneTimeInit(EnergyPlusData &state) override;
196 :
197 : void oneTimeInit_new(EnergyPlusData &state) override;
198 :
199 : void report(EnergyPlusData &state);
200 : };
201 :
202 : void GetSwimmingPool(EnergyPlusData &state);
203 :
204 : void UpdatePoolSourceValAvg(EnergyPlusData &state, bool &SwimmingPoolOn); // .TRUE. if the swimming pool has "run" this zone time step
205 :
206 : Real64 MakeUpWaterVolFlowFunct(Real64 MakeUpWaterMassFlowRate, Real64 Density);
207 :
208 : Real64 MakeUpWaterVolFunct(Real64 MakeUpWaterMass, Real64 Density);
209 :
210 : } // namespace SwimmingPool
211 :
212 : struct SwimmingPoolsData : BaseGlobalStruct
213 : {
214 :
215 : // MODULE VARIABLE DECLARATIONS:
216 : int NumSwimmingPools = 0; // Number of swimming pools
217 : Array1D_bool CheckEquipName;
218 : bool getSwimmingPoolInput = true;
219 : Array1D<SwimmingPool::SwimmingPoolData> Pool;
220 :
221 796 : void init_state([[maybe_unused]] EnergyPlusData &state) override
222 : {
223 796 : }
224 :
225 0 : void clear_state() override
226 : {
227 0 : NumSwimmingPools = 0;
228 0 : getSwimmingPoolInput = true;
229 0 : CheckEquipName.deallocate();
230 0 : Pool.deallocate();
231 0 : }
232 :
233 : // Default Constructor
234 796 : SwimmingPoolsData() = default;
235 : };
236 : } // namespace EnergyPlus
237 :
238 : #endif
|