LCOV - code coverage report
Current view: top level - EnergyPlus - FluidProperties.hh (source / functions) Coverage Total Hit
Test: lcov.output.filtered Lines: 42.1 % 19 8
Test Date: 2025-06-02 07:23:51 Functions: 75.0 % 4 3

            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 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 Fluid {
      71              : 
      72              :     constexpr int GlycolNum_Water = 1;
      73              :     constexpr int RefrigNum_Steam = 1;
      74              : 
      75              : #undef PERFORMANCE_OPT
      76              : 
      77              : #ifdef EP_cache_GlycolSpecificHeat
      78              :     int constexpr t_sh_cache_size = 1024 * 1024;
      79              :     int constexpr t_sh_precision_bits = 24;
      80              :     std::uint64_t constexpr t_sh_cache_mask = (t_sh_cache_size - 1);
      81              : #endif
      82              : 
      83              :     enum class RefrigError
      84              :     {
      85              :         Invalid = -1,
      86              :         SatTemp,
      87              :         SatPress,
      88              :         SatTempDensity,
      89              :         SatSupEnthalpy,
      90              :         SatSupEnthalpyTemp,
      91              :         SatSupEnthalpyPress,
      92              :         SatSupPress,
      93              :         SatSupPressTemp,
      94              :         SatSupPressEnthalpy,
      95              :         SatSupDensity,
      96              :         SatSupDensityTemp,
      97              :         SatSupDensityPress,
      98              :         Num
      99              :     };
     100              : 
     101              :     struct RefrigProps
     102              :     {
     103              :         // Members
     104              :         std::string Name; // Name of the refrigerant
     105              :         int Num = 0;
     106              :         bool used = false;
     107              : 
     108              :         std::string satTempArrayName; // Array of saturated temperature points, must be same for all properties
     109              :         std::string supTempArrayName; // Array of superheated temperature points, must be same for all properties
     110              : 
     111              :         int NumPsPoints = 0;          // Number of saturation pressure
     112              :         Real64 PsLowTempValue = 0.0;  // Low Temperature Value for Ps (>0.0)
     113              :         Real64 PsHighTempValue = 0.0; // High Temperature Value for Ps (max in tables)
     114              :         int PsLowTempIndex = 0;       // Low Temperature Min Index for Ps (>0.0)
     115              :         int PsHighTempIndex = 0;      // High Temperature Max Index for Ps (>0.0)
     116              :         Real64 PsLowPresValue = 0.0;  // Low Pressure Value for Ps (>0.0)
     117              :         Real64 PsHighPresValue = 0.0; // High Pressure Value for Ps (max in tables)
     118              :         int PsLowPresIndex = 0;       // Low Pressure Min Index for Ps (>0.0)
     119              :         int PsHighPresIndex = 0;      // High Pressure Max Index for Ps (>0.0)
     120              :         Array1D<Real64> PsTemps;      // Temperatures for saturation pressures
     121              :         Array1D<Real64> PsValues;     // Saturation pressures at PsTemps
     122              : #ifdef PERFORMANCE_OPT
     123              :         Array1D<Real64> PsTempRatios; // PsTempRatios(i) = (PsValues(i+1) - PsValues(i)) / (PsTemps(i+1) - PsTemps(i)).  Speed optimization.
     124              : #endif                                // PERFORMANCE_OPT
     125              : 
     126              :         int NumHPoints = 0;            // Number of enthalpy points
     127              :         Real64 HfLowTempValue = 0.0;   // Low Temperature Value for Hf (>0.0)
     128              :         Real64 HfHighTempValue = 0.0;  // High Temperature Value for Hf (max in tables)
     129              :         int HfLowTempIndex = 0;        // Low Temperature Min Index for Hf (>0.0)
     130              :         int HfHighTempIndex = 0;       // High Temperature Max Index for Hf (>0.0)
     131              :         Real64 HfgLowTempValue = 0.0;  // Low Temperature Value for Hfg (>0.0)
     132              :         Real64 HfgHighTempValue = 0.0; // High Temperature Value for Hfg (max in tables)
     133              :         int HfgLowTempIndex = 0;       // Low Temperature Min Index for Hfg (>0.0)
     134              :         int HfgHighTempIndex = 0;      // High Temperature Max Index for Hfg (>0.0)
     135              :         Array1D<Real64> HTemps;        // Temperatures for enthalpy points
     136              :         Array1D<Real64> HfValues;      // Enthalpy of saturated fluid at HTemps
     137              :         Array1D<Real64> HfgValues;     // Enthalpy of saturated fluid/gas at HTemps
     138              : #ifdef PERFORMANCE_OPT
     139              :         Array1D<Real64> HfTempRatios;
     140              :         Array1D<Real64> HfgTempRatios;
     141              : #endif // PERFORMANCE_OPT
     142              : 
     143              :         int NumCpPoints = 0;            // Number of specific heat of fluid points
     144              :         Real64 CpfLowTempValue = 0.0;   // Low Temperature Value for Cpf (>0.0)
     145              :         Real64 CpfHighTempValue = 0.0;  // High Temperature Value for Cpf (max in tables)
     146              :         int CpfLowTempIndex = 0;        // Low Temperature Min Index for Cpf (>0.0)
     147              :         int CpfHighTempIndex = 0;       // High Temperature Max Index for Cpf (>0.0)
     148              :         Real64 CpfgLowTempValue = 0.0;  // Low Temperature Value for Cpfg (>0.0)
     149              :         Real64 CpfgHighTempValue = 0.0; // High Temperature Value for Cpfg (max in tables)
     150              :         int CpfgLowTempIndex = 0;       // Low Temperature Min Index for Cpfg (>0.0)
     151              :         int CpfgHighTempIndex = 0;      // High Temperature Max Index for Cpfg (>0.0)
     152              :         Array1D<Real64> CpTemps;        // Temperatures for specific heat points
     153              :         Array1D<Real64> CpfValues;      // Specific heat of saturated fluid at CpTemps
     154              :         Array1D<Real64> CpfgValues;     // Specific heat of saturated fluid/gas at CpTemps
     155              : #ifdef PERFORMANCE_OPT
     156              :         Array1D<Real64> CpfTempRatios;
     157              :         Array1D<Real64> CpfgTempRatios;
     158              : #endif // PERFORMANCE_OPT
     159              : 
     160              :         int NumRhoPoints = 0;            // Number of density of fluid points
     161              :         Real64 RhofLowTempValue = 0.0;   // Low Temperature Value for Rhof (>0.0)
     162              :         Real64 RhofHighTempValue = 0.0;  // High Temperature Value for Rhof (max in tables)
     163              :         int RhofLowTempIndex = 0;        // Low Temperature Min Index for Rhof (>0.0)
     164              :         int RhofHighTempIndex = 0;       // High Temperature Max Index for Rhof (>0.0)
     165              :         Real64 RhofgLowTempValue = 0.0;  // Low Temperature Value for Rhofg (>0.0)
     166              :         Real64 RhofgHighTempValue = 0.0; // High Temperature Value for Rhofg (max in tables)
     167              :         int RhofgLowTempIndex = 0;       // Low Temperature Min Index for Rhofg (>0.0)
     168              :         int RhofgHighTempIndex = 0;      // High Temperature Max Index for Rhofg (>0.0)
     169              :         Array1D<Real64> RhoTemps;        // Temperatures for density of fluid points
     170              :         Array1D<Real64> RhofValues;      // Density of saturated fluid at RhoTemps
     171              :         Array1D<Real64> RhofgValues;     // Density of saturated fluid/gas at RhoTemps
     172              : #ifdef PERFORMANCE_OPT
     173              :         Array1D<Real64> RhofTempRatios;
     174              :         Array1D<Real64> RhofgTempRatios;
     175              : #endif // PERFORMANCE_OPT
     176              : 
     177              :         int NumSupTempPoints = 0;    // Number of temperature points for superheated enthalpy
     178              :         int NumSupPressPoints = 0;   // Number of pressure points for superheated enthalpy
     179              :         Array1D<Real64> SupTemps;    // Temperatures for superheated gas
     180              :         Array1D<Real64> SupPress;    // Pressures for superheated gas
     181              :         Array2D<Real64> HshValues;   // Enthalpy of superheated gas at HshTemps, HshPress
     182              :         Array2D<Real64> RhoshValues; // Density of superheated gas at HshTemps, HshPress
     183              : 
     184              :         std::array<ErrorCountIndex, (int)RefrigError::Num> errors;
     185              : 
     186              :         Real64 getQuality(EnergyPlusData &state,
     187              :                           Real64 Temperature,           // actual temperature given as input
     188              :                           Real64 Enthalpy,              // actual enthalpy given as input
     189              :                           std::string_view CalledFrom); // routine this function was called from (error messages)
     190              : 
     191              :         Real64 getSatPressure(EnergyPlusData &state,
     192              :                               Real64 Temperature,           // actual temperature given as input
     193              :                               std::string_view CalledFrom); // routine this function was called from (error messages)
     194              : 
     195              :         Real64 getSatTemperature(EnergyPlusData &state,
     196              :                                  Real64 Pressure,              // actual temperature given as input
     197              :                                  std::string_view CalledFrom); // routine this function was called from (error messages)
     198              : 
     199              :         Real64 getSatEnthalpy(EnergyPlusData &state,
     200              :                               Real64 Temperature,           // actual temperature given as input
     201              :                               Real64 Quality,               // actual quality given as input
     202              :                               std::string_view CalledFrom); // routine this function was called from (error messages)
     203              : 
     204              :         Real64 getSatDensity(EnergyPlusData &state,
     205              :                              Real64 Temperature,           // actual temperature given as input
     206              :                              Real64 Quality,               // actual quality given as input
     207              :                              std::string_view CalledFrom); // routine this function was called from (error messages)
     208              : 
     209              :         Real64 getSatSpecificHeat(EnergyPlusData &state,
     210              :                                   Real64 Temperature,           // actual temperature given as input
     211              :                                   Real64 Quality,               // actual quality given as input
     212              :                                   std::string_view CalledFrom); // routine this function was called from (error messages)
     213              : 
     214              :         Real64 getSupHeatEnthalpy(EnergyPlusData &state,
     215              :                                   Real64 Temperature,           // actual temperature given as input
     216              :                                   Real64 Pressure,              // actual pressure given as input
     217              :                                   std::string_view CalledFrom); // routine this function was called from (error messages)
     218              : 
     219              :         Real64 getSupHeatPressure(EnergyPlusData &state,
     220              :                                   Real64 Temperature,           // actual temperature given as input
     221              :                                   Real64 Enthalpy,              // actual enthalpy given as input
     222              :                                   std::string_view CalledFrom); // routine this function was called from (error messages)
     223              : 
     224              :         Real64 getSupHeatTemp(EnergyPlusData &state,
     225              :                               Real64 Pressure,              // actual pressure given as input
     226              :                               Real64 Enthalpy,              // actual enthalpy given as input
     227              :                               Real64 TempLow,               // lower bound of temperature in the iteration
     228              :                               Real64 TempUp,                // upper bound of temperature in the iteration
     229              :                               std::string_view CalledFrom); // routine this function was called from (error messages)
     230              : 
     231              :         Real64 getSupHeatDensity(EnergyPlusData &state,
     232              :                                  Real64 Temperature,           // actual temperature given as input
     233              :                                  Real64 Pressure,              // actual pressure given as input
     234              :                                  std::string_view CalledFrom); // routine this function was called from (error messages)
     235              : 
     236              :         void setTempLimits(EnergyPlusData &state, bool &ErrorsFound);
     237              :     };
     238              : 
     239              :     enum class GlycolError
     240              :     {
     241              :         Invalid = -1,
     242              :         SpecHeatLow,
     243              :         SpecHeatHigh,
     244              :         DensityLow,
     245              :         DensityHigh,
     246              :         ConductivityLow,
     247              :         ConductivityHigh,
     248              :         ViscosityLow,
     249              :         ViscosityHigh,
     250              :         Num
     251              :     };
     252              : 
     253              :     struct GlycolRawProps
     254              :     {
     255              :         // Members
     256              :         std::string Name; // Name of the glycol
     257              :         int Num = 0;
     258              : 
     259              :         std::string CpTempArrayName;
     260              :         bool CpDataPresent = false; // Flag set when specific heat data is available
     261              :         int NumCpTempPoints = 0;    // Number of temperature points for specific heat
     262              :         int NumCpConcPoints = 0;    // Number of concentration points for specific heat
     263              :         Array1D<Real64> CpTemps;    // Temperatures for specific heat of glycol
     264              :         Array1D<Real64> CpConcs;    // Concentration for specific heat of glycol
     265              :         Array2D<Real64> CpValues;   // Specific heat data values
     266              : 
     267              :         std::string RhoTempArrayName;
     268              :         bool RhoDataPresent = false; // Flag set when density data is available
     269              :         int NumRhoTempPoints = 0;    // Number of temperature points for density
     270              :         int NumRhoConcPoints = 0;    // Number of concentration points for density
     271              :         Array1D<Real64> RhoTemps;    // Temperatures for density of glycol
     272              :         Array1D<Real64> RhoConcs;    // Concentration for density of glycol
     273              :         Array2D<Real64> RhoValues;   // Density data values
     274              : 
     275              :         std::string CondTempArrayName;
     276              :         bool CondDataPresent = false; // Flag set when conductivity data is available
     277              :         int NumCondTempPoints = 0;    // Number of temperature points for conductivity
     278              :         int NumCondConcPoints = 0;    // Number of concentration points for conductivity
     279              :         Array1D<Real64> CondTemps;    // Temperatures for conductivity of glycol
     280              :         Array1D<Real64> CondConcs;    // Concentration for conductivity of glycol
     281              :         Array2D<Real64> CondValues;   // conductivity values
     282              : 
     283              :         std::string ViscTempArrayName;
     284              :         bool ViscDataPresent = false; // Flag set when viscosity data is available
     285              :         int NumViscTempPoints = 0;    // Number of temperature points for viscosity
     286              :         int NumViscConcPoints = 0;    // Number of concentration points for viscosity
     287              :         Array1D<Real64> ViscTemps;    // Temperatures for viscosity of glycol
     288              :         Array1D<Real64> ViscConcs;    // Concentration for viscosity of glycol
     289              :         Array2D<Real64> ViscValues;   // viscosity values
     290              :     };
     291              : 
     292              :     struct GlycolProps
     293              :     {
     294              :         // Members
     295              :         std::string Name; // Name of the glycol mixture (used by other parts of code)
     296              :         int Num = 0;
     297              :         bool used = false;
     298              : 
     299              :         std::string GlycolName; // Name of non-water fluid that is part of this mixture
     300              :         // (refers to ethylene glycol, propylene glycol, or user fluid)
     301              :         int BaseGlycolIndex = 0; // Index in user defined glycol data (>0 = index in raw data,
     302              :         // -1=propylene glycol, -2=ethylene glycol)
     303              :         Real64 Concentration = 0.0; // Concentration (if applicable)
     304              : 
     305              :         bool CpDataPresent = false;   // Flag set when specific heat data is available
     306              :         Real64 CpLowTempValue = 0.0;  // Low Temperature Value for Cp (>0.0)
     307              :         Real64 CpHighTempValue = 0.0; // High Temperature Value for Cp (max in tables)
     308              :         int CpLowTempIndex = 0;       // Low Temperature Min Index for Cp (>0.0)
     309              :         int CpHighTempIndex = 0;      // High Temperature Max Index for Cp (>0.0)
     310              :         int NumCpTempPoints = 0;      // Number of temperature points for specific heat
     311              :         Array1D<Real64> CpTemps;      // Temperatures for specific heat of glycol
     312              :         Array1D<Real64> CpValues;     // Specific heat data values (J/kg-K)
     313              : #ifdef PERFORMANCE_OPT
     314              :         int LoCpTempIdxLast = 1;
     315              :         Array1D<Real64> CpTempRatios; // Speed optimization
     316              : #endif                                // PERFORMANCE_OPT
     317              : 
     318              :         bool RhoDataPresent = false;   // Flag set when density data is available
     319              :         int NumRhoTempPoints = 0.0;    // Number of temperature points for density
     320              :         Real64 RhoLowTempValue = 0.0;  // Low Temperature Value for Rho (>0.0)
     321              :         Real64 RhoHighTempValue = 0.0; // High Temperature Value for Rho (max in tables)
     322              :         int RhoLowTempIndex = 0;       // Low Temperature Min Index for Rho (>0.0)
     323              :         int RhoHighTempIndex = 0;      // High Temperature Max Index for Rho (>0.0)
     324              :         Array1D<Real64> RhoTemps;      // Temperatures for density of glycol
     325              :         Array1D<Real64> RhoValues;     // Density data values (kg/m3)
     326              : #ifdef PERFORMANCE_OPT
     327              :         int LoRhoTempIdxLast = 1;
     328              :         Array1D<Real64> RhoTempRatios; // Speed optimization
     329              : #endif                                 // PERFORMANCE_OPT
     330              : 
     331              :         bool CondDataPresent = false;   // Flag set when conductivity data is available
     332              :         int NumCondTempPoints = 0;      // Number of temperature points for conductivity
     333              :         Real64 CondLowTempValue = 0.0;  // Low Temperature Value for Cond (>0.0)
     334              :         Real64 CondHighTempValue = 0.0; // High Temperature Value for Cond (max in tables)
     335              :         int CondLowTempIndex = 0;       // Low Temperature Min Index for Cond (>0.0)
     336              :         int CondHighTempIndex = 0;      // High Temperature Max Index for Cond (>0.0)
     337              :         Array1D<Real64> CondTemps;      // Temperatures for conductivity of glycol
     338              :         Array1D<Real64> CondValues;     // conductivity values (W/m-K)
     339              : #ifdef PERFORMANCE_OPT
     340              :         int LoCondTempIdxLast = 1;
     341              :         Array1D<Real64> CondTempRatios; // Speed optimization
     342              : #endif                                  // PERFORMANCE_OPT
     343              : 
     344              :         bool ViscDataPresent = false;   // Flag set when viscosity data is available
     345              :         int NumViscTempPoints = 0;      // Number of temperature points for viscosity
     346              :         Real64 ViscLowTempValue = 0.0;  // Low Temperature Value for Visc (>0.0)
     347              :         Real64 ViscHighTempValue = 0.0; // High Temperature Value for Visc (max in tables)
     348              :         int ViscLowTempIndex = 0;       // Low Temperature Min Index for Visc (>0.0)
     349              :         int ViscHighTempIndex = 0;      // High Temperature Max Index for Visc (>0.0)
     350              :         Array1D<Real64> ViscTemps;      // Temperatures for viscosity of glycol
     351              :         Array1D<Real64> ViscValues;     // viscosity values (mPa-s)
     352              : #ifdef PERFORMANCE_OPT
     353              :         int LoViscTempIdxLast = 1;
     354              :         Array1D<Real64> ViscTempRatios;
     355              : #endif // PERFORMANCE_OPT
     356              : 
     357              :         std::array<ErrorCountIndex, (int)GlycolError::Num> errors;
     358              : 
     359              : #ifdef EP_cache_GlycolSpecificHeat
     360              :         Real64 getSpecificHeat_raw(EnergyPlusData &state,
     361              :                                    Real64 Temperature,         // actual temperature given as input
     362              :                                    std::string_view CalledFrom // routine this function was called from (error messages)
     363              :         );
     364              : #endif
     365              :         Real64 getSpecificHeat(EnergyPlusData &state,
     366              :                                Real64 Temperature,           // actual temperature given as input
     367              :                                std::string_view CalledFrom); // routine this function was called from (error messages)
     368              : 
     369              :         Real64 getDensity(EnergyPlusData &state,
     370              :                           Real64 Temperature,           // actual temperature given as input
     371              :                           std::string_view CalledFrom); // routine this function was called from (error messages)
     372              : 
     373              :         Real64 getConductivity(EnergyPlusData &state,
     374              :                                Real64 Temperature,           // actual temperature given as input
     375              :                                std::string_view CalledFrom); // routine this function was called from (error messages)
     376              : 
     377              :         Real64 getViscosity(EnergyPlusData &state,
     378              :                             Real64 Temperature,           // actual temperature given as input
     379              :                             std::string_view CalledFrom); // routine this function was called from (error messages)
     380              : 
     381              :         void setTempLimits(EnergyPlusData &state, bool &ErrorsFound);
     382              : 
     383              :         void getDensityTemperatureLimits(EnergyPlusData &state, Real64 &MinTempLimit, Real64 &MaxTempLimit);
     384              : 
     385              :         void getSpecificHeatTemperatureLimits(EnergyPlusData &state, Real64 &MinTempLimit, Real64 &MaxTempLimit);
     386              :     };
     387              : 
     388              :     struct cached_tsh
     389              :     {
     390              :         // Members
     391              :         std::uint64_t iT = 1000;
     392              :         Real64 sh = 0.0;
     393              :     };
     394              : 
     395              :     void GetFluidPropertiesData(EnergyPlusData &state);
     396              : 
     397              :     void InitConstantFluidPropertiesData(EnergyPlusData &state);
     398              : 
     399              :     template <size_t NumOfTemps, size_t NumOfConcs>
     400              :     void InterpDefValuesForGlycolConc(
     401              :         EnergyPlusData &state,
     402              :         const std::array<Real64, NumOfConcs> &RawConcData,                         // concentrations for raw data
     403              :         const std::array<std::array<Real64, NumOfTemps>, NumOfConcs> &RawPropData, // raw property data (concentration, temperature)
     404              :         Real64 Concentration,                                                      // concentration of actual fluid mix
     405              :         Array1D<Real64> &InterpData                                                // interpolated output data at proper concentration
     406              :     );
     407              : 
     408              :     void InterpValuesForGlycolConc(EnergyPlusData &state,
     409              :                                    int NumOfConcs,                     // number of concentrations (dimension of raw data)
     410              :                                    int NumOfTemps,                     // number of temperatures (dimension of raw data)
     411              :                                    const Array1D<Real64> &RawConcData, // concentrations for raw data
     412              :                                    Array2S<Real64> RawPropData,        // raw property data (temperature,concentration)
     413              :                                    Real64 Concentration,               // concentration of actual fluid mix
     414              :                                    Array1D<Real64> &InterpData         // interpolated output data at proper concentration
     415              :     );
     416              : 
     417              :     void ReportAndTestGlycols(EnergyPlusData &state);
     418              : 
     419              :     void ReportAndTestRefrigerants(EnergyPlusData &state);
     420              : #ifdef GET_OUT
     421              :     Real64 GetQualityRefrig(EnergyPlusData &state,
     422              :                             std::string const &Refrigerant, // carries in substance name
     423              :                             Real64 Temperature,             // actual temperature given as input
     424              :                             Real64 Enthalpy,                // actual enthalpy given as input
     425              :                             int &RefrigIndex,               // Index to Refrigerant Properties
     426              :                             std::string_view CalledFrom     // routine this function was called from (error messages)
     427              :     );
     428              : 
     429              :     Real64 GetSatPressureRefrig(EnergyPlusData &state,
     430              :                                 std::string_view Refrigerant, // carries in substance name
     431              :                                 Real64 Temperature,           // actual temperature given as input
     432              :                                 int &RefrigIndex,             // Index to Refrigerant Properties
     433              :                                 std::string_view CalledFrom   // routine this function was called from (error messages)
     434              :     );
     435              : 
     436              :     Real64 GetSatTemperatureRefrig(EnergyPlusData &state,
     437              :                                    std::string_view Refrigerant, // carries in substance name
     438              :                                    Real64 Pressure,              // actual temperature given as input
     439              :                                    int &RefrigIndex,             // Index to Refrigerant Properties
     440              :                                    std::string_view CalledFrom   // routine this function was called from (error messages)
     441              :     );
     442              : 
     443              :     Real64 GetSatEnthalpyRefrig(EnergyPlusData &state,
     444              :                                 std::string_view 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 CalledFrom   // routine this function was called from (error messages)
     449              :     );
     450              : 
     451              :     Real64 GetSatDensityRefrig(EnergyPlusData &state,
     452              :                                std::string_view Refrigerant, // carries in substance name
     453              :                                Real64 Temperature,           // actual temperature given as input
     454              :                                Real64 Quality,               // actual quality given as input
     455              :                                int &RefrigIndex,             // Index to Refrigerant Properties
     456              :                                std::string_view CalledFrom   // routine this function was called from (error messages)
     457              :     );
     458              : 
     459              :     Real64 GetSatSpecificHeatRefrig(EnergyPlusData &state,
     460              :                                     std::string_view Refrigerant, // carries in substance name
     461              :                                     Real64 Temperature,           // actual temperature given as input
     462              :                                     Real64 Quality,               // actual quality given as input
     463              :                                     int &RefrigIndex,             // Index to Refrigerant Properties
     464              :                                     std::string_view CalledFrom   // routine this function was called from (error messages)
     465              :     );
     466              : 
     467              :     Real64 GetSupHeatEnthalpyRefrig(EnergyPlusData &state,
     468              :                                     std::string_view Refrigerant, // carries in substance name
     469              :                                     Real64 Temperature,           // actual temperature given as input
     470              :                                     Real64 Pressure,              // actual pressure given as input
     471              :                                     int &RefrigIndex,             // Index to Refrigerant Properties
     472              :                                     std::string_view CalledFrom   // routine this function was called from (error messages)
     473              :     );
     474              : 
     475              :     Real64 GetSupHeatPressureRefrig(EnergyPlusData &state,
     476              :                                     std::string_view Refrigerant, // carries in substance name
     477              :                                     Real64 Temperature,           // actual temperature given as input
     478              :                                     Real64 Enthalpy,              // actual enthalpy given as input
     479              :                                     int &RefrigIndex,             // Index to Refrigerant Properties
     480              :                                     std::string_view CalledFrom   // routine this function was called from (error messages)
     481              :     );
     482              : 
     483              :     Real64 GetSupHeatTempRefrig(EnergyPlusData &state,
     484              :                                 std::string_view 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 CalledFrom   // routine this function was called from (error messages)
     491              :     );
     492              : 
     493              :     Real64 GetSupHeatDensityRefrig(EnergyPlusData &state,
     494              :                                    std::string_view 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 CalledFrom   // routine this function was called from (error messages)
     499              :     );
     500              : 
     501              :     Real64 GetSpecificHeatGlycol(EnergyPlusData &state,
     502              :                                  std::string_view Glycol,    // carries in substance name
     503              :                                  Real64 Temperature,         // actual temperature given as input
     504              :                                  int &GlycolIndex,           // Index to Glycol Properties
     505              :                                  std::string_view CalledFrom // routine this function was called from (error messages)
     506              :     );
     507              : 
     508              :     Real64 GetDensityGlycol(EnergyPlusData &state,
     509              :                             std::string_view Glycol,    // carries in substance name
     510              :                             Real64 Temperature,         // actual temperature given as input
     511              :                             int &GlycolIndex,           // Index to Glycol Properties
     512              :                             std::string_view CalledFrom // routine this function was called from (error messages)
     513              :     );
     514              : 
     515              :     Real64 GetConductivityGlycol(EnergyPlusData &state,
     516              :                                  std::string_view Glycol,    // carries in substance name
     517              :                                  Real64 Temperature,         // actual temperature given as input
     518              :                                  int &GlycolIndex,           // Index to Glycol Properties
     519              :                                  std::string_view CalledFrom // routine this function was called from (error messages)
     520              :     );
     521              : 
     522              :     Real64 GetViscosityGlycol(EnergyPlusData &state,
     523              :                               std::string_view Glycol,    // carries in substance name
     524              :                               Real64 Temperature,         // actual temperature given as input
     525              :                               int &GlycolIndex,           // Index to Glycol Properties
     526              :                               std::string_view CalledFrom // routine this function was called from (error messages)
     527              :     );
     528              : #endif // GET_OUT
     529              : 
     530     22758620 :     inline Real64 GetInterpValue(Real64 const Tact, // actual temperature at which we want the property of interest
     531              :                                  Real64 const Tlo,  // temperature below Tact for which we have property data
     532              :                                  Real64 const Thi,  // temperature above Tact for which we have property data
     533              :                                  Real64 const Xlo,  // value of property at Tlo
     534              :                                  Real64 const Xhi   // value of property at Thi
     535              :     )
     536              :     {
     537     22758620 :         return Xhi - (((Thi - Tact) / (Thi - Tlo)) * (Xhi - Xlo));
     538              :     }
     539              : 
     540              :     int GetRefrigNum(EnergyPlusData &state, std::string_view name);
     541              :     RefrigProps *GetRefrig(EnergyPlusData &state, std::string_view name);
     542              :     RefrigProps *GetSteam(EnergyPlusData &state);
     543              : 
     544              :     int GetGlycolRawNum(EnergyPlusData &state, std::string_view name);
     545              :     GlycolRawProps *GetGlycolRaw(EnergyPlusData &state, std::string_view name);
     546              : 
     547              :     int GetGlycolNum(EnergyPlusData &state, std::string_view name);
     548              :     GlycolProps *GetGlycol(EnergyPlusData &state, std::string_view name);
     549              :     GlycolProps *GetWater(EnergyPlusData &state);
     550              : 
     551              :     std::string GetGlycolNameByIndex(EnergyPlusData &state, int Idx); // carries in substance index
     552              : 
     553              :     int FindArrayIndex(Real64 Value,                 // Value to be placed/found within the array of values
     554              :                        Array1D<Real64> const &Array, // Array of values in ascending order
     555              :                        int LowBound,                 // Valid values lower bound (set by calling program)
     556              :                        int UpperBound                // Valid values upper bound (set by calling program)
     557              :     );
     558              : 
     559              :     int FindArrayIndex(Real64 Value,                // Value to be placed/found within the array of values
     560              :                        Array1D<Real64> const &Array // Array of values in ascending order
     561              :     );
     562              : 
     563              :     Real64 GetInterpolatedSatProp(EnergyPlusData &state,
     564              :                                   Real64 Temperature,               // Saturation Temp.
     565              :                                   Array1D<Real64> const &PropTemps, // Array of temperature at which props are available
     566              :                                   Array1D<Real64> const &LiqProp,   // Array of saturated liquid properties
     567              :                                   Array1D<Real64> const &VapProp,   // Array of saturatedvapour properties
     568              :                                   Real64 Quality,                   // Quality
     569              :                                   std::string_view CalledFrom,      // routine this function was called from (error messages)
     570              :                                   int LowBound,                     // Valid values lower bound (set by calling program)
     571              :                                   int UpperBound                    // Valid values upper bound (set by calling program)
     572              :     );
     573              : 
     574              :     void ReportOrphanFluids(EnergyPlusData &state);
     575              : } // namespace Fluid
     576              : 
     577              : struct FluidData : BaseGlobalStruct
     578              : {
     579              :     bool DebugReportGlycols = false;
     580              :     bool DebugReportRefrigerants = false;
     581              :     int GlycolErrorLimitTest = 1; // how many times error is printed with details before recurring called
     582              :     int RefrigErrorLimitTest = 1; // how many times error is printed with details before recurring called
     583              : 
     584              :     Array1D<Fluid::RefrigProps *> refrigs;
     585              :     Array1D<Fluid::GlycolRawProps *> glycolsRaw;
     586              :     Array1D<Fluid::GlycolProps *> glycols;
     587              : 
     588              :     std::array<int, (int)Fluid::GlycolError::Num> glycolErrorLimits = {0, 0, 0, 0, 0, 0, 0, 0};
     589              : 
     590              :     int SatErrCountGetSupHeatEnthalpyRefrig = 0;
     591              :     int SatErrCountGetSupHeatDensityRefrig = 0;
     592              :     int TempLoRangeErrIndexGetQualityRefrig = 0;
     593              :     int TempHiRangeErrIndexGetQualityRefrig = 0;
     594              :     int TempRangeErrCountGetInterpolatedSatProp = 0;
     595              :     int TempRangeErrIndexGetInterpolatedSatProp = 0;
     596              : 
     597              : #ifdef EP_cache_GlycolSpecificHeat
     598              :     std::array<Fluid::cached_tsh, Fluid::t_sh_cache_size> cached_t_sh;
     599              : #endif
     600              : 
     601          801 :     void init_constant_state([[maybe_unused]] EnergyPlusData &state) override
     602              :     {
     603          801 :         Fluid::InitConstantFluidPropertiesData(state);
     604          801 :     }
     605              : 
     606          801 :     void init_state(EnergyPlusData &state) override
     607              :     {
     608          801 :         Fluid::GetFluidPropertiesData(state);
     609          801 :     }
     610              : 
     611            0 :     void clear_state() override
     612              :     {
     613              : 
     614            0 :         for (int i = 1; i <= refrigs.isize(); ++i) {
     615            0 :             refrigs(i)->HshValues.deallocate();
     616            0 :             refrigs(i)->RhoshValues.deallocate();
     617            0 :             delete refrigs(i);
     618              :         }
     619            0 :         for (int i = 1; i <= glycolsRaw.isize(); ++i) {
     620            0 :             delete glycolsRaw(i);
     621              :         }
     622            0 :         for (int i = 1; i <= glycols.isize(); ++i) {
     623            0 :             delete glycols(i);
     624              :         }
     625              : 
     626            0 :         new (this) FluidData();
     627            0 :     }
     628              : };
     629              : 
     630              : } // namespace EnergyPlus
     631              : 
     632              : #endif
        

Generated by: LCOV version 2.0-1