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 FluidProperties_hh_INCLUDED
49 : #define FluidProperties_hh_INCLUDED
50 :
51 : // C++ Headers
52 : #include <cmath>
53 :
54 : // ObjexxFCL Headers
55 : #include <ObjexxFCL/Array1D.hh>
56 : #include <ObjexxFCL/Array2D.hh>
57 : #include <ObjexxFCL/Array2S.hh>
58 :
59 : // EnergyPlus Headers
60 : #include <EnergyPlus/Data/BaseData.hh>
61 : #include <EnergyPlus/DataGlobals.hh>
62 : #include <EnergyPlus/EnergyPlus.hh>
63 : #include <EnergyPlus/Psychrometrics.hh>
64 :
65 : namespace EnergyPlus {
66 :
67 : // Forward declarations
68 : struct EnergyPlusData;
69 :
70 : namespace FluidProperties {
71 :
72 : // Using/Aliasing
73 :
74 : // Data
75 : // MODULE PARAMETER DEFINITIONS
76 :
77 : int constexpr EthyleneGlycolIndex = -2;
78 : int constexpr PropyleneGlycolIndex = -1;
79 : int constexpr iRefri = 1;
80 : int constexpr iGlyco = 1;
81 :
82 : constexpr int DefaultNumGlyTemps(33); // Temperature dimension of default glycol data
83 : constexpr int DefaultNumGlyConcs(10); // Concentration dimension of default glycol data
84 : constexpr int DefaultNumSteamTemps(111); // Temperature dimension of default steam data.
85 : constexpr int DefaultNumSteamSuperheatedTemps(114); // Temperature dimension of default steam data.
86 : constexpr int DefaultNumSteamSuperheatedPressure(114); // Temperature dimension of default steam data.
87 :
88 : constexpr static std::string_view Refrig("REFRIGERANT");
89 : constexpr static std::string_view Glycol("GLYCOL");
90 : constexpr static std::string_view Pressure("PRESSURE");
91 : constexpr static std::string_view Enthalpy("ENTHALPY");
92 : constexpr static std::string_view Density("DENSITY");
93 : constexpr static std::string_view SpecificHeat("SPECIFICHEAT");
94 : constexpr static std::string_view Conductivity("CONDUCTIVITY");
95 : constexpr static std::string_view Viscosity("VISCOSITY");
96 : constexpr static std::string_view Fluid("FLUID");
97 : constexpr static std::string_view GasFluid("FLUIDGAS");
98 : constexpr static std::string_view Water("Water");
99 : constexpr static std::string_view Steam("Steam");
100 : constexpr static std::string_view EthyleneGlycol("EthyleneGlycol");
101 : constexpr static std::string_view PropyleneGlycol("PropyleneGlycol");
102 :
103 : // DERIVED TYPE DEFINITIONS
104 :
105 : // INTERFACE BLOCK SPECIFICATIONS
106 : // na
107 :
108 : // MODULE VARIABLE DECLARATIONS
109 :
110 : #ifdef EP_cache_GlycolSpecificHeat
111 : int constexpr t_sh_cache_size = 1024 * 1024;
112 : int constexpr t_sh_precision_bits = 24;
113 : std::uint64_t constexpr t_sh_cache_mask = (t_sh_cache_size - 1);
114 : #endif
115 : // ACCESSIBLE SPECIFICATIONS OF MODULE SUBROUTINES OR FUNCTIONS:
116 :
117 : // Types
118 :
119 1463 : struct FluidPropsRefrigerantData
120 : {
121 : // Members
122 : std::string Name; // Name of the refrigerant
123 : int NumPsPoints; // Number of saturation pressure
124 : Real64 PsLowTempValue; // Low Temperature Value for Ps (>0.0)
125 : Real64 PsHighTempValue; // High Temperature Value for Ps (max in tables)
126 : int PsLowTempIndex; // Low Temperature Min Index for Ps (>0.0)
127 : int PsHighTempIndex; // High Temperature Max Index for Ps (>0.0)
128 : Real64 PsLowPresValue; // Low Pressure Value for Ps (>0.0)
129 : Real64 PsHighPresValue; // High Pressure Value for Ps (max in tables)
130 : int PsLowPresIndex; // Low Pressure Min Index for Ps (>0.0)
131 : int PsHighPresIndex; // High Pressure Max Index for Ps (>0.0)
132 : Array1D<Real64> PsTemps; // Temperatures for saturation pressures
133 : Array1D<Real64> PsValues; // Saturation pressures at PsTemps
134 : int NumHPoints; // Number of enthalpy points
135 : Real64 HfLowTempValue; // Low Temperature Value for Hf (>0.0)
136 : Real64 HfHighTempValue; // High Temperature Value for Hf (max in tables)
137 : int HfLowTempIndex; // Low Temperature Min Index for Hf (>0.0)
138 : int HfHighTempIndex; // High Temperature Max Index for Hf (>0.0)
139 : Real64 HfgLowTempValue; // Low Temperature Value for Hfg (>0.0)
140 : Real64 HfgHighTempValue; // High Temperature Value for Hfg (max in tables)
141 : int HfgLowTempIndex; // Low Temperature Min Index for Hfg (>0.0)
142 : int HfgHighTempIndex; // High Temperature Max Index for Hfg (>0.0)
143 : Array1D<Real64> HTemps; // Temperatures for enthalpy points
144 : Array1D<Real64> HfValues; // Enthalpy of saturated fluid at HTemps
145 : Array1D<Real64> HfgValues; // Enthalpy of saturated fluid/gas at HTemps
146 : int NumCpPoints; // Number of specific heat of fluid points
147 : Real64 CpfLowTempValue; // Low Temperature Value for Cpf (>0.0)
148 : Real64 CpfHighTempValue; // High Temperature Value for Cpf (max in tables)
149 : int CpfLowTempIndex; // Low Temperature Min Index for Cpf (>0.0)
150 : int CpfHighTempIndex; // High Temperature Max Index for Cpf (>0.0)
151 : Real64 CpfgLowTempValue; // Low Temperature Value for Cpfg (>0.0)
152 : Real64 CpfgHighTempValue; // High Temperature Value for Cpfg (max in tables)
153 : int CpfgLowTempIndex; // Low Temperature Min Index for Cpfg (>0.0)
154 : int CpfgHighTempIndex; // High Temperature Max Index for Cpfg (>0.0)
155 : Array1D<Real64> CpTemps; // Temperatures for specific heat points
156 : Array1D<Real64> CpfValues; // Specific heat of saturated fluid at CpTemps
157 : Array1D<Real64> CpfgValues; // Specific heat of saturated fluid/gas at CpTemps
158 : int NumRhoPoints; // Number of density of fluid points
159 : Real64 RhofLowTempValue; // Low Temperature Value for Rhof (>0.0)
160 : Real64 RhofHighTempValue; // High Temperature Value for Rhof (max in tables)
161 : int RhofLowTempIndex; // Low Temperature Min Index for Rhof (>0.0)
162 : int RhofHighTempIndex; // High Temperature Max Index for Rhof (>0.0)
163 : Real64 RhofgLowTempValue; // Low Temperature Value for Rhofg (>0.0)
164 : Real64 RhofgHighTempValue; // High Temperature Value for Rhofg (max in tables)
165 : int RhofgLowTempIndex; // Low Temperature Min Index for Rhofg (>0.0)
166 : int RhofgHighTempIndex; // High Temperature Max Index for Rhofg (>0.0)
167 : Array1D<Real64> RhoTemps; // Temperatures for density of fluid points
168 : Array1D<Real64> RhofValues; // Density of saturated fluid at RhoTemps
169 : Array1D<Real64> RhofgValues; // Density of saturated fluid/gas at RhoTemps
170 : int NumSuperTempPts; // Number of temperature points for superheated enthalpy
171 : int NumSuperPressPts; // Number of pressure points for superheated enthalpy
172 : Array1D<Real64> SHTemps; // Temperatures for superheated gas
173 : Array1D<Real64> SHPress; // Pressures for superheated gas
174 : Array2D<Real64> HshValues; // Enthalpy of superheated gas at HshTemps, HshPress
175 : Array2D<Real64> RhoshValues; // Density of superheated gas at HshTemps, HshPress
176 :
177 : // Default Constructor
178 469 : FluidPropsRefrigerantData()
179 469 : : NumPsPoints(0), PsLowTempValue(0.0), PsHighTempValue(0.0), PsLowTempIndex(0), PsHighTempIndex(0), PsLowPresValue(0.0),
180 : PsHighPresValue(0.0), PsLowPresIndex(0), PsHighPresIndex(0), NumHPoints(0), HfLowTempValue(0.0), HfHighTempValue(0.0),
181 : HfLowTempIndex(0), HfHighTempIndex(0), HfgLowTempValue(0.0), HfgHighTempValue(0.0), HfgLowTempIndex(0), HfgHighTempIndex(0),
182 : NumCpPoints(0), CpfLowTempValue(0.0), CpfHighTempValue(0.0), CpfLowTempIndex(0), CpfHighTempIndex(0), CpfgLowTempValue(0.0),
183 : CpfgHighTempValue(0.0), CpfgLowTempIndex(0), CpfgHighTempIndex(0), NumRhoPoints(0), RhofLowTempValue(0.0), RhofHighTempValue(0.0),
184 : RhofLowTempIndex(0), RhofHighTempIndex(0), RhofgLowTempValue(0.0), RhofgHighTempValue(0.0), RhofgLowTempIndex(0), RhofgHighTempIndex(0),
185 469 : NumSuperTempPts(0), NumSuperPressPts(0)
186 : {
187 469 : }
188 : };
189 :
190 33 : struct FluidPropsGlycolRawData
191 : {
192 : // Members
193 : std::string Name; // Name of the glycol
194 : bool CpDataPresent; // Flag set when specific heat data is available
195 : int NumCpTempPts; // Number of temperature points for specific heat
196 : int NumCpConcPts; // Number of concentration points for specific heat
197 : Array1D<Real64> CpTemps; // Temperatures for specific heat of glycol
198 : Array1D<Real64> CpConcs; // Concentration for specific heat of glycol
199 : Array2D<Real64> CpValues; // Specific heat data values
200 : bool RhoDataPresent; // Flag set when density data is available
201 : int NumRhoTempPts; // Number of temperature points for density
202 : int NumRhoConcPts; // Number of concentration points for density
203 : Array1D<Real64> RhoTemps; // Temperatures for density of glycol
204 : Array1D<Real64> RhoConcs; // Concentration for density of glycol
205 : Array2D<Real64> RhoValues; // Density data values
206 : bool CondDataPresent; // Flag set when conductivity data is available
207 : int NumCondTempPts; // Number of temperature points for conductivity
208 : int NumCondConcPts; // Number of concentration points for conductivity
209 : Array1D<Real64> CondTemps; // Temperatures for conductivity of glycol
210 : Array1D<Real64> CondConcs; // Concentration for conductivity of glycol
211 : Array2D<Real64> CondValues; // conductivity values
212 : bool ViscDataPresent; // Flag set when viscosity data is available
213 : int NumViscTempPts; // Number of temperature points for viscosity
214 : int NumViscConcPts; // Number of concentration points for viscosity
215 : Array1D<Real64> ViscTemps; // Temperatures for viscosity of glycol
216 : Array1D<Real64> ViscConcs; // Concentration for viscosity of glycol
217 : Array2D<Real64> ViscValues; // viscosity values
218 :
219 : // Default Constructor
220 11 : FluidPropsGlycolRawData()
221 11 : : CpDataPresent(false), NumCpTempPts(0), NumCpConcPts(0), RhoDataPresent(false), NumRhoTempPts(0), NumRhoConcPts(0),
222 11 : CondDataPresent(false), NumCondTempPts(0), NumCondConcPts(0), ViscDataPresent(false), NumViscTempPts(0), NumViscConcPts(0)
223 : {
224 11 : }
225 : };
226 :
227 1463 : struct FluidPropsGlycolData
228 : {
229 : // Members
230 : std::string Name; // Name of the glycol mixture (used by other parts of code)
231 : std::string GlycolName; // Name of non-water fluid that is part of this mixture
232 : // (refers to ethylene glycol, propylene glycol, or user fluid)
233 : int GlycolIndex; // Index in user defined glycol data (>0 = index in raw data,
234 : // -1=propylene glycol, -2=ethylene glycol)
235 : Real64 Concentration; // Concentration (if applicable)
236 : bool CpDataPresent; // Flag set when specific heat data is available
237 : Real64 CpLowTempValue; // Low Temperature Value for Cp (>0.0)
238 : Real64 CpHighTempValue; // High Temperature Value for Cp (max in tables)
239 : int CpLowTempIndex; // Low Temperature Min Index for Cp (>0.0)
240 : int CpHighTempIndex; // High Temperature Max Index for Cp (>0.0)
241 : int NumCpTempPts; // Number of temperature points for specific heat
242 : Array1D<Real64> CpTemps; // Temperatures for specific heat of glycol
243 : Array1D<Real64> CpValues; // Specific heat data values (J/kg-K)
244 : bool RhoDataPresent; // Flag set when density data is available
245 : int NumRhoTempPts; // Number of temperature points for density
246 : Real64 RhoLowTempValue; // Low Temperature Value for Rho (>0.0)
247 : Real64 RhoHighTempValue; // High Temperature Value for Rho (max in tables)
248 : int RhoLowTempIndex; // Low Temperature Min Index for Rho (>0.0)
249 : int RhoHighTempIndex; // High Temperature Max Index for Rho (>0.0)
250 : Array1D<Real64> RhoTemps; // Temperatures for density of glycol
251 : Array1D<Real64> RhoValues; // Density data values (kg/m3)
252 : bool CondDataPresent; // Flag set when conductivity data is available
253 : int NumCondTempPts; // Number of temperature points for conductivity
254 : Real64 CondLowTempValue; // Low Temperature Value for Cond (>0.0)
255 : Real64 CondHighTempValue; // High Temperature Value for Cond (max in tables)
256 : int CondLowTempIndex; // Low Temperature Min Index for Cond (>0.0)
257 : int CondHighTempIndex; // High Temperature Max Index for Cond (>0.0)
258 : Array1D<Real64> CondTemps; // Temperatures for conductivity of glycol
259 : Array1D<Real64> CondValues; // conductivity values (W/m-K)
260 : bool ViscDataPresent; // Flag set when viscosity data is available
261 : int NumViscTempPts; // Number of temperature points for viscosity
262 : Real64 ViscLowTempValue; // Low Temperature Value for Visc (>0.0)
263 : Real64 ViscHighTempValue; // High Temperature Value for Visc (max in tables)
264 : int ViscLowTempIndex; // Low Temperature Min Index for Visc (>0.0)
265 : int ViscHighTempIndex; // High Temperature Max Index for Visc (>0.0)
266 : Array1D<Real64> ViscTemps; // Temperatures for viscosity of glycol
267 : Array1D<Real64> ViscValues; // viscosity values (mPa-s)
268 :
269 : // Default Constructor
270 469 : FluidPropsGlycolData()
271 469 : : GlycolIndex(0), Concentration(1.0), CpDataPresent(false), CpLowTempValue(0.0), CpHighTempValue(0.0), CpLowTempIndex(0),
272 : CpHighTempIndex(0), NumCpTempPts(0), RhoDataPresent(false), NumRhoTempPts(0), RhoLowTempValue(0.0), RhoHighTempValue(0.0),
273 : RhoLowTempIndex(0), RhoHighTempIndex(0), CondDataPresent(false), NumCondTempPts(0), CondLowTempValue(0.0), CondHighTempValue(0.0),
274 : CondLowTempIndex(0), CondHighTempIndex(0), ViscDataPresent(false), NumViscTempPts(0), ViscLowTempValue(0.0), ViscHighTempValue(0.0),
275 469 : ViscLowTempIndex(0), ViscHighTempIndex(0)
276 : {
277 469 : }
278 : };
279 :
280 1463 : struct FluidPropsRefrigErrors
281 : {
282 : // Members
283 : std::string Name;
284 : int SatTempErrIndex; // Index for Sat Temperature Error (Recurring errors)
285 : int SatTempErrCount; // Count for Sat Temperature Error (Recurring errors)
286 : int SatPressErrIndex; // Index for Sat Pressure Error (Recurring errors)
287 : int SatPressErrCount; // Count for Sat Pressure Error (Recurring errors)
288 : int SatTempDensityErrIndex; // Index for Sat Temperature (Density) Error (Recurring errors)
289 : int SatTempDensityErrCount; // Count for Sat Temperature (Density) Error (Recurring errors)
290 : int SatSupEnthalpyErrIndex; // Index for Sat Temperature (Density) Error (Recurring errors)
291 : int SatSupEnthalpyErrCount; // Count for Sat Temperature (Density) Error (Recurring errors)
292 : int SatSupEnthalpyTempErrIndex; // Index for Sat Temperature (Density) Error (Recurring errors)
293 : int SatSupEnthalpyTempErrCount; // Count for Sat Temperature (Density) Error (Recurring errors)
294 : int SatSupEnthalpyPresErrIndex; // Index for Sat Temperature (Density) Error (Recurring errors)
295 : int SatSupEnthalpyPresErrCount; // Count for Sat Temperature (Density) Error (Recurring errors)
296 : int SatSupPressureErrIndex; // Index for Sat Temperature (Density) Error (Recurring errors)
297 : int SatSupPressureErrCount; // Count for Sat Temperature (Density) Error (Recurring errors)
298 : int SatSupPressureTempErrIndex; // Index for Sat Temperature (Density) Error (Recurring errors)
299 : int SatSupPressureTempErrCount; // Count for Sat Temperature (Density) Error (Recurring errors)
300 : int SatSupPressureEnthErrIndex; // Index for Sat Temperature (Density) Error (Recurring errors)
301 : int SatSupPressureEnthErrCount; // Count for Sat Temperature (Density) Error (Recurring errors)
302 : int SatSupDensityErrIndex; // Index for Sat Temperature (Density) Error (Recurring errors)
303 : int SatSupDensityErrCount; // Count for Sat Temperature (Density) Error (Recurring errors)
304 : int SatSupDensityTempErrIndex; // Index for Sat Temperature (Density) Error (Recurring errors)
305 : int SatSupDensityTempErrCount; // Count for Sat Temperature (Density) Error (Recurring errors)
306 : int SatSupDensityPresErrIndex; // Index for Sat Temperature (Density) Error (Recurring errors)
307 : int SatSupDensityPresErrCount; // Count for Sat Temperature (Density) Error (Recurring errors)
308 :
309 : // Default Constructor
310 469 : FluidPropsRefrigErrors()
311 469 : : SatTempErrIndex(0), SatTempErrCount(0), SatPressErrIndex(0), SatPressErrCount(0), SatTempDensityErrIndex(0), SatTempDensityErrCount(0),
312 : SatSupEnthalpyErrIndex(0), SatSupEnthalpyErrCount(0), SatSupEnthalpyTempErrIndex(0), SatSupEnthalpyTempErrCount(0),
313 : SatSupEnthalpyPresErrIndex(0), SatSupEnthalpyPresErrCount(0), SatSupPressureErrIndex(0), SatSupPressureErrCount(0),
314 : SatSupPressureTempErrIndex(0), SatSupPressureTempErrCount(0), SatSupPressureEnthErrIndex(0), SatSupPressureEnthErrCount(0),
315 : SatSupDensityErrIndex(0), SatSupDensityErrCount(0), SatSupDensityTempErrIndex(0), SatSupDensityTempErrCount(0),
316 469 : SatSupDensityPresErrIndex(0), SatSupDensityPresErrCount(0)
317 : {
318 469 : }
319 : };
320 :
321 1463 : struct FluidPropsGlycolErrors
322 : {
323 : // Members
324 : std::string Name; // Which glycol this error structure is for
325 : int SpecHeatLowErrIndex; // Index for Specific Heat Low Error (Recurring errors)
326 : int SpecHeatHighErrIndex; // Index for Specific Heat High Error (Recurring errors)
327 : int SpecHeatLowErrCount; // Count for Specific Heat Low Error (Recurring errors)
328 : int SpecHeatHighErrCount; // Count for Specific Heat High Error (Recurring errors)
329 : int DensityHighErrCount; // Index for Density Low Error (Recurring errors)
330 : int DensityLowErrIndex; // Index for Density High Error (Recurring errors)
331 : int DensityHighErrIndex; // Count for Density Low Error (Recurring errors)
332 : int DensityLowErrCount; // Count for Density High Error (Recurring errors)
333 : int ConductivityLowErrIndex; // Index for Conductivity Low Error (Recurring errors)
334 : int ConductivityHighErrIndex; // Index for Conductivity High Error (Recurring errors)
335 : int ConductivityLowErrCount; // Count for Conductivity Low Error (Recurring errors)
336 : int ConductivityHighErrCount; // Count for Conductivity High Error (Recurring errors)
337 : int ViscosityLowErrIndex; // Index for Viscosity Low Error (Recurring errors)
338 : int ViscosityHighErrIndex; // Index for Viscosity High Error (Recurring errors)
339 : int ViscosityLowErrCount; // Count for Viscosity Low Error (Recurring errors)
340 : int ViscosityHighErrCount; // Count for Viscosity High Error (Recurring errors)
341 :
342 : // Default Constructor
343 469 : FluidPropsGlycolErrors()
344 469 : : SpecHeatLowErrIndex(0), SpecHeatHighErrIndex(0), SpecHeatLowErrCount(0), SpecHeatHighErrCount(0), DensityHighErrCount(0),
345 : DensityLowErrIndex(0), DensityHighErrIndex(0), DensityLowErrCount(0), ConductivityLowErrIndex(0), ConductivityHighErrIndex(0),
346 : ConductivityLowErrCount(0), ConductivityHighErrCount(0), ViscosityLowErrIndex(0), ViscosityHighErrIndex(0), ViscosityLowErrCount(0),
347 469 : ViscosityHighErrCount(0)
348 : {
349 469 : }
350 : };
351 :
352 : struct cached_tsh
353 : {
354 : // Members
355 : std::uint64_t iT;
356 : Real64 sh;
357 :
358 : // Default Constructor
359 808452565 : cached_tsh() : iT(1000), sh(0.0)
360 : {
361 808452565 : }
362 : };
363 :
364 : #ifdef EP_cache_GlycolSpecificHeat
365 : extern std::array<FluidProperties::cached_tsh, t_sh_cache_size> cached_t_sh;
366 : #endif
367 : // Object Data
368 :
369 : // Functions
370 :
371 : void InitializeGlycRoutines();
372 :
373 : void GetFluidPropertiesData(EnergyPlusData &state);
374 :
375 : //*****************************************************************************
376 :
377 : template <size_t NumOfTemps, size_t NumOfConcs>
378 : void InterpDefValuesForGlycolConc(
379 : EnergyPlusData &state,
380 : const std::array<Real64, NumOfConcs> &RawConcData, // concentrations for raw data
381 : const std::array<std::array<Real64, NumOfTemps>, NumOfConcs> &RawPropData, // raw property data (concentration, temperature)
382 : Real64 Concentration, // concentration of actual fluid mix
383 : Array1D<Real64> &InterpData // interpolated output data at proper concentration
384 : );
385 :
386 : //*****************************************************************************
387 :
388 : void InterpValuesForGlycolConc(EnergyPlusData &state,
389 : int NumOfConcs, // number of concentrations (dimension of raw data)
390 : int NumOfTemps, // number of temperatures (dimension of raw data)
391 : const Array1D<Real64> &RawConcData, // concentrations for raw data
392 : Array2S<Real64> RawPropData, // raw property data (temperature,concentration)
393 : Real64 Concentration, // concentration of actual fluid mix
394 : Array1D<Real64> &InterpData // interpolated output data at proper concentration
395 : );
396 :
397 : //*****************************************************************************
398 :
399 : void InitializeGlycolTempLimits(EnergyPlusData &state, bool &ErrorsFound); // set to true if errors found here
400 :
401 : //*****************************************************************************
402 :
403 : void InitializeRefrigerantLimits(EnergyPlusData &state, bool &ErrorsFound); // set to true if errors found here
404 :
405 : //*****************************************************************************
406 :
407 : void ReportAndTestGlycols(EnergyPlusData &state);
408 :
409 : //*****************************************************************************
410 :
411 : void ReportAndTestRefrigerants(EnergyPlusData &state);
412 :
413 : //*****************************************************************************
414 :
415 : Real64 GetSatPressureRefrig(EnergyPlusData &state,
416 : std::string_view const Refrigerant, // carries in substance name
417 : Real64 Temperature, // actual temperature given as input
418 : int &RefrigIndex, // Index to Refrigerant Properties
419 : std::string_view const CalledFrom // routine this function was called from (error messages)
420 : );
421 :
422 : //*****************************************************************************
423 :
424 : Real64 GetSatTemperatureRefrig(EnergyPlusData &state,
425 : std::string_view const Refrigerant, // carries in substance name
426 : Real64 Pressure, // actual temperature given as input
427 : int &RefrigIndex, // Index to Refrigerant Properties
428 : std::string_view const CalledFrom // routine this function was called from (error messages)
429 : );
430 :
431 : //*****************************************************************************
432 :
433 : Real64 GetSatEnthalpyRefrig(EnergyPlusData &state,
434 : std::string_view const Refrigerant, // carries in substance name
435 : Real64 Temperature, // actual temperature given as input
436 : Real64 Quality, // actual quality given as input
437 : int &RefrigIndex, // Index to Refrigerant Properties
438 : std::string_view const CalledFrom // routine this function was called from (error messages)
439 : );
440 :
441 : //*****************************************************************************
442 :
443 : Real64 GetSatDensityRefrig(EnergyPlusData &state,
444 : std::string_view const Refrigerant, // carries in substance name
445 : Real64 Temperature, // actual temperature given as input
446 : Real64 Quality, // actual quality given as input
447 : int &RefrigIndex, // Index to Refrigerant Properties
448 : std::string_view const CalledFrom // routine this function was called from (error messages)
449 : );
450 :
451 : //*****************************************************************************
452 :
453 : Real64 GetSatSpecificHeatRefrig(EnergyPlusData &state,
454 : std::string_view const Refrigerant, // carries in substance name
455 : Real64 Temperature, // actual temperature given as input
456 : Real64 Quality, // actual quality given as input
457 : int &RefrigIndex, // Index to Refrigerant Properties
458 : std::string_view const CalledFrom // routine this function was called from (error messages)
459 : );
460 :
461 : //*****************************************************************************
462 :
463 : Real64 GetSupHeatEnthalpyRefrig(EnergyPlusData &state,
464 : std::string_view const Refrigerant, // carries in substance name
465 : Real64 Temperature, // actual temperature given as input
466 : Real64 Pressure, // actual pressure given as input
467 : int &RefrigIndex, // Index to Refrigerant Properties
468 : std::string_view const CalledFrom // routine this function was called from (error messages)
469 : );
470 :
471 : //*****************************************************************************
472 :
473 : Real64 GetSupHeatPressureRefrig(EnergyPlusData &state,
474 : std::string_view const Refrigerant, // carries in substance name
475 : Real64 Temperature, // actual temperature given as input
476 : Real64 Enthalpy, // actual enthalpy given as input
477 : int &RefrigIndex, // Index to Refrigerant Properties
478 : std::string_view const CalledFrom // routine this function was called from (error messages)
479 : );
480 :
481 : //*****************************************************************************
482 :
483 : Real64 GetSupHeatTempRefrig(EnergyPlusData &state,
484 : std::string_view const Refrigerant, // carries in substance name
485 : Real64 Pressure, // actual pressure given as input
486 : Real64 Enthalpy, // actual enthalpy given as input
487 : Real64 TempLow, // lower bound of temperature in the iteration
488 : Real64 TempUp, // upper bound of temperature in the iteration
489 : int &RefrigIndex, // Index to Refrigerant Properties
490 : std::string_view const CalledFrom // routine this function was called from (error messages)
491 : );
492 :
493 : Real64 GetSupHeatDensityRefrig(EnergyPlusData &state,
494 : std::string_view const Refrigerant, // carries in substance name
495 : Real64 Temperature, // actual temperature given as input
496 : Real64 Pressure, // actual pressure given as input
497 : int &RefrigIndex, // Index to Refrigerant Properties
498 : std::string_view const CalledFrom // routine this function was called from (error messages)
499 : );
500 :
501 : //*****************************************************************************
502 : #ifdef EP_cache_GlycolSpecificHeat
503 : Real64 GetSpecificHeatGlycol_raw(EnergyPlusData &state,
504 : std::string_view const Glycol, // carries in substance name
505 : Real64 const Temperature, // actual temperature given as input
506 : int &GlycolIndex, // Index to Glycol Properties
507 : std::string_view const CalledFrom // routine this function was called from (error messages)
508 : );
509 :
510 517139879 : inline Real64 GetSpecificHeatGlycol(EnergyPlusData &state,
511 : std::string_view const Glycol, // carries in substance name
512 : Real64 const Temperature, // actual temperature given as input
513 : int &GlycolIndex, // Index to Glycol Properties
514 : std::string_view const CalledFrom // routine this function was called from (error messages)
515 : )
516 : {
517 517139879 : std::uint64_t constexpr Grid_Shift = 64 - 12 - t_sh_precision_bits;
518 :
519 517139879 : double const t(Temperature + 1000 * GlycolIndex);
520 :
521 : DISABLE_WARNING_PUSH
522 : DISABLE_WARNING_STRICT_ALIASING
523 : DISABLE_WARNING_UNINITIALIZED
524 517139879 : std::uint64_t const T_tag(*reinterpret_cast<std::uint64_t const *>(&t) >> Grid_Shift);
525 : DISABLE_WARNING_POP
526 :
527 517139879 : std::uint64_t const hash(T_tag & t_sh_cache_mask);
528 517139879 : auto &cTsh(cached_t_sh[hash]);
529 :
530 517139879 : if (cTsh.iT != T_tag) {
531 21209813 : cTsh.iT = T_tag;
532 21209813 : cTsh.sh = GetSpecificHeatGlycol_raw(state, Glycol, Temperature, GlycolIndex, CalledFrom);
533 : }
534 :
535 517139879 : return cTsh.sh; // saturation pressure {Pascals}
536 : }
537 : #else
538 : Real64 GetSpecificHeatGlycol(EnergyPlusData &state,
539 : std::string_view const Glycol, // carries in substance name
540 : Real64 const Temperature, // actual temperature given as input
541 : int &GlycolIndex, // Index to Glycol Properties
542 : std::string_view const CalledFrom // routine this function was called from (error messages)
543 : );
544 : #endif
545 :
546 : //*****************************************************************************
547 :
548 : Real64 GetDensityGlycol(EnergyPlusData &state,
549 : std::string_view const Glycol, // carries in substance name
550 : Real64 Temperature, // actual temperature given as input
551 : int &GlycolIndex, // Index to Glycol Properties
552 : std::string_view const CalledFrom // routine this function was called from (error messages)
553 : );
554 :
555 : //*****************************************************************************
556 :
557 : Real64 GetConductivityGlycol(EnergyPlusData &state,
558 : std::string_view const Glycol, // carries in substance name
559 : Real64 Temperature, // actual temperature given as input
560 : int &GlycolIndex, // Index to Glycol Properties
561 : std::string_view const CalledFrom // routine this function was called from (error messages)
562 : );
563 :
564 : //*****************************************************************************
565 :
566 : Real64 GetViscosityGlycol(EnergyPlusData &state,
567 : std::string_view const Glycol, // carries in substance name
568 : Real64 Temperature, // actual temperature given as input
569 : int &GlycolIndex, // Index to Glycol Properties
570 : std::string_view const CalledFrom // routine this function was called from (error messages)
571 : );
572 :
573 : //*****************************************************************************
574 :
575 : void GetInterpValue_error(EnergyPlusData &state);
576 :
577 104365014 : inline Real64 GetInterpValue(EnergyPlusData &state,
578 : Real64 const Tact, // actual temperature at which we want the property of interest
579 : Real64 const Tlo, // temperature below Tact for which we have property data
580 : Real64 const Thi, // temperature above Tact for which we have property data
581 : Real64 const Xlo, // value of property at Tlo
582 : Real64 const Xhi // value of property at Thi
583 : )
584 : {
585 : // FUNCTION INFORMATION:
586 : // AUTHOR Rick Strand
587 : // DATE WRITTEN June 2004
588 : // MODIFIED N/A
589 : // RE-ENGINEERED N/A
590 :
591 : // PURPOSE OF THIS FUNCTION:
592 : // This subroutine does a simple linear interpolation.
593 :
594 : // METHODOLOGY EMPLOYED:
595 : // No mysteries here...just plain-old linear interpolation.
596 :
597 : // REFERENCES:
598 : // Any basic engineering mathematic text.
599 :
600 : // USE STATEMENTS:
601 : // na
602 :
603 : // Return value
604 : // na
605 :
606 : // Locals
607 : // FUNCTION ARGUMENT DEFINITIONS:
608 :
609 : // SUBROUTINE PARAMETER DEFINITIONS:
610 104365014 : Real64 constexpr TempToler(0.001); // Some reasonable value for comparisons
611 :
612 : // INTERFACE BLOCK SPECIFICATIONS:
613 : // na
614 :
615 : // DERIVED TYPE DEFINITIONS:
616 : // na
617 :
618 : // FUNCTION LOCAL VARIABLE DECLARATIONS:
619 : // na
620 :
621 104365014 : if (std::abs(Thi - Tlo) > TempToler) {
622 104365014 : return Xhi - (((Thi - Tact) / (Thi - Tlo)) * (Xhi - Xlo));
623 : } else {
624 0 : GetInterpValue_error(state);
625 0 : return 0.0;
626 : }
627 : }
628 :
629 21209702 : inline Real64 GetInterpValue_fast(Real64 const Tact, // actual temperature at which we want the property of interest
630 : Real64 const Tlo, // temperature below Tact for which we have property data
631 : Real64 const Thi, // temperature above Tact for which we have property data
632 : Real64 const Xlo, // value of property at Tlo
633 : Real64 const Xhi // value of property at Thi
634 : )
635 : {
636 21209702 : return Xhi - (((Thi - Tact) / (Thi - Tlo)) * (Xhi - Xlo));
637 : }
638 :
639 : //*****************************************************************************
640 :
641 : Real64 GetQualityRefrig(EnergyPlusData &state,
642 : std::string const &Refrigerant, // carries in substance name
643 : Real64 Temperature, // actual temperature given as input
644 : Real64 Enthalpy, // actual enthalpy given as input
645 : int &RefrigIndex, // Index to Refrigerant Properties
646 : std::string_view const CalledFrom // routine this function was called from (error messages)
647 : );
648 :
649 : //*****************************************************************************
650 :
651 : int FindRefrigerant(EnergyPlusData &state, std::string_view const Rrefrigerant); // carries in substance name
652 :
653 : //*****************************************************************************
654 :
655 : int FindGlycol(EnergyPlusData &state, std::string_view const Glycol); // carries in substance name
656 :
657 : //*****************************************************************************
658 :
659 : std::string GetGlycolNameByIndex(EnergyPlusData &state, int Idx); // carries in substance index
660 :
661 : //*****************************************************************************
662 :
663 : int FindArrayIndex(Real64 Value, // Value to be placed/found within the array of values
664 : Array1D<Real64> const &Array, // Array of values in ascending order
665 : int LowBound, // Valid values lower bound (set by calling program)
666 : int UpperBound // Valid values upper bound (set by calling program)
667 : );
668 :
669 : int FindArrayIndex(Real64 Value, // Value to be placed/found within the array of values
670 : Array1D<Real64> const &Array // Array of values in ascending order
671 : );
672 :
673 : //*****************************************************************************
674 :
675 : Real64 GetInterpolatedSatProp(EnergyPlusData &state,
676 : Real64 Temperature, // Saturation Temp.
677 : Array1D<Real64> const &PropTemps, // Array of temperature at which props are available
678 : Array1D<Real64> const &LiqProp, // Array of saturated liquid properties
679 : Array1D<Real64> const &VapProp, // Array of saturatedvapour properties
680 : Real64 Quality, // Quality
681 : std::string_view const CalledFrom, // routine this function was called from (error messages)
682 : int LowBound, // Valid values lower bound (set by calling program)
683 : int UpperBound // Valid values upper bound (set by calling program)
684 : );
685 :
686 : //*****************************************************************************
687 :
688 : int CheckFluidPropertyName(EnergyPlusData &state,
689 : std::string const &NameToCheck); // Name from input(?) to be checked against valid FluidPropertyNames
690 :
691 : void ReportOrphanFluids(EnergyPlusData &state);
692 :
693 : void ReportFatalGlycolErrors(EnergyPlusData &state,
694 : int NumGlycols, // Number of Glycols in input/data
695 : int GlycolNum, // Glycol Index
696 : bool DataPresent, // data is present for this fluid.
697 : std::string_view const GlycolName, // Name being reported
698 : std::string_view const RoutineName, // Routine name to show
699 : std::string_view const Property, // Property being requested
700 : std::string_view const CalledFrom // original called from (external to fluid properties)
701 : );
702 :
703 : void ReportFatalRefrigerantErrors(EnergyPlusData &state,
704 : int NumRefrigerants, // Number of Refrigerants in input/data
705 : int RefrigerantNum, // Refrigerant Index
706 : bool DataPresent, // data is present for this fluid.
707 : std::string_view const RefrigerantName, // Name being reported
708 : std::string_view const RoutineName, // Routine name to show
709 : std::string_view const Property, // Property being requested
710 : std::string_view const CalledFrom // original called from (external to fluid properties)
711 : );
712 :
713 : void GetFluidDensityTemperatureLimits(EnergyPlusData &state, int FluidIndex, Real64 &MinTempLimit, Real64 &MaxTempLimit);
714 :
715 : void GetFluidSpecificHeatTemperatureLimits(EnergyPlusData &state, int FluidIndex, Real64 &MinTempLimit, Real64 &MaxTempLimit);
716 :
717 : struct GlycolAPI
718 : {
719 : std::string glycolName;
720 : int glycolIndex;
721 : std::string cf;
722 : explicit GlycolAPI(EnergyPlusData &state, std::string const &glycolName);
723 0 : ~GlycolAPI() = default;
724 : Real64 specificHeat(EnergyPlusData &state, Real64 temperature);
725 : Real64 density(EnergyPlusData &state, Real64 temperature);
726 : Real64 conductivity(EnergyPlusData &state, Real64 temperature);
727 : Real64 viscosity(EnergyPlusData &state, Real64 temperature);
728 : };
729 :
730 : struct RefrigerantAPI
731 : {
732 : std::string rName;
733 : int rIndex;
734 : std::string cf;
735 : explicit RefrigerantAPI(EnergyPlusData &state, std::string const &refrigName);
736 0 : ~RefrigerantAPI() = default;
737 : Real64 saturationPressure(EnergyPlusData &state, Real64 temperature);
738 : Real64 saturationTemperature(EnergyPlusData &state, Real64 pressure);
739 : Real64 saturatedEnthalpy(EnergyPlusData &state, Real64 temperature, Real64 quality);
740 : Real64 saturatedDensity(EnergyPlusData &state, Real64 temperature, Real64 quality);
741 : Real64 saturatedSpecificHeat(EnergyPlusData &state, Real64 temperature, Real64 quality);
742 : Real64 superHeatedEnthalpy(EnergyPlusData &state, Real64 temperature, Real64 pressure);
743 : Real64 superHeatedPressure(EnergyPlusData &state, Real64 temperature, Real64 enthalpy);
744 : Real64 superHeatedDensity(EnergyPlusData &state, Real64 temperature, Real64 pressure);
745 : };
746 :
747 : } // namespace FluidProperties
748 :
749 1542 : struct FluidPropertiesData : BaseGlobalStruct
750 : {
751 :
752 : bool GetInput = true; // Used to get the input once only
753 : int NumOfRefrigerants = 0; // Total number of refrigerants input by user
754 : int NumOfGlycols = 0; // Total number of glycols input by user
755 : bool DebugReportGlycols = false;
756 : bool DebugReportRefrigerants = false;
757 : int GlycolErrorLimitTest = 1; // how many times error is printed with details before recurring called
758 : int RefrigerantErrorLimitTest = 1; // how many times error is printed with details before recurring called
759 : Array1D_bool RefrigUsed;
760 : Array1D_bool GlycolUsed;
761 :
762 : Array1D<FluidProperties::FluidPropsRefrigerantData> RefrigData;
763 : Array1D<FluidProperties::FluidPropsRefrigErrors> RefrigErrorTracking;
764 : Array1D<FluidProperties::FluidPropsGlycolRawData> GlyRawData;
765 : Array1D<FluidProperties::FluidPropsGlycolData> GlycolData;
766 : Array1D<FluidProperties::FluidPropsGlycolErrors> GlycolErrorTracking;
767 :
768 : int SatErrCountGetSupHeatEnthalpyRefrig = 0;
769 : int SatErrCountGetSupHeatDensityRefrig = 0;
770 : int HighTempLimitErrGetSpecificHeatGlycol_raw = 0;
771 : int LowTempLimitErrGetSpecificHeatGlycol_raw = 0;
772 : int HighTempLimitErrGetDensityGlycol = 0;
773 : int LowTempLimitErrGetDensityGlycol = 0;
774 : int HighTempLimitErrGetConductivityGlycol = 0;
775 : int LowTempLimitErrGetConductivityGlycol = 0;
776 : int HighTempLimitErrGetViscosityGlycol = 0;
777 : int LowTempLimitErrGetViscosityGlycol = 0;
778 : int TempLoRangeErrIndexGetQualityRefrig = 0;
779 : int TempHiRangeErrIndexGetQualityRefrig = 0;
780 : int TempRangeErrCountGetInterpolatedSatProp = 0;
781 : int TempRangeErrIndexGetInterpolatedSatProp = 0;
782 :
783 0 : void clear_state() override
784 : {
785 0 : this->GetInput = true;
786 0 : this->NumOfRefrigerants = 0;
787 0 : this->NumOfGlycols = 0;
788 0 : this->DebugReportGlycols = false;
789 0 : this->DebugReportRefrigerants = false;
790 0 : this->GlycolErrorLimitTest = 1;
791 0 : this->RefrigerantErrorLimitTest = 1;
792 0 : this->RefrigUsed.deallocate();
793 0 : this->GlycolUsed.deallocate();
794 :
795 0 : this->RefrigData.deallocate();
796 0 : this->RefrigErrorTracking.deallocate();
797 0 : this->GlyRawData.deallocate();
798 0 : this->GlycolData.deallocate();
799 0 : this->GlycolErrorTracking.deallocate();
800 :
801 0 : this->SatErrCountGetSupHeatEnthalpyRefrig = 0;
802 0 : this->SatErrCountGetSupHeatDensityRefrig = 0;
803 0 : this->HighTempLimitErrGetSpecificHeatGlycol_raw = 0;
804 0 : this->LowTempLimitErrGetSpecificHeatGlycol_raw = 0;
805 0 : this->HighTempLimitErrGetDensityGlycol = 0;
806 0 : this->LowTempLimitErrGetDensityGlycol = 0;
807 0 : this->HighTempLimitErrGetConductivityGlycol = 0;
808 0 : this->LowTempLimitErrGetConductivityGlycol = 0;
809 0 : this->HighTempLimitErrGetViscosityGlycol = 0;
810 0 : this->LowTempLimitErrGetViscosityGlycol = 0;
811 0 : this->TempLoRangeErrIndexGetQualityRefrig = 0;
812 0 : this->TempHiRangeErrIndexGetQualityRefrig = 0;
813 0 : this->TempRangeErrCountGetInterpolatedSatProp = 0;
814 0 : this->TempRangeErrIndexGetInterpolatedSatProp = 0;
815 0 : }
816 : };
817 :
818 : } // namespace EnergyPlus
819 :
820 : #endif
|