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 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 : Sched::Schedule *activityFactorSched = nullptr; // Activity factor schedule
85 : Real64 CurActivityFactor; // Current activity factor value
86 : Sched::Schedule *makeupWaterSupplySched = nullptr; // schedule for make-up water
87 : Real64 CurMakeupWaterTemp; // Current makeup water temperature
88 : Sched::Schedule *coverSched = nullptr; // pool cover schedule
89 : Real64 CurCoverSchedVal; // Current cover schedule value based on schedule
90 : Real64 CoverEvapFactor; // Pool cover evaporation factor
91 : Real64 CoverConvFactor; // Pool cover convective factor
92 : Real64 CoverSWRadFactor; // Pool cover short-wavelength radiation factor
93 : Real64 CoverLWRadFactor; // Pool cover long-wavelength radiation factor
94 : Real64 CurCoverEvapFac; // Current pool cover evaporation factor
95 : Real64 CurCoverConvFac; // Current pool cover convective factor
96 : Real64 CurCoverSWRadFac; // Current pool cover short-wavelength radiation factor
97 : Real64 CurCoverLWRadFac; // Current pool cover long-wavelength radiation factor
98 : Real64 RadConvertToConvect; // LW and SW radiation converted to convective gain by pool cover in W/m2
99 : Real64 MiscPowerFactor; // Pool miscellaneous power equipment consumption coefficient in W/(kg/s)
100 : Sched::Schedule *setPtTempSched = nullptr; // Schedule for water setpoint temperature
101 : Real64 CurSetPtTemp; // Current water setpoint temperature
102 : Real64 MaxNumOfPeople; // Number of people in the pool as defined by user input
103 : Sched::Schedule *peopleSched = nullptr; // People schedule
104 : Sched::Schedule *peopleHeatGainSched = nullptr; // People heat gain schedule
105 : Real64 PeopleHeatGain; // Current heat gain from people
106 : Fluid::GlycolProps *glycol = nullptr;
107 : Real64 WaterMass; // pool water mass
108 : Real64 SatPressPoolWaterTemp; // Saturation pressure at the pool water temperature
109 : Real64 PartPressZoneAirTemp; // Partial pressure of water vapor in the air
110 : // Report data
111 : Real64 PoolWaterTemp; // Average pool water temperature
112 : Real64 WaterInletTemp; // water inlet temperature
113 : Real64 WaterOutletTemp; // water outlet temperature
114 : Real64 WaterMassFlowRate; // water mass flow rate
115 : Real64 MakeUpWaterMassFlowRate; // makeup water flow rate (addition to the pool)
116 : Real64 MakeUpWaterMass; // makeup water mass added to pool
117 : Real64 MakeUpWaterVolFlowRate; // makeup water volume flow rate
118 : Real64 MakeUpWaterVol; // makeup water volume added to pool
119 : Real64 HeatPower; // heating sent to pool in Watts
120 : Real64 HeatEnergy; // heating sent to pool in Joules
121 : Real64 MiscEquipPower; // power for miscellaneous pool equipment in Watts
122 : Real64 MiscEquipEnergy; // energy for miscellaneous pool equipment in Joules
123 : Real64 RadConvertToConvectRep; // LW and SW radiation converted to convective gain by pool cover (reporting) in W
124 : Real64 EvapHeatLossRate; // Heat lost due to evaporation of pool water as a rate in Watts
125 : Real64 EvapEnergyLoss; // Energy lost due to evaporation in Joules
126 : bool MyOneTimeFlag;
127 : bool MyEnvrnFlagGeneral;
128 : bool MyPlantScanFlagPool;
129 : Real64 QPoolSrcAvg; // Average source over the time step for a particular radiant surface
130 : Real64 HeatTransCoefsAvg; // Average denominator term over the time step for a particular pool
131 : Real64 ZeroPoolSourceSumHATsurf; // Equal to SumHATsurf for all the walls in a zone with no source
132 : // Record keeping variables used to calculate QRadSysSrcAvg locally
133 : Real64 LastQPoolSrc; // Need to keep the last value in case we are still iterating
134 : Real64 LastHeatTransCoefs; // Need to keep the last value in case we are still iterating
135 : Real64 LastSysTimeElapsed; // Need to keep the last value in case we are still iterating
136 : Real64 LastTimeStepSys; // Need to keep the last value in case we are still iterating
137 :
138 : // Default Constructor
139 13 : SwimmingPoolData()
140 13 : : SurfacePtr(0), ZonePtr(0), WaterInletNode(0), WaterOutletNode(0), HWplantLoc{}, WaterVolFlowMax(0.0), WaterMassFlowRateMax(0.0),
141 13 : AvgDepth(0.0), ActivityFactor(0.0), CurActivityFactor(0.0), CurMakeupWaterTemp(0.0), CurCoverSchedVal(0.0), CoverEvapFactor(0.0),
142 13 : CoverConvFactor(0.0), CoverSWRadFactor(0.0), CoverLWRadFactor(0.0), CurCoverEvapFac(0.0), CurCoverConvFac(0.0), CurCoverSWRadFac(0.0),
143 13 : CurCoverLWRadFac(0.0), RadConvertToConvect(0.0), MiscPowerFactor(0.0), CurSetPtTemp(23.0), MaxNumOfPeople(0.0), PeopleHeatGain(0.0),
144 13 : WaterMass(0.0), SatPressPoolWaterTemp(0.0), PartPressZoneAirTemp(0.0), PoolWaterTemp(23.0), WaterInletTemp(0.0), WaterOutletTemp(0.0),
145 13 : WaterMassFlowRate(0.0), MakeUpWaterMassFlowRate(0.0), MakeUpWaterMass(0.0), MakeUpWaterVolFlowRate(0.0), MakeUpWaterVol(0.0),
146 13 : HeatPower(0.0), HeatEnergy(0.0), MiscEquipPower(0.0), MiscEquipEnergy(0.0), RadConvertToConvectRep(0.0), EvapHeatLossRate(0.0),
147 13 : EvapEnergyLoss(0.0), MyOneTimeFlag(true), MyEnvrnFlagGeneral(true), MyPlantScanFlagPool(true), QPoolSrcAvg(0.0), HeatTransCoefsAvg(0.0),
148 13 : ZeroPoolSourceSumHATsurf(0.0), LastQPoolSrc(0.0), LastHeatTransCoefs(0.0), LastSysTimeElapsed(0.0), LastTimeStepSys(0.0)
149 : {
150 13 : }
151 :
152 : static SwimmingPoolData *factory(EnergyPlusData &state, std::string const &objectName);
153 :
154 : void simulate([[maybe_unused]] EnergyPlusData &state,
155 : const PlantLocation &calledFromLocation,
156 : bool FirstHVACIteration,
157 : Real64 &CurLoad,
158 : bool RunFlag) override;
159 :
160 : void ErrorCheckSetupPoolSurface(
161 : EnergyPlusData &state, std::string_view Alpha1, std::string_view Alpha2, std::string_view cAlphaField2, bool &ErrorsFound);
162 :
163 : void initialize(EnergyPlusData &state, bool FirstHVACIteration // true during the first HVAC iteration
164 : );
165 :
166 : void setupOutputVars(EnergyPlusData &state);
167 :
168 : void initSwimmingPoolPlantLoopIndex(EnergyPlusData &state);
169 :
170 : void initSwimmingPoolPlantNodeFlow(EnergyPlusData &state) const;
171 :
172 : void calculate(EnergyPlusData &state);
173 :
174 : void calcMassFlowRate(EnergyPlusData &state,
175 : Real64 &massFlowRate, // Mass Flow Rate (to be calculated)
176 : Real64 TH22, // Pool water temperature from previous time step
177 : Real64 TLoopInletTemp //
178 : );
179 :
180 : void calcSwimmingPoolEvap(EnergyPlusData &state,
181 : Real64 &EvapRate, // Evaporation rate
182 : int SurfNum, // Surface index
183 : Real64 MAT, // mean air temperature
184 : Real64 HumRat // zone air humidity ratio
185 : );
186 :
187 : void update(EnergyPlusData &state);
188 :
189 : void oneTimeInit(EnergyPlusData &state) override;
190 :
191 : void oneTimeInit_new(EnergyPlusData &state) override;
192 :
193 : void report(EnergyPlusData &state);
194 : };
195 :
196 : void GetSwimmingPool(EnergyPlusData &state);
197 :
198 : void UpdatePoolSourceValAvg(EnergyPlusData &state, bool &SwimmingPoolOn); // .TRUE. if the swimming pool has "run" this zone time step
199 :
200 : Real64 MakeUpWaterVolFlowFunct(Real64 MakeUpWaterMassFlowRate, Real64 Density);
201 :
202 : Real64 MakeUpWaterVolFunct(Real64 MakeUpWaterMass, Real64 Density);
203 :
204 : } // namespace SwimmingPool
205 :
206 : struct SwimmingPoolsData : BaseGlobalStruct
207 : {
208 :
209 : // MODULE VARIABLE DECLARATIONS:
210 : int NumSwimmingPools = 0; // Number of swimming pools
211 : Array1D_bool CheckEquipName;
212 : bool getSwimmingPoolInput = true;
213 : Array1D<SwimmingPool::SwimmingPoolData> Pool;
214 :
215 2126 : void init_constant_state([[maybe_unused]] EnergyPlusData &state) override
216 : {
217 2126 : }
218 :
219 1152 : void init_state([[maybe_unused]] EnergyPlusData &state) override
220 : {
221 1152 : }
222 :
223 2100 : void clear_state() override
224 : {
225 2100 : NumSwimmingPools = 0;
226 2100 : getSwimmingPoolInput = true;
227 2100 : CheckEquipName.deallocate();
228 2100 : Pool.deallocate();
229 2100 : }
230 :
231 : // Default Constructor
232 2129 : SwimmingPoolsData() = default;
233 : };
234 : } // namespace EnergyPlus
235 :
236 : #endif
|