LCOV - code coverage report
Current view: top level - EnergyPlus - TARCOGGasses90.cc (source / functions) Coverage Total Hit
Test: lcov.output.filtered Lines: 0.0 % 96 0
Test Date: 2025-05-22 16:09:37 Functions: 0.0 % 2 0

            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              : // C++ Headers
      49              : #include <cassert>
      50              : 
      51              : // ObjexxFCL Headers
      52              : #include <ObjexxFCL/Array1D.hh>
      53              : #include <ObjexxFCL/Array2D.hh>
      54              : 
      55              : // EnergyPlus Headers
      56              : #include <EnergyPlus/Data/EnergyPlusData.hh>
      57              : #include <EnergyPlus/DataGlobals.hh>
      58              : #include <EnergyPlus/TARCOGGasses90.hh>
      59              : #include <EnergyPlus/TARCOGGassesParams.hh>
      60              : 
      61              : namespace EnergyPlus::TARCOGGasses90 {
      62              : 
      63              : // MODULE INFORMATION:
      64              : //       AUTHOR         D. Charlie Curcija
      65              : //       DATE WRITTEN   June/2000
      66              : //       MODIFIED       (see revision history bellow)
      67              : //       RE-ENGINEERED  na
      68              : //  Revision: 7.0.02  (November/8/2011), Simon Vidanovic
      69              : //   - feature: Error message (string) return from gasses
      70              : //  Revision: 7.0.00  (September/6/2011), Simon Vidanovic
      71              : //   - Introduction of vacuum coefficients and routine to calculate low gas pressure conductance
      72              : //  Revision: 6.3.09  (August/23/2011), Simon Vidanovic
      73              : //   - Removed GetGasIndex function which could cause a double usage of gas coefficients
      74              : //     and therefore introducing new bugs.
      75              : 
      76              : // PURPOSE OF THIS MODULE:
      77              : // A module containing functions for gas properties calculation
      78              : 
      79              : // Using/Aliasing
      80              : using namespace TARCOGGassesParams;
      81              : 
      82            0 : void GASSES90(EnergyPlusData &state,
      83              :               Real64 const tmean,
      84              :               const Array1D_int &iprop,
      85              :               const Array1D<Real64> &frct,
      86              :               Real64 const pres,
      87              :               int const nmix,
      88              :               const Array1D<Real64> &xwght,
      89              :               Array2<Real64> const &xgcon,
      90              :               Array2<Real64> const &xgvis,
      91              :               Array2<Real64> const &xgcp,
      92              :               Real64 &con,
      93              :               Real64 &visc,
      94              :               Real64 &dens,
      95              :               Real64 &cp,
      96              :               Real64 &pr,
      97              :               TARCOGGassesParams::Stdrd const standard,
      98              :               int &nperr,
      99              :               std::string &ErrorMessage)
     100              : {
     101              : 
     102              :     static Real64 const two_sqrt_2(2.0 * std::sqrt(2.0));
     103              :     Real64 molmix;
     104              :     Real64 cpmixm;
     105              :     Real64 phimup;
     106              :     Real64 downer;
     107              :     Real64 psiup;
     108              :     Real64 psiterm;
     109              :     Real64 phikup;
     110              : 
     111              :     // SUBROUTINE PARAMETER DEFINITIONS:
     112            0 :     Real64 constexpr ENpressure(1.0e5); // Gap gas pressure (Pa)
     113            0 :     Real64 constexpr gaslaw(8314.51);   // Molar gas constant (J/kMol-K)
     114              : 
     115              :     //!! Body of GASSES90
     116              : 
     117              :     // Autodesk:Uninit Initialize variables used uninitialized
     118              :     // xgrho = 0.0d0 //Autodesk:Uninit Force default initialization
     119              : 
     120            0 :     Real64 const tmean_2(pow_2(tmean));
     121            0 :     state.dataTARCOGGasses90->fcon(1) = xgcon(1, iprop(1)) + xgcon(2, iprop(1)) * tmean + xgcon(3, iprop(1)) * tmean_2;
     122            0 :     state.dataTARCOGGasses90->fvis(1) = xgvis(1, iprop(1)) + xgvis(2, iprop(1)) * tmean + xgvis(3, iprop(1)) * tmean_2;
     123            0 :     state.dataTARCOGGasses90->fcp(1) = xgcp(1, iprop(1)) + xgcp(2, iprop(1)) * tmean + xgcp(3, iprop(1)) * tmean_2;
     124              :     // Density using ideal gas law: rho=(presure*mol. weight)/(gas const*Tmean)
     125            0 :     state.dataTARCOGGasses90->fdens(1) = pres * xwght(iprop(1)) / (Constant::UniversalGasConst * tmean);
     126              :     // Mollecular weights in kg/kmol
     127            0 :     if ((standard == TARCOGGassesParams::Stdrd::EN673) || (standard == TARCOGGassesParams::Stdrd::EN673Design)) {
     128              :         // fdens( 1 ) = xgrho( iprop( 1 ), 1 ) + xgrho( iprop( 1 ), 2 ) * tmean + xgrho( iprop( 1 ), 3 ) * pow_2( tmean ); //Autodesk:Uninit xgrho
     129              :         // was uninitialized
     130            0 :         state.dataTARCOGGasses90->fdens(1) = ENpressure * xwght(iprop(1)) / (gaslaw * tmean);
     131              :     }
     132              : 
     133            0 :     if (frct(1) == 1.0) {                          // Single gas properties
     134            0 :         visc = state.dataTARCOGGasses90->fvis(1);  // viscosity in kg/(m*s)
     135            0 :         con = state.dataTARCOGGasses90->fcon(1);   // conductivity in W/(m*K)
     136            0 :         cp = state.dataTARCOGGasses90->fcp(1);     // SpecIFic heat in J/(kg*K)
     137            0 :         dens = state.dataTARCOGGasses90->fdens(1); // density in kg/m^3
     138              :     } else {                                       // Mixture properties
     139            0 :         bool const stdISO15099(standard == TARCOGGassesParams::Stdrd::ISO15099);
     140            0 :         bool const stdEN673((standard == TARCOGGassesParams::Stdrd::EN673) || (standard == TARCOGGassesParams::Stdrd::EN673Design));
     141            0 :         if (stdISO15099) {
     142            0 :             molmix = frct(1) * xwght(iprop(1));                 // initialize equation 56
     143            0 :             cpmixm = molmix * state.dataTARCOGGasses90->fcp(1); // initialize equation 58
     144            0 :             state.dataTARCOGGasses90->kprime(1) =
     145            0 :                 3.75 * Constant::UniversalGasConst / xwght(iprop(1)) * state.dataTARCOGGasses90->fvis(1);                   // equation 67
     146            0 :             state.dataTARCOGGasses90->kdblprm(1) = state.dataTARCOGGasses90->fcon(1) - state.dataTARCOGGasses90->kprime(1); // equation 67
     147              :             // initialize sumations for eqns 60-66:
     148            0 :             state.dataTARCOGGasses90->mukpdwn(1) = 1.0;
     149            0 :             state.dataTARCOGGasses90->kpdown(1) = 1.0;
     150            0 :             state.dataTARCOGGasses90->kdpdown(1) = 1.0;
     151              :         }
     152            0 :         for (int i = 2; i <= nmix; ++i) {
     153            0 :             if (frct(i) == 0.0) {
     154            0 :                 nperr = 2011; // error 2011: component fraction in a mixture is 0%
     155            0 :                 ErrorMessage = "Component fraction in mixture is 0%";
     156            0 :                 return;
     157              :             }
     158              :             // calculate properties of mixture constituents:
     159            0 :             state.dataTARCOGGasses90->fcon(i) = xgcon(1, iprop(i)) + xgcon(2, iprop(i)) * tmean + xgcon(3, iprop(i)) * tmean_2;
     160            0 :             state.dataTARCOGGasses90->fvis(i) = xgvis(1, iprop(i)) + xgvis(2, iprop(i)) * tmean + xgvis(3, iprop(i)) * tmean_2;
     161            0 :             state.dataTARCOGGasses90->fcp(i) = xgcp(1, iprop(i)) + xgcp(2, iprop(i)) * tmean + xgcp(3, iprop(i)) * tmean_2;
     162            0 :             if (stdEN673) {
     163              :                 // fdens( i ) = grho( iprop( i ), 1 ) + grho( iprop( i ), 2 ) * tmean + grho( iprop( i ), 3 ) * pow_2( tmean );
     164            0 :                 state.dataTARCOGGasses90->fdens(i) =
     165            0 :                     ENpressure * xwght(iprop(i)) / (gaslaw * tmean); // Density using ideal gas law: rho=(presure*mol. weight)/(gas const*Tmean)
     166              :             }
     167            0 :             if (stdISO15099) {
     168            0 :                 molmix += frct(i) * xwght(iprop(i));                                    // equation 56
     169            0 :                 cpmixm += frct(i) * state.dataTARCOGGasses90->fcp(i) * xwght(iprop(i)); // equation 58-59
     170            0 :                 state.dataTARCOGGasses90->kprime(i) =
     171            0 :                     3.75 * Constant::UniversalGasConst / xwght(iprop(i)) * state.dataTARCOGGasses90->fvis(i);                   // equation 67
     172            0 :                 state.dataTARCOGGasses90->kdblprm(i) = state.dataTARCOGGasses90->fcon(i) - state.dataTARCOGGasses90->kprime(i); // equation 68
     173            0 :                 state.dataTARCOGGasses90->mukpdwn(i) = 1.0; // initialize denominator of equation 60
     174            0 :                 state.dataTARCOGGasses90->kpdown(i) = 1.0;  // initialize denominator of equation 63
     175            0 :                 state.dataTARCOGGasses90->kdpdown(i) = 1.0; // initialize denominator of equation 65
     176              :             }
     177              :         }
     178              : 
     179            0 :         if (stdISO15099) {
     180            0 :             Real64 mumix(0.0);
     181            0 :             Real64 kpmix(0.0);
     182            0 :             Real64 kdpmix(0.0);
     183            0 :             for (int i = 1; i <= nmix; ++i) {
     184            0 :                 Real64 const kprime_i(state.dataTARCOGGasses90->kprime(i));
     185            0 :                 Real64 const xwght_i(xwght(iprop(i)));
     186            0 :                 for (int j = 1; j <= nmix; ++j) {
     187            0 :                     Real64 const xwght_j(xwght(iprop(j)));
     188              : 
     189              :                     // numerator of equation 61
     190            0 :                     Real64 const x_pow(root_4(xwght_j / xwght_i));
     191            0 :                     phimup = pow_2(1.0 + std::sqrt(state.dataTARCOGGasses90->fvis(i) / state.dataTARCOGGasses90->fvis(j)) * x_pow);
     192              : 
     193              :                     // denominator of equation 61, 64 and 66
     194            0 :                     downer = two_sqrt_2 * std::sqrt(1.0 + (xwght_i / xwght_j));
     195              : 
     196              :                     // calculate the denominator of equation 60
     197            0 :                     if (i != j) state.dataTARCOGGasses90->mukpdwn(i) += phimup / downer * frct(j) / frct(i);
     198              : 
     199              :                     // numerator of equation 64, psiterm is the multiplied term in brackets
     200            0 :                     psiup = pow_2(1.0 + std::sqrt(kprime_i / state.dataTARCOGGasses90->kprime(j)) / x_pow);
     201              : 
     202            0 :                     psiterm = 1.0 + 2.41 * (xwght_i - xwght_j) * (xwght_i - 0.142 * xwght_j) / pow_2(xwght_i + xwght_j);
     203              : 
     204              :                     // using the common denominator downer calculate the denominator for equation 63
     205            0 :                     if (i != j) state.dataTARCOGGasses90->kpdown(i) += psiup * psiterm / downer * frct(j) / frct(i);
     206              : 
     207              :                     // calculate the numerator of equation 66
     208            0 :                     phikup = psiup; // Tuned Was pow_2( 1.0 + std::sqrt( kprime_i / kprime( j ) ) * std::pow( xwght_i / xwght_j, 0.25 ) );
     209              : 
     210              :                     // using the common denominator downer calculate the denominator for equation 65
     211            0 :                     if (i != j) state.dataTARCOGGasses90->kdpdown(i) += phikup / downer * frct(j) / frct(i);
     212              :                 }
     213            0 :                 mumix += state.dataTARCOGGasses90->fvis(i) / state.dataTARCOGGasses90->mukpdwn(i);     // equation 60
     214            0 :                 kpmix += state.dataTARCOGGasses90->kprime(i) / state.dataTARCOGGasses90->kpdown(i);    // equation 63
     215            0 :                 kdpmix += state.dataTARCOGGasses90->kdblprm(i) / state.dataTARCOGGasses90->kdpdown(i); // equation 65
     216              :             }
     217              : 
     218              :             // calculate the density of the mixture assuming an ideal gas:
     219            0 :             Real64 const rhomix = pres * molmix / (Constant::UniversalGasConst * tmean); // equation 57
     220            0 :             Real64 const kmix = kpmix + kdpmix;                                          // equation 68-a
     221              : 
     222              :             // final mixture properties:
     223            0 :             visc = mumix;
     224            0 :             con = kmix;
     225            0 :             dens = rhomix;
     226            0 :             if (molmix > 0) {
     227            0 :                 cp = cpmixm / molmix;
     228              :             } else {
     229            0 :                 cp = 0;
     230              :             }
     231            0 :         } else if (stdEN673) {
     232            0 :             con = 0.0;
     233            0 :             visc = 0.0;
     234            0 :             dens = 0.0;
     235            0 :             cp = 0.0;
     236            0 :             for (int i = 1; i <= nmix; ++i) {
     237            0 :                 Real64 const frct_i(frct(i));
     238            0 :                 con += state.dataTARCOGGasses90->fcon(i) * frct_i;
     239            0 :                 visc += state.dataTARCOGGasses90->fvis(i) * frct_i;
     240            0 :                 dens += state.dataTARCOGGasses90->fdens(i) * frct_i;
     241            0 :                 cp += state.dataTARCOGGasses90->fcp(i) * frct_i;
     242              :             }
     243              :         } else {
     244            0 :             assert(false); // should never come here - unsupported standard
     245              :         }
     246              :     }
     247              : 
     248            0 :     pr = cp * visc / con; // calculate the Prandtl number
     249              : }
     250              : 
     251            0 : void GassesLow(Real64 const tmean, Real64 const mwght, Real64 const pressure, Real64 const gama, Real64 &cond, int &nperr, std::string &ErrorMessage)
     252              : {
     253              : 
     254            0 :     Real64 const alpha = alpha1 * alpha2 / (alpha2 + alpha1 * (1 - alpha2));
     255              : 
     256            0 :     if ((gama) == 1) {
     257            0 :         nperr = 40; // supplied gamma coefficient is incorrect
     258            0 :         ErrorMessage = "Supplied gamma coefficient is incorrect.";
     259            0 :         return;
     260              :     }
     261              : 
     262            0 :     Real64 const B = alpha * (gama + 1) / (gama - 1) * std::sqrt(Constant::UniversalGasConst / (8 * Constant::Pi * mwght * tmean));
     263              : 
     264            0 :     cond = B * pressure;
     265              : }
     266              : 
     267              : } // namespace EnergyPlus::TARCOGGasses90
        

Generated by: LCOV version 2.0-1