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 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 774 : 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 : Array1D<Real64> QPoolSrcAvg; // Average source over the time step for a particular radiant surface
134 : Array1D<Real64> HeatTransCoefsAvg; // Average denominator term over the time step for a particular pool
135 : Array1D<Real64> ZeroSourceSumHATsurf; // Equal to SumHATsurf for all the walls in a zone with no source
136 : // Record keeping variables used to calculate QRadSysSrcAvg locally
137 : Array1D<Real64> LastQPoolSrc; // Need to keep the last value in case we are still iterating
138 : Array1D<Real64> LastHeatTransCoefs; // Need to keep the last value in case we are still iterating
139 : Array1D<Real64> LastSysTimeElapsed; // Need to keep the last value in case we are still iterating
140 : Array1D<Real64> LastTimeStepSys; // Need to keep the last value in case we are still iterating
141 :
142 : // Default Constructor
143 770 : SwimmingPoolData()
144 770 : : SurfacePtr(0), ZonePtr(0), WaterInletNode(0), WaterOutletNode(0), HWplantLoc{}, WaterVolFlowMax(0.0), WaterMassFlowRateMax(0.0),
145 : AvgDepth(0.0), ActivityFactor(0.0), ActivityFactorSchedPtr(0), CurActivityFactor(0.0), MakeupWaterSupplySchedPtr(0),
146 : CurMakeupWaterTemp(0.0), CoverSchedPtr(0), CurCoverSchedVal(0.0), CoverEvapFactor(0.0), CoverConvFactor(0.0), CoverSWRadFactor(0.0),
147 : CoverLWRadFactor(0.0), CurCoverEvapFac(0.0), CurCoverConvFac(0.0), CurCoverSWRadFac(0.0), CurCoverLWRadFac(0.0),
148 : RadConvertToConvect(0.0), MiscPowerFactor(0.0), SetPtTempSchedPtr(0), CurSetPtTemp(23.0), MaxNumOfPeople(0.0), PeopleSchedPtr(0),
149 : PeopleHeatGainSchedPtr(0), PeopleHeatGain(0.0), GlycolIndex(0), WaterMass(0.0), SatPressPoolWaterTemp(0.0), PartPressZoneAirTemp(0.0),
150 : PoolWaterTemp(23.0), WaterInletTemp(0.0), WaterOutletTemp(0.0), WaterMassFlowRate(0.0), MakeUpWaterMassFlowRate(0.0),
151 : MakeUpWaterMass(0.0), MakeUpWaterVolFlowRate(0.0), MakeUpWaterVol(0.0), HeatPower(0.0), HeatEnergy(0.0), MiscEquipPower(0.0),
152 : MiscEquipEnergy(0.0), RadConvertToConvectRep(0.0), EvapHeatLossRate(0.0), EvapEnergyLoss(0.0), MyOneTimeFlag(true),
153 770 : MyEnvrnFlagGeneral(true), MyPlantScanFlagPool(true)
154 : {
155 770 : }
156 :
157 : void simulate([[maybe_unused]] EnergyPlusData &state,
158 : const PlantLocation &calledFromLocation,
159 : bool FirstHVACIteration,
160 : Real64 &CurLoad,
161 : bool RunFlag) override;
162 :
163 : void ErrorCheckSetupPoolSurface(
164 : EnergyPlusData &state, std::string_view Alpha1, std::string_view Alpha2, std::string_view cAlphaField2, bool &ErrorsFound);
165 :
166 : void initialize(EnergyPlusData &state, bool FirstHVACIteration // true during the first HVAC iteration
167 : );
168 :
169 : void setupOutputVars(EnergyPlusData &state);
170 :
171 : void initSwimmingPoolPlantLoopIndex(EnergyPlusData &state);
172 :
173 : void initSwimmingPoolPlantNodeFlow(EnergyPlusData &state) const;
174 :
175 : void calculate(EnergyPlusData &state);
176 :
177 : void calcSwimmingPoolEvap(EnergyPlusData &state,
178 : Real64 &EvapRate, // Evaporation rate
179 : int SurfNum, // Surface index
180 : Real64 MAT, // mean air temperature
181 : Real64 HumRat // zone air humidity ratio
182 : );
183 :
184 : void update(EnergyPlusData &state);
185 :
186 : void oneTimeInit(EnergyPlusData &state) override;
187 :
188 : void oneTimeInit_new(EnergyPlusData &state) override;
189 : };
190 :
191 : void GetSwimmingPool(EnergyPlusData &state);
192 :
193 : void SimSwimmingPool(EnergyPlusData &state, bool FirstHVACIteration);
194 :
195 : void UpdatePoolSourceValAvg(EnergyPlusData &state, bool &SwimmingPoolOn); // .TRUE. if the swimming pool has "run" this zone time step
196 :
197 : void ReportSwimmingPool(EnergyPlusData &state);
198 :
199 : Real64 MakeUpWaterVolFlowFunct(Real64 MakeUpWaterMassFlowRate, Real64 Density);
200 :
201 : Real64 MakeUpWaterVolFunct(Real64 MakeUpWaterMass, Real64 Density);
202 :
203 : } // namespace SwimmingPool
204 :
205 771 : struct SwimmingPoolsData : BaseGlobalStruct
206 : {
207 :
208 : // MODULE VARIABLE DECLARATIONS:
209 : int NumSwimmingPools = 0; // Number of swimming pools
210 : Array1D_bool CheckEquipName;
211 : bool getSwimmingPoolInput = true;
212 : Array1D<SwimmingPool::SwimmingPoolData> Pool;
213 :
214 0 : void clear_state() override
215 : {
216 0 : NumSwimmingPools = 0;
217 0 : getSwimmingPoolInput = true;
218 0 : CheckEquipName.deallocate();
219 0 : Pool.deallocate();
220 0 : }
221 :
222 : // Default Constructor
223 771 : SwimmingPoolsData() = default;
224 : };
225 : } // namespace EnergyPlus
226 :
227 : #endif
|