LCOV - code coverage report
Current view: top level - EnergyPlus - FluidProperties.hh (source / functions) Hit Total Coverage
Test: lcov.output.filtered Lines: 7 18 38.9 %
Date: 2024-08-23 23:50:59 Functions: 3 6 50.0 %

          Line data    Source code
       1             : // EnergyPlus, Copyright (c) 1996-2024, The Board of Trustees of the University of Illinois,
       2             : // The Regents of the University of California, through Lawrence Berkeley National Laboratory
       3             : // (subject to receipt of any required approvals from the U.S. Dept. of Energy), Oak Ridge
       4             : // National Laboratory, managed by UT-Battelle, Alliance for Sustainable Energy, LLC, and other
       5             : // contributors. All rights reserved.
       6             : //
       7             : // NOTICE: This Software was developed under funding from the U.S. Department of Energy and the
       8             : // U.S. Government consequently retains certain rights. As such, the U.S. Government has been
       9             : // granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable,
      10             : // worldwide license in the Software to reproduce, distribute copies to the public, prepare
      11             : // derivative works, and perform publicly and display publicly, and to permit others to do so.
      12             : //
      13             : // Redistribution and use in source and binary forms, with or without modification, are permitted
      14             : // provided that the following conditions are met:
      15             : //
      16             : // (1) Redistributions of source code must retain the above copyright notice, this list of
      17             : //     conditions and the following disclaimer.
      18             : //
      19             : // (2) Redistributions in binary form must reproduce the above copyright notice, this list of
      20             : //     conditions and the following disclaimer in the documentation and/or other materials
      21             : //     provided with the distribution.
      22             : //
      23             : // (3) Neither the name of the University of California, Lawrence Berkeley National Laboratory,
      24             : //     the University of Illinois, U.S. Dept. of Energy nor the names of its contributors may be
      25             : //     used to endorse or promote products derived from this software without specific prior
      26             : //     written permission.
      27             : //
      28             : // (4) Use of EnergyPlus(TM) Name. If Licensee (i) distributes the software in stand-alone form
      29             : //     without changes from the version obtained under this License, or (ii) Licensee makes a
      30             : //     reference solely to the software portion of its product, Licensee must refer to the
      31             : //     software as "EnergyPlus version X" software, where "X" is the version number Licensee
      32             : //     obtained under this License and may not use a different name for the software. Except as
      33             : //     specifically required in this Section (4), Licensee shall not use in a company name, a
      34             : //     product name, in advertising, publicity, or other promotional activities any name, trade
      35             : //     name, trademark, logo, or other designation of "EnergyPlus", "E+", "e+" or confusingly
      36             : //     similar designation, without the U.S. Department of Energy's prior written consent.
      37             : //
      38             : // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
      39             : // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
      40             : // AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
      41             : // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
      42             : // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
      43             : // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
      44             : // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
      45             : // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
      46             : // POSSIBILITY OF SUCH DAMAGE.
      47             : 
      48             : #ifndef 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             : #undef PERFORMANCE_OPT
      73             : 
      74             : #ifdef EP_cache_GlycolSpecificHeat
      75             :     int constexpr t_sh_cache_size = 1024 * 1024;
      76             :     int constexpr t_sh_precision_bits = 24;
      77             :     std::uint64_t constexpr t_sh_cache_mask = (t_sh_cache_size - 1);
      78             : #endif
      79             : 
      80             :     enum class RefrigError
      81             :     {
      82             :         Invalid = -1,
      83             :         SatTemp,
      84             :         SatPress,
      85             :         SatTempDensity,
      86             :         SatSupEnthalpy,
      87             :         SatSupEnthalpyTemp,
      88             :         SatSupEnthalpyPress,
      89             :         SatSupPress,
      90             :         SatSupPressTemp,
      91             :         SatSupPressEnthalpy,
      92             :         SatSupDensity,
      93             :         SatSupDensityTemp,
      94             :         SatSupDensityPress,
      95             :         Num
      96             :     };
      97             : 
      98             :     struct RefrigProps
      99             :     {
     100             :         // Members
     101             :         std::string Name; // Name of the refrigerant
     102             :         int Num = 0;
     103             :         bool used = false;
     104             : 
     105             :         std::string satTempArrayName; // Array of saturated temperature points, must be same for all properties
     106             :         std::string supTempArrayName; // Array of superheated temperature points, must be same for all properties
     107             : 
     108             :         int NumPsPoints = 0;          // Number of saturation pressure
     109             :         Real64 PsLowTempValue = 0.0;  // Low Temperature Value for Ps (>0.0)
     110             :         Real64 PsHighTempValue = 0.0; // High Temperature Value for Ps (max in tables)
     111             :         int PsLowTempIndex = 0;       // Low Temperature Min Index for Ps (>0.0)
     112             :         int PsHighTempIndex = 0;      // High Temperature Max Index for Ps (>0.0)
     113             :         Real64 PsLowPresValue = 0.0;  // Low Pressure Value for Ps (>0.0)
     114             :         Real64 PsHighPresValue = 0.0; // High Pressure Value for Ps (max in tables)
     115             :         int PsLowPresIndex = 0;       // Low Pressure Min Index for Ps (>0.0)
     116             :         int PsHighPresIndex = 0;      // High Pressure Max Index for Ps (>0.0)
     117             :         Array1D<Real64> PsTemps;      // Temperatures for saturation pressures
     118             :         Array1D<Real64> PsValues;     // Saturation pressures at PsTemps
     119             : #ifdef PERFORMANCE_OPT
     120             :         Array1D<Real64> PsTempRatios; // PsTempRatios(i) = (PsValues(i+1) - PsValues(i)) / (PsTemps(i+1) - PsTemps(i)).  Speed optimization.
     121             : #endif                                // PERFORMANCE_OPT
     122             : 
     123             :         int NumHPoints = 0;            // Number of enthalpy points
     124             :         Real64 HfLowTempValue = 0.0;   // Low Temperature Value for Hf (>0.0)
     125             :         Real64 HfHighTempValue = 0.0;  // High Temperature Value for Hf (max in tables)
     126             :         int HfLowTempIndex = 0;        // Low Temperature Min Index for Hf (>0.0)
     127             :         int HfHighTempIndex = 0;       // High Temperature Max Index for Hf (>0.0)
     128             :         Real64 HfgLowTempValue = 0.0;  // Low Temperature Value for Hfg (>0.0)
     129             :         Real64 HfgHighTempValue = 0.0; // High Temperature Value for Hfg (max in tables)
     130             :         int HfgLowTempIndex = 0;       // Low Temperature Min Index for Hfg (>0.0)
     131             :         int HfgHighTempIndex = 0;      // High Temperature Max Index for Hfg (>0.0)
     132             :         Array1D<Real64> HTemps;        // Temperatures for enthalpy points
     133             :         Array1D<Real64> HfValues;      // Enthalpy of saturated fluid at HTemps
     134             :         Array1D<Real64> HfgValues;     // Enthalpy of saturated fluid/gas at HTemps
     135             : #ifdef PERFORMANCE_OPT
     136             :         Array1D<Real64> HfTempRatios;
     137             :         Array1D<Real64> HfgTempRatios;
     138             : #endif // PERFORMANCE_OPT
     139             : 
     140             :         int NumCpPoints = 0;            // Number of specific heat of fluid points
     141             :         Real64 CpfLowTempValue = 0.0;   // Low Temperature Value for Cpf (>0.0)
     142             :         Real64 CpfHighTempValue = 0.0;  // High Temperature Value for Cpf (max in tables)
     143             :         int CpfLowTempIndex = 0;        // Low Temperature Min Index for Cpf (>0.0)
     144             :         int CpfHighTempIndex = 0;       // High Temperature Max Index for Cpf (>0.0)
     145             :         Real64 CpfgLowTempValue = 0.0;  // Low Temperature Value for Cpfg (>0.0)
     146             :         Real64 CpfgHighTempValue = 0.0; // High Temperature Value for Cpfg (max in tables)
     147             :         int CpfgLowTempIndex = 0;       // Low Temperature Min Index for Cpfg (>0.0)
     148             :         int CpfgHighTempIndex = 0;      // High Temperature Max Index for Cpfg (>0.0)
     149             :         Array1D<Real64> CpTemps;        // Temperatures for specific heat points
     150             :         Array1D<Real64> CpfValues;      // Specific heat of saturated fluid at CpTemps
     151             :         Array1D<Real64> CpfgValues;     // Specific heat of saturated fluid/gas at CpTemps
     152             : #ifdef PERFORMANCE_OPT
     153             :         Array1D<Real64> CpfTempRatios;
     154             :         Array1D<Real64> CpfgTempRatios;
     155             : #endif // PERFORMANCE_OPT
     156             : 
     157             :         int NumRhoPoints = 0;            // Number of density of fluid points
     158             :         Real64 RhofLowTempValue = 0.0;   // Low Temperature Value for Rhof (>0.0)
     159             :         Real64 RhofHighTempValue = 0.0;  // High Temperature Value for Rhof (max in tables)
     160             :         int RhofLowTempIndex = 0;        // Low Temperature Min Index for Rhof (>0.0)
     161             :         int RhofHighTempIndex = 0;       // High Temperature Max Index for Rhof (>0.0)
     162             :         Real64 RhofgLowTempValue = 0.0;  // Low Temperature Value for Rhofg (>0.0)
     163             :         Real64 RhofgHighTempValue = 0.0; // High Temperature Value for Rhofg (max in tables)
     164             :         int RhofgLowTempIndex = 0;       // Low Temperature Min Index for Rhofg (>0.0)
     165             :         int RhofgHighTempIndex = 0;      // High Temperature Max Index for Rhofg (>0.0)
     166             :         Array1D<Real64> RhoTemps;        // Temperatures for density of fluid points
     167             :         Array1D<Real64> RhofValues;      // Density of saturated fluid at RhoTemps
     168             :         Array1D<Real64> RhofgValues;     // Density of saturated fluid/gas at RhoTemps
     169             : #ifdef PERFORMANCE_OPT
     170             :         Array1D<Real64> RhofTempRatios;
     171             :         Array1D<Real64> RhofgTempRatios;
     172             : #endif // PERFORMANCE_OPT
     173             : 
     174             :         int NumSupTempPoints = 0;    // Number of temperature points for superheated enthalpy
     175             :         int NumSupPressPoints = 0;   // Number of pressure points for superheated enthalpy
     176             :         Array1D<Real64> SupTemps;    // Temperatures for superheated gas
     177             :         Array1D<Real64> SupPress;    // Pressures for superheated gas
     178             :         Array2D<Real64> HshValues;   // Enthalpy of superheated gas at HshTemps, HshPress
     179             :         Array2D<Real64> RhoshValues; // Density of superheated gas at HshTemps, HshPress
     180             : 
     181             :         std::array<ErrorCountIndex, (int)RefrigError::Num> errors;
     182             : 
     183             :         Real64 getQuality(EnergyPlusData &state,
     184             :                           Real64 Temperature,           // actual temperature given as input
     185             :                           Real64 Enthalpy,              // actual enthalpy given as input
     186             :                           std::string_view CalledFrom); // routine this function was called from (error messages)
     187             : 
     188             :         Real64 getSatPressure(EnergyPlusData &state,
     189             :                               Real64 Temperature,           // actual temperature given as input
     190             :                               std::string_view CalledFrom); // routine this function was called from (error messages)
     191             : 
     192             :         Real64 getSatTemperature(EnergyPlusData &state,
     193             :                                  Real64 Pressure,              // actual temperature given as input
     194             :                                  std::string_view CalledFrom); // routine this function was called from (error messages)
     195             : 
     196             :         Real64 getSatEnthalpy(EnergyPlusData &state,
     197             :                               Real64 Temperature,           // actual temperature given as input
     198             :                               Real64 Quality,               // actual quality given as input
     199             :                               std::string_view CalledFrom); // routine this function was called from (error messages)
     200             : 
     201             :         Real64 getSatDensity(EnergyPlusData &state,
     202             :                              Real64 Temperature,           // actual temperature given as input
     203             :                              Real64 Quality,               // actual quality given as input
     204             :                              std::string_view CalledFrom); // routine this function was called from (error messages)
     205             : 
     206             :         Real64 getSatSpecificHeat(EnergyPlusData &state,
     207             :                                   Real64 Temperature,           // actual temperature given as input
     208             :                                   Real64 Quality,               // actual quality given as input
     209             :                                   std::string_view CalledFrom); // routine this function was called from (error messages)
     210             : 
     211             :         Real64 getSupHeatEnthalpy(EnergyPlusData &state,
     212             :                                   Real64 Temperature,           // actual temperature given as input
     213             :                                   Real64 Pressure,              // actual pressure given as input
     214             :                                   std::string_view CalledFrom); // routine this function was called from (error messages)
     215             : 
     216             :         Real64 getSupHeatPressure(EnergyPlusData &state,
     217             :                                   Real64 Temperature,           // actual temperature given as input
     218             :                                   Real64 Enthalpy,              // actual enthalpy given as input
     219             :                                   std::string_view CalledFrom); // routine this function was called from (error messages)
     220             : 
     221             :         Real64 getSupHeatTemp(EnergyPlusData &state,
     222             :                               Real64 Pressure,              // actual pressure given as input
     223             :                               Real64 Enthalpy,              // actual enthalpy given as input
     224             :                               Real64 TempLow,               // lower bound of temperature in the iteration
     225             :                               Real64 TempUp,                // upper bound of temperature in the iteration
     226             :                               std::string_view CalledFrom); // routine this function was called from (error messages)
     227             : 
     228             :         Real64 getSupHeatDensity(EnergyPlusData &state,
     229             :                                  Real64 Temperature,           // actual temperature given as input
     230             :                                  Real64 Pressure,              // actual pressure given as input
     231             :                                  std::string_view CalledFrom); // routine this function was called from (error messages)
     232             :     };
     233             : 
     234             :     enum class GlycolError
     235             :     {
     236             :         Invalid = -1,
     237             :         SpecHeatLow,
     238             :         SpecHeatHigh,
     239             :         DensityLow,
     240             :         DensityHigh,
     241             :         ConductivityLow,
     242             :         ConductivityHigh,
     243             :         ViscosityLow,
     244             :         ViscosityHigh,
     245             :         Num
     246             :     };
     247             : 
     248             :     struct GlycolRawProps
     249             :     {
     250             :         // Members
     251             :         std::string Name; // Name of the glycol
     252             :         int Num = 0;
     253             : 
     254             :         std::string CpTempArrayName;
     255             :         bool CpDataPresent = false; // Flag set when specific heat data is available
     256             :         int NumCpTempPoints = 0;    // Number of temperature points for specific heat
     257             :         int NumCpConcPoints = 0;    // Number of concentration points for specific heat
     258             :         Array1D<Real64> CpTemps;    // Temperatures for specific heat of glycol
     259             :         Array1D<Real64> CpConcs;    // Concentration for specific heat of glycol
     260             :         Array2D<Real64> CpValues;   // Specific heat data values
     261             : 
     262             :         std::string RhoTempArrayName;
     263             :         bool RhoDataPresent = false; // Flag set when density data is available
     264             :         int NumRhoTempPoints = 0;    // Number of temperature points for density
     265             :         int NumRhoConcPoints = 0;    // Number of concentration points for density
     266             :         Array1D<Real64> RhoTemps;    // Temperatures for density of glycol
     267             :         Array1D<Real64> RhoConcs;    // Concentration for density of glycol
     268             :         Array2D<Real64> RhoValues;   // Density data values
     269             : 
     270             :         std::string CondTempArrayName;
     271             :         bool CondDataPresent = false; // Flag set when conductivity data is available
     272             :         int NumCondTempPoints = 0;    // Number of temperature points for conductivity
     273             :         int NumCondConcPoints = 0;    // Number of concentration points for conductivity
     274             :         Array1D<Real64> CondTemps;    // Temperatures for conductivity of glycol
     275             :         Array1D<Real64> CondConcs;    // Concentration for conductivity of glycol
     276             :         Array2D<Real64> CondValues;   // conductivity values
     277             : 
     278             :         std::string ViscTempArrayName;
     279             :         bool ViscDataPresent = false; // Flag set when viscosity data is available
     280             :         int NumViscTempPoints = 0;    // Number of temperature points for viscosity
     281             :         int NumViscConcPoints = 0;    // Number of concentration points for viscosity
     282             :         Array1D<Real64> ViscTemps;    // Temperatures for viscosity of glycol
     283             :         Array1D<Real64> ViscConcs;    // Concentration for viscosity of glycol
     284             :         Array2D<Real64> ViscValues;   // viscosity values
     285             :     };
     286             : 
     287             :     struct GlycolProps
     288             :     {
     289             :         // Members
     290             :         std::string Name; // Name of the glycol mixture (used by other parts of code)
     291             :         int Num = 0;
     292             :         bool used = false;
     293             : 
     294             :         std::string GlycolName; // Name of non-water fluid that is part of this mixture
     295             :         // (refers to ethylene glycol, propylene glycol, or user fluid)
     296             :         int BaseGlycolIndex = 0; // Index in user defined glycol data (>0 = index in raw data,
     297             :         // -1=propylene glycol, -2=ethylene glycol)
     298             :         Real64 Concentration = 0.0; // Concentration (if applicable)
     299             : 
     300             :         bool CpDataPresent = false;   // Flag set when specific heat data is available
     301             :         Real64 CpLowTempValue = 0.0;  // Low Temperature Value for Cp (>0.0)
     302             :         Real64 CpHighTempValue = 0.0; // High Temperature Value for Cp (max in tables)
     303             :         int CpLowTempIndex = 0;       // Low Temperature Min Index for Cp (>0.0)
     304             :         int CpHighTempIndex = 0;      // High Temperature Max Index for Cp (>0.0)
     305             :         int NumCpTempPoints = 0;      // Number of temperature points for specific heat
     306             :         Array1D<Real64> CpTemps;      // Temperatures for specific heat of glycol
     307             :         Array1D<Real64> CpValues;     // Specific heat data values (J/kg-K)
     308             : #ifdef PERFORMANCE_OPT
     309             :         int LoCpTempIdxLast = 1;
     310             :         Array1D<Real64> CpTempRatios; // Speed optimization
     311             : #endif                                // PERFORMANCE_OPT
     312             : 
     313             :         bool RhoDataPresent = false;   // Flag set when density data is available
     314             :         int NumRhoTempPoints = 0.0;    // Number of temperature points for density
     315             :         Real64 RhoLowTempValue = 0.0;  // Low Temperature Value for Rho (>0.0)
     316             :         Real64 RhoHighTempValue = 0.0; // High Temperature Value for Rho (max in tables)
     317             :         int RhoLowTempIndex = 0;       // Low Temperature Min Index for Rho (>0.0)
     318             :         int RhoHighTempIndex = 0;      // High Temperature Max Index for Rho (>0.0)
     319             :         Array1D<Real64> RhoTemps;      // Temperatures for density of glycol
     320             :         Array1D<Real64> RhoValues;     // Density data values (kg/m3)
     321             : #ifdef PERFORMANCE_OPT
     322             :         int LoRhoTempIdxLast = 1;
     323             :         Array1D<Real64> RhoTempRatios; // Speed optimization
     324             : #endif                                 // PERFORMANCE_OPT
     325             : 
     326             :         bool CondDataPresent = false;   // Flag set when conductivity data is available
     327             :         int NumCondTempPoints = 0;      // Number of temperature points for conductivity
     328             :         Real64 CondLowTempValue = 0.0;  // Low Temperature Value for Cond (>0.0)
     329             :         Real64 CondHighTempValue = 0.0; // High Temperature Value for Cond (max in tables)
     330             :         int CondLowTempIndex = 0;       // Low Temperature Min Index for Cond (>0.0)
     331             :         int CondHighTempIndex = 0;      // High Temperature Max Index for Cond (>0.0)
     332             :         Array1D<Real64> CondTemps;      // Temperatures for conductivity of glycol
     333             :         Array1D<Real64> CondValues;     // conductivity values (W/m-K)
     334             : #ifdef PERFORMANCE_OPT
     335             :         int LoCondTempIdxLast = 1;
     336             :         Array1D<Real64> CondTempRatios; // Speed optimization
     337             : #endif                                  // PERFORMANCE_OPT
     338             : 
     339             :         bool ViscDataPresent = false;   // Flag set when viscosity data is available
     340             :         int NumViscTempPoints = 0;      // Number of temperature points for viscosity
     341             :         Real64 ViscLowTempValue = 0.0;  // Low Temperature Value for Visc (>0.0)
     342             :         Real64 ViscHighTempValue = 0.0; // High Temperature Value for Visc (max in tables)
     343             :         int ViscLowTempIndex = 0;       // Low Temperature Min Index for Visc (>0.0)
     344             :         int ViscHighTempIndex = 0;      // High Temperature Max Index for Visc (>0.0)
     345             :         Array1D<Real64> ViscTemps;      // Temperatures for viscosity of glycol
     346             :         Array1D<Real64> ViscValues;     // viscosity values (mPa-s)
     347             : #ifdef PERFORMANCE_OPT
     348             :         int LoViscTempIdxLast = 1;
     349             :         Array1D<Real64> ViscTempRatios;
     350             : #endif // PERFORMANCE_OPT
     351             : 
     352             :         std::array<ErrorCountIndex, (int)GlycolError::Num> errors;
     353             : 
     354             : #ifdef EP_cache_GlycolSpecificHeat
     355             :         Real64 getSpecificHeat_raw(EnergyPlusData &state,
     356             :                                    Real64 Temperature,         // actual temperature given as input
     357             :                                    std::string_view CalledFrom // routine this function was called from (error messages)
     358             :         );
     359             : #endif
     360             :         Real64 getSpecificHeat(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             :         Real64 getDensity(EnergyPlusData &state,
     365             :                           Real64 Temperature,           // actual temperature given as input
     366             :                           std::string_view CalledFrom); // routine this function was called from (error messages)
     367             : 
     368             :         Real64 getConductivity(EnergyPlusData &state,
     369             :                                Real64 Temperature,           // actual temperature given as input
     370             :                                std::string_view CalledFrom); // routine this function was called from (error messages)
     371             : 
     372             :         Real64 getViscosity(EnergyPlusData &state,
     373             :                             Real64 Temperature,           // actual temperature given as input
     374             :                             std::string_view CalledFrom); // routine this function was called from (error messages)
     375             :     };
     376             : 
     377             :     struct cached_tsh
     378             :     {
     379             :         // Members
     380             :         std::uint64_t iT;
     381             :         Real64 sh;
     382             : 
     383             :         // Default Constructor
     384   834666496 :         cached_tsh() : iT(1000), sh(0.0)
     385             :         {
     386   834666496 :         }
     387             :     };
     388             : 
     389             :     void GetFluidPropertiesData(EnergyPlusData &state);
     390             : 
     391             :     template <size_t NumOfTemps, size_t NumOfConcs>
     392             :     void InterpDefValuesForGlycolConc(
     393             :         EnergyPlusData &state,
     394             :         const std::array<Real64, NumOfConcs> &RawConcData,                         // concentrations for raw data
     395             :         const std::array<std::array<Real64, NumOfTemps>, NumOfConcs> &RawPropData, // raw property data (concentration, temperature)
     396             :         Real64 Concentration,                                                      // concentration of actual fluid mix
     397             :         Array1D<Real64> &InterpData                                                // interpolated output data at proper concentration
     398             :     );
     399             : 
     400             :     void InterpValuesForGlycolConc(EnergyPlusData &state,
     401             :                                    int NumOfConcs,                     // number of concentrations (dimension of raw data)
     402             :                                    int NumOfTemps,                     // number of temperatures (dimension of raw data)
     403             :                                    const Array1D<Real64> &RawConcData, // concentrations for raw data
     404             :                                    Array2S<Real64> RawPropData,        // raw property data (temperature,concentration)
     405             :                                    Real64 Concentration,               // concentration of actual fluid mix
     406             :                                    Array1D<Real64> &InterpData         // interpolated output data at proper concentration
     407             :     );
     408             : 
     409             :     void InitializeGlycolTempLimits(EnergyPlusData &state, bool &ErrorsFound); // set to true if errors found here
     410             : 
     411             :     void InitializeRefrigerantLimits(EnergyPlusData &state, bool &ErrorsFound); // set to true if errors found here
     412             : 
     413             :     void ReportAndTestGlycols(EnergyPlusData &state);
     414             : 
     415             :     void ReportAndTestRefrigerants(EnergyPlusData &state);
     416             : 
     417             :     Real64 GetQualityRefrig(EnergyPlusData &state,
     418             :                             std::string const &Refrigerant, // carries in substance name
     419             :                             Real64 Temperature,             // actual temperature given as input
     420             :                             Real64 Enthalpy,                // actual enthalpy given as input
     421             :                             int &RefrigIndex,               // Index to Refrigerant Properties
     422             :                             std::string_view CalledFrom     // routine this function was called from (error messages)
     423             :     );
     424             : 
     425             :     Real64 GetSatPressureRefrig(EnergyPlusData &state,
     426             :                                 std::string_view Refrigerant, // carries in substance name
     427             :                                 Real64 Temperature,           // actual temperature given as input
     428             :                                 int &RefrigIndex,             // Index to Refrigerant Properties
     429             :                                 std::string_view CalledFrom   // routine this function was called from (error messages)
     430             :     );
     431             : 
     432             :     Real64 GetSatTemperatureRefrig(EnergyPlusData &state,
     433             :                                    std::string_view Refrigerant, // carries in substance name
     434             :                                    Real64 Pressure,              // actual temperature given as input
     435             :                                    int &RefrigIndex,             // Index to Refrigerant Properties
     436             :                                    std::string_view CalledFrom   // routine this function was called from (error messages)
     437             :     );
     438             : 
     439             :     Real64 GetSatEnthalpyRefrig(EnergyPlusData &state,
     440             :                                 std::string_view Refrigerant, // carries in substance name
     441             :                                 Real64 Temperature,           // actual temperature given as input
     442             :                                 Real64 Quality,               // actual quality given as input
     443             :                                 int &RefrigIndex,             // Index to Refrigerant Properties
     444             :                                 std::string_view CalledFrom   // routine this function was called from (error messages)
     445             :     );
     446             : 
     447             :     Real64 GetSatDensityRefrig(EnergyPlusData &state,
     448             :                                std::string_view Refrigerant, // carries in substance name
     449             :                                Real64 Temperature,           // actual temperature given as input
     450             :                                Real64 Quality,               // actual quality given as input
     451             :                                int &RefrigIndex,             // Index to Refrigerant Properties
     452             :                                std::string_view CalledFrom   // routine this function was called from (error messages)
     453             :     );
     454             : 
     455             :     Real64 GetSatSpecificHeatRefrig(EnergyPlusData &state,
     456             :                                     std::string_view Refrigerant, // carries in substance name
     457             :                                     Real64 Temperature,           // actual temperature given as input
     458             :                                     Real64 Quality,               // actual quality given as input
     459             :                                     int &RefrigIndex,             // Index to Refrigerant Properties
     460             :                                     std::string_view CalledFrom   // routine this function was called from (error messages)
     461             :     );
     462             : 
     463             :     Real64 GetSupHeatEnthalpyRefrig(EnergyPlusData &state,
     464             :                                     std::string_view 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 CalledFrom   // routine this function was called from (error messages)
     469             :     );
     470             : 
     471             :     Real64 GetSupHeatPressureRefrig(EnergyPlusData &state,
     472             :                                     std::string_view Refrigerant, // carries in substance name
     473             :                                     Real64 Temperature,           // actual temperature given as input
     474             :                                     Real64 Enthalpy,              // actual enthalpy given as input
     475             :                                     int &RefrigIndex,             // Index to Refrigerant Properties
     476             :                                     std::string_view CalledFrom   // routine this function was called from (error messages)
     477             :     );
     478             : 
     479             :     Real64 GetSupHeatTempRefrig(EnergyPlusData &state,
     480             :                                 std::string_view Refrigerant, // carries in substance name
     481             :                                 Real64 Pressure,              // actual pressure given as input
     482             :                                 Real64 Enthalpy,              // actual enthalpy given as input
     483             :                                 Real64 TempLow,               // lower bound of temperature in the iteration
     484             :                                 Real64 TempUp,                // upper bound of temperature in the iteration
     485             :                                 int &RefrigIndex,             // Index to Refrigerant Properties
     486             :                                 std::string_view CalledFrom   // routine this function was called from (error messages)
     487             :     );
     488             : 
     489             :     Real64 GetSupHeatDensityRefrig(EnergyPlusData &state,
     490             :                                    std::string_view Refrigerant, // carries in substance name
     491             :                                    Real64 Temperature,           // actual temperature given as input
     492             :                                    Real64 Pressure,              // actual pressure given as input
     493             :                                    int &RefrigIndex,             // Index to Refrigerant Properties
     494             :                                    std::string_view CalledFrom   // routine this function was called from (error messages)
     495             :     );
     496             : 
     497             :     Real64 GetSpecificHeatGlycol(EnergyPlusData &state,
     498             :                                  std::string_view Glycol,    // carries in substance name
     499             :                                  Real64 Temperature,         // actual temperature given as input
     500             :                                  int &GlycolIndex,           // Index to Glycol Properties
     501             :                                  std::string_view CalledFrom // routine this function was called from (error messages)
     502             :     );
     503             : 
     504             :     Real64 GetDensityGlycol(EnergyPlusData &state,
     505             :                             std::string_view Glycol,    // carries in substance name
     506             :                             Real64 Temperature,         // actual temperature given as input
     507             :                             int &GlycolIndex,           // Index to Glycol Properties
     508             :                             std::string_view CalledFrom // routine this function was called from (error messages)
     509             :     );
     510             : 
     511             :     Real64 GetConductivityGlycol(EnergyPlusData &state,
     512             :                                  std::string_view Glycol,    // carries in substance name
     513             :                                  Real64 Temperature,         // actual temperature given as input
     514             :                                  int &GlycolIndex,           // Index to Glycol Properties
     515             :                                  std::string_view CalledFrom // routine this function was called from (error messages)
     516             :     );
     517             : 
     518             :     Real64 GetViscosityGlycol(EnergyPlusData &state,
     519             :                               std::string_view Glycol,    // carries in substance name
     520             :                               Real64 Temperature,         // actual temperature given as input
     521             :                               int &GlycolIndex,           // Index to Glycol Properties
     522             :                               std::string_view CalledFrom // routine this function was called from (error messages)
     523             :     );
     524             : 
     525    22369875 :     inline Real64 GetInterpValue(Real64 const Tact, // actual temperature at which we want the property of interest
     526             :                                  Real64 const Tlo,  // temperature below Tact for which we have property data
     527             :                                  Real64 const Thi,  // temperature above Tact for which we have property data
     528             :                                  Real64 const Xlo,  // value of property at Tlo
     529             :                                  Real64 const Xhi   // value of property at Thi
     530             :     )
     531             :     {
     532    22369875 :         return Xhi - (((Thi - Tact) / (Thi - Tlo)) * (Xhi - Xlo));
     533             :     }
     534             : 
     535             :     int GetRefrigNum(EnergyPlusData &state, std::string_view name);
     536             :     RefrigProps *GetRefrig(EnergyPlusData &state, std::string_view name);
     537             : 
     538             :     int GetGlycolRawNum(EnergyPlusData &state, std::string_view name);
     539             :     GlycolRawProps *GetGlycolRaw(EnergyPlusData &state, std::string_view name);
     540             : 
     541             :     int GetGlycolNum(EnergyPlusData &state, std::string_view name);
     542             :     GlycolProps *GetGlycol(EnergyPlusData &state, std::string_view name);
     543             : 
     544             :     std::string GetGlycolNameByIndex(EnergyPlusData &state, int Idx); // carries in substance index
     545             : 
     546             :     int FindArrayIndex(Real64 Value,                 // Value to be placed/found within the array of values
     547             :                        Array1D<Real64> const &Array, // Array of values in ascending order
     548             :                        int LowBound,                 // Valid values lower bound (set by calling program)
     549             :                        int UpperBound                // Valid values upper bound (set by calling program)
     550             :     );
     551             : 
     552             :     int FindArrayIndex(Real64 Value,                // Value to be placed/found within the array of values
     553             :                        Array1D<Real64> const &Array // Array of values in ascending order
     554             :     );
     555             : 
     556             :     Real64 GetInterpolatedSatProp(EnergyPlusData &state,
     557             :                                   Real64 Temperature,               // Saturation Temp.
     558             :                                   Array1D<Real64> const &PropTemps, // Array of temperature at which props are available
     559             :                                   Array1D<Real64> const &LiqProp,   // Array of saturated liquid properties
     560             :                                   Array1D<Real64> const &VapProp,   // Array of saturatedvapour properties
     561             :                                   Real64 Quality,                   // Quality
     562             :                                   std::string_view CalledFrom,      // routine this function was called from (error messages)
     563             :                                   int LowBound,                     // Valid values lower bound (set by calling program)
     564             :                                   int UpperBound                    // Valid values upper bound (set by calling program)
     565             :     );
     566             : 
     567             :     bool CheckFluidPropertyName(EnergyPlusData const &state,
     568             :                                 std::string const &NameToCheck); // Name from input(?) to be checked against valid FluidPropertyNames
     569             : 
     570             :     void ReportOrphanFluids(EnergyPlusData &state);
     571             : 
     572             :     void GetFluidDensityTemperatureLimits(EnergyPlusData &state, int FluidIndex, Real64 &MinTempLimit, Real64 &MaxTempLimit);
     573             : 
     574             :     void GetFluidSpecificHeatTemperatureLimits(EnergyPlusData &state, int FluidIndex, Real64 &MinTempLimit, Real64 &MaxTempLimit);
     575             : 
     576             :     struct GlycolAPI
     577             :     {
     578             :         std::string glycolName;
     579             :         int glycolIndex;
     580             :         std::string cf;
     581             :         explicit GlycolAPI(EnergyPlusData &state, std::string const &glycolName);
     582           0 :         ~GlycolAPI() = default;
     583             :         Real64 specificHeat(EnergyPlusData &state, Real64 temperature);
     584             :         Real64 density(EnergyPlusData &state, Real64 temperature);
     585             :         Real64 conductivity(EnergyPlusData &state, Real64 temperature);
     586             :         Real64 viscosity(EnergyPlusData &state, Real64 temperature);
     587             :     };
     588             : 
     589             :     struct RefrigerantAPI
     590             :     {
     591             :         std::string rName;
     592             :         int rIndex;
     593             :         std::string cf;
     594             :         explicit RefrigerantAPI(EnergyPlusData &state, std::string const &refrigName);
     595           0 :         ~RefrigerantAPI() = default;
     596             :         Real64 saturationPressure(EnergyPlusData &state, Real64 temperature);
     597             :         Real64 saturationTemperature(EnergyPlusData &state, Real64 pressure);
     598             :         Real64 saturatedEnthalpy(EnergyPlusData &state, Real64 temperature, Real64 quality);
     599             :         Real64 saturatedDensity(EnergyPlusData &state, Real64 temperature, Real64 quality);
     600             :         Real64 saturatedSpecificHeat(EnergyPlusData &state, Real64 temperature, Real64 quality);
     601             :         Real64 superHeatedEnthalpy(EnergyPlusData &state, Real64 temperature, Real64 pressure);
     602             :         Real64 superHeatedPressure(EnergyPlusData &state, Real64 temperature, Real64 enthalpy);
     603             :         Real64 superHeatedDensity(EnergyPlusData &state, Real64 temperature, Real64 pressure);
     604             :     };
     605             : 
     606             : } // namespace FluidProperties
     607             : 
     608             : struct FluidData : BaseGlobalStruct
     609             : {
     610             :     bool DebugReportGlycols = false;
     611             :     bool DebugReportRefrigerants = false;
     612             :     int GlycolErrorLimitTest = 1; // how many times error is printed with details before recurring called
     613             :     int RefrigErrorLimitTest = 1; // how many times error is printed with details before recurring called
     614             : 
     615             :     Array1D<FluidProperties::RefrigProps *> refrigs;
     616             :     Array1D<FluidProperties::GlycolRawProps *> glycolsRaw;
     617             :     Array1D<FluidProperties::GlycolProps *> glycols;
     618             : 
     619             :     std::array<int, (int)FluidProperties::GlycolError::Num> glycolErrorLimits = {0, 0, 0, 0, 0, 0, 0, 0};
     620             : 
     621             :     int SatErrCountGetSupHeatEnthalpyRefrig = 0;
     622             :     int SatErrCountGetSupHeatDensityRefrig = 0;
     623             :     int TempLoRangeErrIndexGetQualityRefrig = 0;
     624             :     int TempHiRangeErrIndexGetQualityRefrig = 0;
     625             :     int TempRangeErrCountGetInterpolatedSatProp = 0;
     626             :     int TempRangeErrIndexGetInterpolatedSatProp = 0;
     627             : 
     628             : #ifdef EP_cache_GlycolSpecificHeat
     629             :     std::array<FluidProperties::cached_tsh, FluidProperties::t_sh_cache_size> cached_t_sh;
     630             : #endif
     631             : 
     632         796 :     void init_state(EnergyPlusData &state) override
     633             :     {
     634         796 :         FluidProperties::GetFluidPropertiesData(state);
     635         796 :     }
     636             : 
     637           0 :     void clear_state() override
     638             :     {
     639             : 
     640           0 :         for (int i = 1; i <= refrigs.isize(); ++i)
     641           0 :             delete refrigs(i);
     642           0 :         for (int i = 1; i <= glycolsRaw.isize(); ++i)
     643           0 :             delete glycolsRaw(i);
     644           0 :         for (int i = 1; i <= glycols.isize(); ++i)
     645           0 :             delete glycols(i);
     646             : 
     647           0 :         new (this) FluidData();
     648           0 :     }
     649             : };
     650             : 
     651             : } // namespace EnergyPlus
     652             : 
     653             : #endif

Generated by: LCOV version 1.14