LCOV - code coverage report
Current view: top level - EnergyPlus - TarcogShading.cc (source / functions) Hit Total Coverage
Test: lcov.output.filtered Lines: 287 320 89.7 %
Date: 2023-01-17 19:17:23 Functions: 6 7 85.7 %

          Line data    Source code
       1             : // EnergyPlus, Copyright (c) 1996-2023, The Board of Trustees of the University of Illinois,
       2             : // The Regents of the University of California, through Lawrence Berkeley National Laboratory
       3             : // (subject to receipt of any required approvals from the U.S. Dept. of Energy), Oak Ridge
       4             : // National Laboratory, managed by UT-Battelle, Alliance for Sustainable Energy, LLC, and other
       5             : // contributors. All rights reserved.
       6             : //
       7             : // NOTICE: This Software was developed under funding from the U.S. Department of Energy and the
       8             : // U.S. Government consequently retains certain rights. As such, the U.S. Government has been
       9             : // granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable,
      10             : // worldwide license in the Software to reproduce, distribute copies to the public, prepare
      11             : // derivative works, and perform publicly and display publicly, and to permit others to do so.
      12             : //
      13             : // Redistribution and use in source and binary forms, with or without modification, are permitted
      14             : // provided that the following conditions are met:
      15             : //
      16             : // (1) Redistributions of source code must retain the above copyright notice, this list of
      17             : //     conditions and the following disclaimer.
      18             : //
      19             : // (2) Redistributions in binary form must reproduce the above copyright notice, this list of
      20             : //     conditions and the following disclaimer in the documentation and/or other materials
      21             : //     provided with the distribution.
      22             : //
      23             : // (3) Neither the name of the University of California, Lawrence Berkeley National Laboratory,
      24             : //     the University of Illinois, U.S. Dept. of Energy nor the names of its contributors may be
      25             : //     used to endorse or promote products derived from this software without specific prior
      26             : //     written permission.
      27             : //
      28             : // (4) Use of EnergyPlus(TM) Name. If Licensee (i) distributes the software in stand-alone form
      29             : //     without changes from the version obtained under this License, or (ii) Licensee makes a
      30             : //     reference solely to the software portion of its product, Licensee must refer to the
      31             : //     software as "EnergyPlus version X" software, where "X" is the version number Licensee
      32             : //     obtained under this License and may not use a different name for the software. Except as
      33             : //     specifically required in this Section (4), Licensee shall not use in a company name, a
      34             : //     product name, in advertising, publicity, or other promotional activities any name, trade
      35             : //     name, trademark, logo, or other designation of "EnergyPlus", "E+", "e+" or confusingly
      36             : //     similar designation, without the U.S. Department of Energy's prior written consent.
      37             : //
      38             : // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
      39             : // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
      40             : // AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
      41             : // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
      42             : // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
      43             : // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
      44             : // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
      45             : // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
      46             : // POSSIBILITY OF SUCH DAMAGE.
      47             : 
      48             : // ObjexxFCL Headers
      49             : #include <ObjexxFCL/Array1D.hh>
      50             : #include <ObjexxFCL/Fmath.hh>
      51             : 
      52             : // EnergyPlus Headers
      53             : #include <EnergyPlus/Data/EnergyPlusData.hh>
      54             : #include <EnergyPlus/DataGlobals.hh>
      55             : #include <EnergyPlus/TARCOGCommon.hh>
      56             : #include <EnergyPlus/TARCOGGasses90.hh>
      57             : #include <EnergyPlus/TARCOGGassesParams.hh>
      58             : #include <EnergyPlus/TARCOGParams.hh>
      59             : #include <EnergyPlus/TarcogShading.hh>
      60             : 
      61             : namespace EnergyPlus {
      62             : 
      63             : namespace TarcogShading {
      64             : 
      65             :     // MODULE INFORMATION:
      66             :     //       AUTHOR         Simon Vidanovic
      67             :     //       DATE WRITTEN   June/22/2010
      68             :     //       MODIFIED       na
      69             :     //       RE-ENGINEERED  na
      70             :     //  Revision: 6.0.36  (June/22/2010)
      71             :     //   - Initial setup, extracted from TARCOG.for
      72             : 
      73             :     // PURPOSE OF THIS MODULE:
      74             :     // Module which contains subroutines used for handling shading
      75             :     // device layers according to ISO15099
      76             : 
      77             :     // METHODOLOGY EMPLOYED:
      78             :     // <description>
      79             : 
      80             :     // REFERENCES:
      81             :     // na
      82             : 
      83             :     // OTHER NOTES:
      84             :     // na
      85             : 
      86             :     // USE STATEMENTS:
      87             : 
      88             :     // Using/Aliasing
      89             :     using namespace TARCOGGassesParams;
      90             :     using namespace TARCOGGasses90;
      91             :     using namespace TARCOGParams;
      92             : 
      93             :     enum class CalcForcedVentilation
      94             :     {
      95             :         Invalid = -1,
      96             :         Skip,
      97             :         Allow,
      98             :         Num
      99             :     };
     100             : 
     101             :     // Functions
     102             : 
     103      198465 :     void shading(EnergyPlusData &state,
     104             :                  Array1D<Real64> const &theta,
     105             :                  Array1D<Real64> const &gap,
     106             :                  Array1D<Real64> &hgas,
     107             :                  Array1D<Real64> &hcgas,
     108             :                  Array1D<Real64> &hrgas,
     109             :                  Array2<Real64> const &frct,
     110             :                  Array2_int const &iprop,
     111             :                  Array1D<Real64> const &pressure,
     112             :                  Array1D_int const &nmix,
     113             :                  const Array1D<Real64> &xwght,
     114             :                  Array2<Real64> const &xgcon,
     115             :                  Array2<Real64> const &xgvis,
     116             :                  Array2<Real64> const &xgcp,
     117             :                  int const nlayer,
     118             :                  Real64 const width,
     119             :                  Real64 const height,
     120             :                  Real64 const angle,
     121             :                  Real64 const Tout,
     122             :                  Real64 const Tin,
     123             :                  Array1D<Real64> const &Atop,
     124             :                  Array1D<Real64> const &Abot,
     125             :                  Array1D<Real64> const &Al,
     126             :                  Array1D<Real64> const &Ar,
     127             :                  Array1D<Real64> const &Ah,
     128             :                  Array1D<Real64> const &vvent,
     129             :                  Array1D<Real64> const &tvent,
     130             :                  Array1D<TARCOGLayerType> LayerType,
     131             :                  Array1D<Real64> &Tgaps,
     132             :                  Array1D<Real64> &qv,
     133             :                  Array1D<Real64> &hcv, // Heat transfer coeefficient in gaps including airlow
     134             :                  int &nperr,
     135             :                  std::string &ErrorMessage,
     136             :                  Array1D<Real64> &vfreevent)
     137             :     {
     138             :         //**************************************************************************************************************
     139             :         //  Input:
     140             :         // theta   Vector of average temperatures
     141             :         //  gap      Vector of gap widths (maxlay) [m]
     142             :         //  hgas    Convective part of gap effective conductivity
     143             :         //  frct    Fraction of gasses in a mixture (maxlay1,maxgas)
     144             :         //  iprop    Vector of gas identifers (maxlay1,maxgas)
     145             :         //  pressure  Vector of gas pressures [N/m^2]
     146             :         //  nmix    Vector of number of gasses for each mixture (maxgas=10)
     147             :         //  nlayer  Number of glazing layers
     148             :         //  width    IGU cavity width [m]
     149             :         //  height  IGU cavity height [m]
     150             :         //  angle    Window angle [degrees]
     151             :         //  Tout    Outdoor temperature [K]
     152             :         //  Tin      Indoor temperature [K]
     153             :         //  Atop    Opening between top of shading device and top of glazing cavity [m^2]
     154             :         //  Abot    Opening between bottom of shading device and bottom of glazing cavity [m^2]
     155             :         //  Al      Opening between left of shading device and left end of glazing cavity [m^2]
     156             :         //  Ar      Opening between right of shading device and right end of glazing cavity [m^2]
     157             :         //  Ah      Total area holes in the shading device [m^2]
     158             :         //  LayerType    Vector of layer types (0 - glazing; 1 - shading)
     159             :         //  Ebf      Vector of emissive power of the front surface (# of layers)
     160             :         //  Input/Output:
     161             :         //  Tgaps    Vector of gap temperatures [K]
     162             :         //  Output:
     163             :         //  qv      Vector of heat transfer to the gap by vetilation [W/m^2]
     164             :         //  hhatv    Vector of all film coefficients for vented cavities (maxlay3)
     165             :         //  hcv      Vector of surface-to-air heat transfer coefficients by condction/convection for vented cavities [W/(m^2*K)]
     166             :         //  Ebgap    Vector of emissive power of the vented cavities (maxlay3)
     167             :         //  nperr    Error flag
     168             :         // vfreevent   Vector of free ventilation velocities in gaps
     169             :         //**************************************************************************************************************
     170             : 
     171             :         // Using/Aliasing
     172             :         using namespace TARCOGCommon;
     173             : 
     174             :         // Locals
     175             :         // REAL(r64), intent(in) :: Ebf(maxlay)
     176             : 
     177             :         Real64 Atops;
     178             :         Real64 Abots;
     179             :         Real64 Als;
     180             :         Real64 Ars;
     181             :         Real64 Ahs;
     182             :         Real64 press1;
     183             :         Real64 press2;
     184             :         Real64 s1;
     185             :         Real64 s2;
     186             :         Real64 s;
     187             :         Real64 hcvs;
     188             :         Real64 qvs;
     189             :         Real64 hc;
     190             :         Real64 hc1;
     191             :         Real64 hc2;
     192             :         Real64 speed;
     193             :         Real64 Tav;
     194             :         Real64 Tgap;
     195             :         Real64 Temp;
     196             :         Real64 speed1;
     197             :         Real64 speed2;
     198             :         Real64 Tav1;
     199             :         Real64 Tav2;
     200             :         Real64 Tgap1;
     201             :         Real64 Tgap2;
     202             :         Real64 hcv1;
     203             :         Real64 hcv2;
     204             :         Real64 qv1;
     205             :         Real64 qv2;
     206             : 
     207             :         int i;
     208             :         int j;
     209             :         int k;
     210             :         int nmix1;
     211             :         int nmix2;
     212             : 
     213             :         // init vectors:
     214      198465 :         qv = 0.0;
     215      198465 :         hcv = 0.0;
     216             :         // hhatv = 0.0d0
     217             :         // Ebgap = 0.0d0
     218             :         // hcv = 0.0d0
     219             : 
     220             :         // main loop:
     221      766926 :         for (i = 1; i <= nlayer; ++i) {
     222      568461 :             k = 2 * i + 1;
     223             :             // if (LayerType(i).eq.VENETBLIND) then
     224      568461 :             if (IsShadingLayer(LayerType(i))) {
     225             :                 // dr.........set Shading device geometry
     226      154646 :                 Atops = Atop(i);
     227      154646 :                 Abots = Abot(i);
     228      154646 :                 Als = Al(i);
     229      154646 :                 Ars = Ar(i);
     230      154646 :                 Ahs = Ah(i);
     231             : 
     232             :                 // dr.....setting gas properies for two adjacent gaps (or enviroment)
     233      154646 :                 nmix1 = nmix(i);
     234      154646 :                 nmix2 = nmix(i + 1);
     235      154646 :                 press1 = pressure(i);
     236      154646 :                 press2 = pressure(i + 1);
     237     1701106 :                 for (j = 1; j <= maxgas; ++j) {
     238     1546460 :                     state.dataTarcogShading->iprop1(j) = iprop(j, i);
     239     1546460 :                     state.dataTarcogShading->iprop2(j) = iprop(j, i + 1);
     240     1546460 :                     state.dataTarcogShading->frct1(j) = frct(j, i);
     241     1546460 :                     state.dataTarcogShading->frct2(j) = frct(j, i + 1);
     242             :                 } // j
     243             : 
     244             :                 // dr.......shading on outdoor side
     245      154646 :                 if (i == 1) {
     246       52648 :                     s = gap(1);
     247       52648 :                     hc = hcgas(2);
     248             :                     // Tenv = tvent(1)
     249       52648 :                     Tav = (theta(2) + theta(3)) / 2.0;
     250       52648 :                     Tgap = Tgaps(2);
     251             : 
     252             :                     // bi......use Tout as temp of the air at inlet
     253      263240 :                     shadingedge(state,
     254       52648 :                                 state.dataTarcogShading->iprop1,
     255       52648 :                                 state.dataTarcogShading->frct1,
     256             :                                 press1,
     257             :                                 nmix1,
     258       52648 :                                 state.dataTarcogShading->iprop2,
     259       52648 :                                 state.dataTarcogShading->frct2,
     260             :                                 press2,
     261             :                                 nmix2,
     262             :                                 xwght,
     263             :                                 xgcon,
     264             :                                 xgvis,
     265             :                                 xgcp,
     266             :                                 Atops,
     267             :                                 Abots,
     268             :                                 Als,
     269             :                                 Ars,
     270             :                                 Ahs,
     271             :                                 s,
     272             :                                 height,
     273             :                                 width,
     274             :                                 angle,
     275       52648 :                                 vvent(2),
     276             :                                 hc,
     277             :                                 Tout,
     278             :                                 Tav,
     279             :                                 Tgap,
     280             :                                 hcvs,
     281             :                                 qvs,
     282             :                                 nperr,
     283             :                                 ErrorMessage,
     284             :                                 speed);
     285             : 
     286             :                     // exit on error
     287       52648 :                     if ((nperr > 0) && (nperr < 1000)) return;
     288             : 
     289       52648 :                     Tgaps(2) = Tgap;
     290             :                     // Ebgap(3) = sigma * Tgap ** 4
     291             : 
     292       52648 :                     hcgas(2) = hcvs / 2.0;
     293       52648 :                     hgas(2) = hcgas(2) + hrgas(2);
     294       52648 :                     hcv(2) = hcvs;
     295       52648 :                     qv(2) = qvs;
     296             : 
     297             :                     // bi.........Add free ventilation velocity
     298       52648 :                     vfreevent(2) = speed;
     299             :                 } // if (i.eq.1) then
     300             : 
     301             :                 // dr.......shading on indoor side
     302      154646 :                 if (i == nlayer) {
     303       81816 :                     if (nlayer > 1) {
     304       81816 :                         s = gap(nlayer - 1); // Autodesk:BoundsViolation gap(nlayer - 1) @ nlayer=1: Fixed with if block
     305       81816 :                         Tav = (theta(2 * nlayer - 1) + theta(2 * nlayer - 2)) /
     306             :                               2.0; // Autodesk:BoundsViolation theta(2 * nlayer - 2) @ nlayer=1: Fixed with if block in 8.2
     307             :                     } else {
     308           0 :                         s = 0.0;
     309           0 :                         Tav = 273.15;
     310             :                     }
     311       81816 :                     hc = hcgas(nlayer);
     312             :                     // Tenv = tvent(nlayer + 1)
     313             : 
     314       81816 :                     Tgap = Tgaps(nlayer);
     315             : 
     316             :                     // bi.........use Tin as temp of the air at inlet
     317      409080 :                     shadingedge(state,
     318       81816 :                                 state.dataTarcogShading->iprop2,
     319       81816 :                                 state.dataTarcogShading->frct2,
     320             :                                 press2,
     321             :                                 nmix2,
     322       81816 :                                 state.dataTarcogShading->iprop1,
     323       81816 :                                 state.dataTarcogShading->frct1,
     324             :                                 press1,
     325             :                                 nmix1,
     326             :                                 xwght,
     327             :                                 xgcon,
     328             :                                 xgvis,
     329             :                                 xgcp,
     330             :                                 Atops,
     331             :                                 Abots,
     332             :                                 Als,
     333             :                                 Ars,
     334             :                                 Ahs,
     335             :                                 s,
     336             :                                 height,
     337             :                                 width,
     338             :                                 angle,
     339       81816 :                                 vvent(nlayer),
     340             :                                 hc,
     341             :                                 Tin,
     342             :                                 Tav,
     343             :                                 Tgap,
     344             :                                 hcvs,
     345             :                                 qvs,
     346             :                                 nperr,
     347             :                                 ErrorMessage,
     348             :                                 speed);
     349             : 
     350             :                     // exit on error
     351       81816 :                     if ((nperr > 0) && (nperr < 1000)) return;
     352             : 
     353       81816 :                     Tgaps(nlayer) = Tgap;
     354       81816 :                     hcgas(nlayer) = hcvs / 2.0;
     355       81816 :                     hgas(nlayer) = hcgas(nlayer) + hrgas(nlayer);
     356       81816 :                     hcv(nlayer) = hcvs;
     357       81816 :                     qv(nlayer) = qvs;
     358             : 
     359             :                     // bi.........Add free ventilation velocity
     360       81816 :                     vfreevent(i) = speed;
     361             :                 } // if (i.eq.nlayer) then
     362             : 
     363             :                 // dr.......shading between glass layers
     364      154646 :                 if ((i > 1) && (i < nlayer)) {
     365             :                     // dr.........average temperatures
     366       20182 :                     Tav1 = (theta(2 * i - 2) + theta(2 * i - 1)) / 2.0;
     367       20182 :                     Tav2 = (theta(2 * i) + theta(2 * i + 1)) / 2.0;
     368       20182 :                     Tgap1 = Tgaps(i);
     369       20182 :                     Tgap2 = Tgaps(i + 1);
     370             : 
     371       20182 :                     hc1 = hcgas(i);
     372       20182 :                     hc2 = hcgas(i + 1);
     373       20182 :                     if (i > 1) s1 = gap(i - 1);
     374       20182 :                     s2 = gap(i);
     375             : 
     376             :                     // speed1 = vvent(i)
     377             :                     // speed2 = vvent(i+1)
     378             : 
     379       20182 :                     if ((static_cast<int>(CalcForcedVentilation::Allow)) && ((vvent(i) != 0) || (vvent(i + 1) != 0))) {
     380           0 :                         forcedventilation(state,
     381           0 :                                           state.dataTarcogShading->iprop1,
     382           0 :                                           state.dataTarcogShading->frct1,
     383             :                                           press1,
     384             :                                           nmix1,
     385             :                                           xwght,
     386             :                                           xgcon,
     387             :                                           xgvis,
     388             :                                           xgcp,
     389             :                                           s1,
     390             :                                           height,
     391             :                                           hc1,
     392           0 :                                           vvent(i),
     393           0 :                                           tvent(i),
     394             :                                           Temp,
     395             :                                           Tav1,
     396             :                                           hcv1,
     397             :                                           qv1,
     398             :                                           nperr,
     399             :                                           ErrorMessage);
     400           0 :                         forcedventilation(state,
     401           0 :                                           state.dataTarcogShading->iprop2,
     402           0 :                                           state.dataTarcogShading->frct2,
     403             :                                           press2,
     404             :                                           nmix1,
     405             :                                           xwght,
     406             :                                           xgcon,
     407             :                                           xgvis,
     408             :                                           xgcp,
     409             :                                           s2,
     410             :                                           height,
     411             :                                           hc1,
     412           0 :                                           vvent(i + 1),
     413           0 :                                           tvent(i + 1),
     414             :                                           Temp,
     415             :                                           Tav2,
     416             :                                           hcv2,
     417             :                                           qv2,
     418             :                                           nperr,
     419             :                                           ErrorMessage);
     420             :                     } else {
     421      100910 :                         shadingin(state,
     422       20182 :                                   state.dataTarcogShading->iprop1,
     423       20182 :                                   state.dataTarcogShading->frct1,
     424             :                                   press1,
     425             :                                   nmix1,
     426       20182 :                                   state.dataTarcogShading->iprop2,
     427       20182 :                                   state.dataTarcogShading->frct2,
     428             :                                   press2,
     429             :                                   nmix2,
     430             :                                   xwght,
     431             :                                   xgcon,
     432             :                                   xgvis,
     433             :                                   xgcp,
     434             :                                   Atops,
     435             :                                   Abots,
     436             :                                   Als,
     437             :                                   Ars,
     438             :                                   Ahs,
     439             :                                   s1,
     440             :                                   s2,
     441             :                                   height,
     442             :                                   width,
     443             :                                   angle,
     444             :                                   hc1,
     445             :                                   hc2,
     446             :                                   speed1,
     447             :                                   speed2,
     448             :                                   Tgap1,
     449             :                                   Tgap2,
     450             :                                   Tav1,
     451             :                                   Tav2,
     452             :                                   hcv1,
     453             :                                   hcv2,
     454             :                                   qv1,
     455             :                                   qv2,
     456             :                                   nperr,
     457             :                                   ErrorMessage);
     458             :                     }
     459             : 
     460             :                     // exit on error
     461       20182 :                     if ((nperr > 0) && (nperr < 1000)) return;
     462             : 
     463             :                     // if (vvent(i).gt.0) then !not implemented for inside shadin yet
     464             :                     //  nperr = 1006
     465             :                     //  ErrorMessage = 'Forced ventilation not implemented for internal SD layers.'
     466             :                     //  return
     467             :                     // end if
     468             : 
     469       20182 :                     hcgas(i) = hcv1 / 2.0;
     470       20182 :                     hcgas(i + 1) = hcv2 / 2.0;
     471       20182 :                     hgas(i) = hcgas(i) + hrgas(i);
     472       20182 :                     hgas(i + 1) = hcgas(i + 1) + hrgas(i + 1);
     473       20182 :                     hcv(i) = hcv1;
     474       20182 :                     hcv(i + 1) = hcv2;
     475       20182 :                     qv(i) = qv1;
     476       20182 :                     qv(i + 1) = qv2;
     477       20182 :                     Tgaps(i) = Tgap1;
     478       20182 :                     Tgaps(i + 1) = Tgap2;
     479             :                     // bi.........Add free ventilation velocity
     480       20182 :                     vfreevent(i) = speed1;
     481       20182 :                     vfreevent(i + 1) = speed2;
     482             :                 } // if ((i.gt.1).and.(i.lt.nlayer)) then
     483             :             }     // if (LayerType(i).eq.SHADING) then
     484             :         }
     485             :     }
     486             : 
     487           0 :     void forcedventilation(EnergyPlusData &state,
     488             :                            const Array1D_int &iprop,
     489             :                            const Array1D<Real64> &frct,
     490             :                            Real64 const press,
     491             :                            int const nmix,
     492             :                            const Array1D<Real64> &xwght,
     493             :                            Array2A<Real64> const xgcon,
     494             :                            Array2A<Real64> const xgvis,
     495             :                            Array2A<Real64> const xgcp,
     496             :                            Real64 const s,
     497             :                            Real64 const H,
     498             :                            Real64 const hc,
     499             :                            Real64 const forcedspeed,
     500             :                            Real64 const Tinlet,
     501             :                            Real64 &Toutlet,
     502             :                            Real64 const Tav,
     503             :                            Real64 &hcv,
     504             :                            Real64 &qv,
     505             :                            int &nperr,
     506             :                            std::string &ErrorMessage)
     507             :     {
     508             :         //**************************************************************************************************************
     509             :         //  Input:
     510             :         //  iprop      Vector of gas identifiers
     511             :         //  frct      Fraction of gasses in a mixture
     512             :         //  nmix      Number of gasses in a mixture
     513             :         //  press      Pressure in mixture
     514             :         //  s1        Gap width [m]
     515             :         //  H          IGU cavity height [m]
     516             :         //  L          IGU cavity width [m]
     517             :         //  hc        Convective/conductive coefficient for non-vented gap
     518             :         //  Tav        Average temperature of gap surfaces
     519             :         // Tinlet    Temperature of inlet air
     520             :         //  Output:
     521             :         //  hcv    Convective/conductive coefficient for vented gap
     522             :         //  qv    Heat transfer to the gap by vetilation [W/m^2]
     523             :         //  nperr      Error flag
     524             :         // ErrorMessage string containing error message
     525             :         //**************************************************************************************************************
     526             : 
     527             :         // Argument array dimensioning
     528           0 :         EP_SIZE_CHECK(iprop, maxgas);
     529           0 :         EP_SIZE_CHECK(frct, maxgas);
     530           0 :         EP_SIZE_CHECK(xwght, maxgas);
     531           0 :         xgcon.dim(3, maxgas);
     532           0 :         xgvis.dim(3, maxgas);
     533           0 :         xgcp.dim(3, maxgas);
     534             : 
     535             :         // Locals
     536             :         Real64 H0;
     537             :         Real64 dens;
     538             :         Real64 cp;
     539             :         Real64 pr;
     540             :         Real64 con;
     541             :         Real64 visc;
     542             : 
     543           0 :         GASSES90(state,
     544             :                  Tav,
     545             :                  iprop,
     546             :                  frct,
     547             :                  press,
     548             :                  nmix,
     549             :                  xwght,
     550             :                  xgcon,
     551             :                  xgvis,
     552             :                  xgcp,
     553             :                  con,
     554             :                  visc,
     555             :                  dens,
     556             :                  cp,
     557             :                  pr,
     558             :                  TARCOGGassesParams::Stdrd::ISO15099,
     559             :                  nperr,
     560             :                  ErrorMessage);
     561             : 
     562           0 :         H0 = (dens * cp * s * forcedspeed) / (4.0 * hc + 8.0 * forcedspeed);
     563             : 
     564           0 :         Toutlet = Tav - (Tav - Tinlet) * std::pow(e, -H / H0);
     565             : 
     566           0 :         qv = -dens * cp * forcedspeed * s * (Toutlet - Tinlet) / H;
     567             : 
     568             :         // Need to calculate surface-to-air convection heat transfer coefficient.  This is needed later to calculate layer
     569             :         // to gap thermal resistance
     570           0 :         hcv = 2.0 * hc + 4.0 * forcedspeed;
     571           0 :     }
     572             : 
     573       20182 :     void shadingin(EnergyPlusData &state,
     574             :                    const Array1D_int &iprop1,
     575             :                    const Array1D<Real64> &frct1,
     576             :                    Real64 const press1,
     577             :                    int const nmix1,
     578             :                    const Array1D_int &iprop2,
     579             :                    const Array1D<Real64> &frct2,
     580             :                    Real64 const press2,
     581             :                    int const nmix2,
     582             :                    const Array1D<Real64> &xwght,
     583             :                    Array2A<Real64> const xgcon,
     584             :                    Array2A<Real64> const xgvis,
     585             :                    Array2A<Real64> const xgcp,
     586             :                    Real64 &Atop,
     587             :                    Real64 &Abot,
     588             :                    Real64 const Al,
     589             :                    Real64 const Ar,
     590             :                    Real64 const Ah,
     591             :                    Real64 const s1,
     592             :                    Real64 const s2,
     593             :                    Real64 const H,
     594             :                    Real64 const L,
     595             :                    Real64 const angle,
     596             :                    Real64 const hc1,
     597             :                    Real64 const hc2,
     598             :                    Real64 &speed1,
     599             :                    Real64 &speed2,
     600             :                    Real64 &Tgap1,
     601             :                    Real64 &Tgap2,
     602             :                    Real64 const Tav1,
     603             :                    Real64 const Tav2,
     604             :                    Real64 &hcv1,
     605             :                    Real64 &hcv2,
     606             :                    Real64 &qv1,
     607             :                    Real64 &qv2,
     608             :                    int &nperr,
     609             :                    std::string &ErrorMessage)
     610             :     {
     611             :         //**************************************************************************************************************
     612             :         //  Input:
     613             :         //  iprop1      Vector of gas identifiers
     614             :         //  frct1      Fraction of gasses in a mixture
     615             :         //  nmix1      Number of gasses in a mixture
     616             :         //  press1      Pressure in mixture
     617             :         //  iprop2      Vector of gas identifiers
     618             :         //  frct2      Fraction of gasses in a mixture
     619             :         //  nmix2      Number of gasses in a mixture
     620             :         //  press2      Pressure in mixture
     621             :         //  Atop      Opening between top of shading device and top of glazing cavity [m^2]
     622             :         //  Abot      Opening between bottom of shading device and bottom of glazing cavity [m^2]
     623             :         //  Al        Opening between left of shading device and left end of glazing cavity [m^2]
     624             :         //  Ar        Opening between right of shading device and right end of glazing cavity [m^2]
     625             :         //  Ah        Total area holes in the shading device [m^2]
     626             :         //  s1, s2      Gap width [m]
     627             :         //  H        IGU cavity height [m]
     628             :         //  L        IGU cavity width [m]
     629             :         //  angle      Window angle [degrees]
     630             :         //  hc1, hc2    Convective/conductive coefficient for non-vented gap
     631             :         //  Tav1, Tav2    Average temperature of gap surfaces
     632             :         //  Output:
     633             :         //  Tgap1, Tgap2  Temperature of vented gap
     634             :         //  hcv1, hcv2    Convective/conductive coefficient for vented gap
     635             :         //  qv1, qv2    Heat transfer to the gap by ventilation [W/m^2]
     636             :         //  speed1, speed2  Air/gas velocities in gaps around SD layer
     637             :         //  nperr      Error flag
     638             :         //**************************************************************************************************************
     639             : 
     640             :         // Using/Aliasing
     641             :         // Argument array dimensioning
     642       20182 :         EP_SIZE_CHECK(iprop1, maxgas);
     643       20182 :         EP_SIZE_CHECK(frct1, maxgas);
     644       20182 :         EP_SIZE_CHECK(iprop2, maxgas);
     645       20182 :         EP_SIZE_CHECK(frct2, maxgas);
     646       20182 :         EP_SIZE_CHECK(xwght, maxgas);
     647       20182 :         xgcon.dim(3, maxgas);
     648       20182 :         xgvis.dim(3, maxgas);
     649       20182 :         xgcp.dim(3, maxgas);
     650             : 
     651             :         // Locals
     652             :         Real64 A;
     653             :         Real64 A1;
     654             :         Real64 A2;
     655             :         Real64 B1;
     656             :         Real64 B2;
     657             :         Real64 C1;
     658             :         Real64 C2;
     659             :         Real64 D1;
     660             :         Real64 D2;
     661             :         Real64 Zin1;
     662             :         Real64 Zin2;
     663             :         Real64 Zout1;
     664             :         Real64 Zout2;
     665             :         Real64 A1eqin;
     666             :         Real64 A1eqout;
     667             :         Real64 A2eqin;
     668             :         Real64 A2eqout;
     669             :         Real64 T0;
     670             :         Real64 tilt;
     671             :         Real64 dens0;
     672             :         Real64 visc0;
     673             :         Real64 con0;
     674             :         Real64 pr0;
     675             :         Real64 cp0;
     676             :         Real64 dens1;
     677             :         Real64 visc1;
     678             :         Real64 con1;
     679             :         Real64 pr1;
     680             :         Real64 cp1;
     681             :         Real64 dens2;
     682             :         Real64 visc2;
     683             :         Real64 con2;
     684             :         Real64 pr2;
     685             :         Real64 cp2;
     686             :         Real64 Tup;
     687             :         Real64 Tdown;
     688             :         Real64 H01;
     689             :         Real64 H02;
     690             :         Real64 beta1;
     691             :         Real64 beta2;
     692             :         Real64 alpha1;
     693             :         Real64 alpha2;
     694             :         Real64 P1;
     695             :         Real64 P2;
     696             :         Real64 qsmooth;
     697             : 
     698             :         // iteration parameters
     699             :         int iter;
     700             :         Real64 TGapOld1;
     701             :         Real64 TGapOld2;
     702             :         Real64 Temp1;
     703             :         Real64 Temp2;
     704             :         bool converged;
     705             : 
     706       20182 :         TGapOld1 = 0.0;
     707       20182 :         TGapOld2 = 0.0;
     708       20182 :         tilt = DataGlobalConstants::Pi / 180 * (angle - 90);
     709       20182 :         T0 = 0.0 + DataGlobalConstants::KelvinConv;
     710       20182 :         A1eqin = 0.0;
     711       20182 :         A2eqout = 0.0;
     712       20182 :         A1eqout = 0.0;
     713       20182 :         A2eqin = 0.0;
     714       20182 :         P1 = 0.0;
     715       20182 :         P2 = 0.0;
     716             : 
     717       20182 :         GASSES90(state,
     718             :                  T0,
     719             :                  iprop1,
     720             :                  frct1,
     721             :                  press1,
     722             :                  nmix1,
     723             :                  xwght,
     724             :                  xgcon,
     725             :                  xgvis,
     726             :                  xgcp,
     727             :                  con0,
     728             :                  visc0,
     729             :                  dens0,
     730             :                  cp0,
     731             :                  pr0,
     732             :                  TARCOGGassesParams::Stdrd::ISO15099,
     733             :                  nperr,
     734             :                  ErrorMessage);
     735             : 
     736             :         // exit on error:
     737       20255 :         if ((nperr > 0) && (nperr < 1000)) return;
     738             : 
     739             :         // dr...check for error messages
     740       20182 :         if ((Tgap1 * Tgap2) == 0) {
     741           0 :             nperr = 15;
     742           0 :             ErrorMessage = "Temperature of vented gap must be greater than 0 [K].";
     743           0 :             return;
     744             :         }
     745             : 
     746       20182 :         if ((Atop + Abot) == 0) {
     747             :             //    nperr = 16
     748             :             //    return
     749       20182 :             Atop = 0.000001;
     750       20182 :             Abot = 0.000001;
     751             :         }
     752             : 
     753       20182 :         converged = false;
     754       20182 :         iter = 0;
     755       20182 :         Real64 const s1_2 = pow_2(s1);
     756       20182 :         Real64 const s2_2 = pow_2(s2);
     757       20182 :         Real64 const s1_s2_2 = pow_2(s1 / s2);
     758       20182 :         Real64 const cos_Tilt = std::cos(tilt);
     759       77982 :         while (!converged) {
     760       28973 :             ++iter;
     761       28973 :             GASSES90(state,
     762             :                      Tgap1,
     763             :                      iprop1,
     764             :                      frct1,
     765             :                      press1,
     766             :                      nmix1,
     767             :                      xwght,
     768             :                      xgcon,
     769             :                      xgvis,
     770             :                      xgcp,
     771             :                      con1,
     772             :                      visc1,
     773             :                      dens1,
     774             :                      cp1,
     775             :                      pr1,
     776             :                      TARCOGGassesParams::Stdrd::ISO15099,
     777             :                      nperr,
     778             :                      ErrorMessage);
     779       28973 :             GASSES90(state,
     780             :                      Tgap2,
     781             :                      iprop2,
     782             :                      frct2,
     783             :                      press2,
     784             :                      nmix2,
     785             :                      xwght,
     786             :                      xgcon,
     787             :                      xgvis,
     788             :                      xgcp,
     789             :                      con2,
     790             :                      visc2,
     791             :                      dens2,
     792             :                      cp2,
     793             :                      pr2,
     794             :                      TARCOGGassesParams::Stdrd::ISO15099,
     795             :                      nperr,
     796             :                      ErrorMessage);
     797             : 
     798             :             //  A = dens0 * T0 * GravityConstant * ABS(cos(tilt)) * ABS(Tgap1 - Tgap2) / (Tgap1 * Tgap2)
     799             : 
     800             :             // bi...Bug fix #00005:
     801       28973 :             A = dens0 * T0 * DataGlobalConstants::GravityConstant * H * std::abs(cos_Tilt) * std::abs(Tgap1 - Tgap2) / (Tgap1 * Tgap2);
     802             : 
     803       28973 :             if (A == 0.0) {
     804          73 :                 qv1 = 0.0;
     805          73 :                 qv2 = 0.0;
     806          73 :                 speed1 = 0.0;
     807          73 :                 speed2 = 0.0;
     808          73 :                 hcv1 = 2.0 * hc1;
     809          73 :                 hcv2 = 2.0 * hc2;
     810          73 :                 return;
     811             :             }
     812             : 
     813       28900 :             B1 = dens1 / 2;
     814       28900 :             B2 = (dens2 / 2) * s1_s2_2;
     815             : 
     816       28900 :             C1 = 12 * visc1 * H / s1_2;
     817       28900 :             C2 = 12 * visc2 * (H / s2_2) * (s1 / s2);
     818             : 
     819       28900 :             if (Tgap1 >= Tgap2) {
     820         537 :                 A1eqin = Abot + 0.5 * Atop * (Al + Ar + Ah) / (Abot + Atop);
     821         537 :                 A2eqout = Abot + 0.5 * Atop * (Al + Ar + Ah) / (Abot + Atop);
     822         537 :                 A1eqout = Atop + 0.5 * Abot * (Al + Ar + Ah) / (Abot + Atop);
     823         537 :                 A2eqin = Atop + 0.5 * Abot * (Al + Ar + Ah) / (Abot + Atop);
     824       28363 :             } else if (Tgap1 < Tgap2) {
     825       28363 :                 A1eqout = Abot + 0.5 * Atop * (Al + Ar + Ah) / (Abot + Atop);
     826       28363 :                 A2eqin = Abot + 0.5 * Atop * (Al + Ar + Ah) / (Abot + Atop);
     827       28363 :                 A1eqin = Atop + 0.5 * Abot * (Al + Ar + Ah) / (Abot + Atop);
     828       28363 :                 A2eqout = Atop + 0.5 * Abot * (Al + Ar + Ah) / (Abot + Atop);
     829             :             }
     830             : 
     831       28900 :             Zin1 = pow_2((s1 * L / (0.6 * A1eqin)) - 1.0);
     832       28900 :             Zin2 = pow_2((s2 * L / (0.6 * A2eqin)) - 1.0);
     833       28900 :             Zout1 = pow_2((s1 * L / (0.6 * A1eqout)) - 1.0);
     834       28900 :             Zout2 = pow_2((s2 * L / (0.6 * A2eqout)) - 1.0);
     835             : 
     836       28900 :             D1 = (dens1 / 2.0) * (Zin1 + Zout1);
     837       28900 :             D2 = (dens2 / 2.0) * s1_s2_2 * (Zin2 + Zout2);
     838             : 
     839       28900 :             A1 = B1 + D1 + B2 + D2;
     840       28900 :             A2 = C1 + C2;
     841             : 
     842       28900 :             speed1 = (std::sqrt(pow_2(A2) + std::abs(4.0 * A * A1)) - A2) / (2.0 * A1);
     843       28900 :             speed2 = speed1 * s1 / s2;
     844             : 
     845       28900 :             H01 = (dens1 * cp1 * s1 * speed1) / (4.0 * hc1 + 8.0 * speed1);
     846       28900 :             H02 = (dens2 * cp2 * s2 * speed2) / (4.0 * hc2 + 8.0 * speed2);
     847             : 
     848       28900 :             if ((H01 != 0.0) && (H02 != 0.0)) {
     849       28900 :                 P1 = -H / H01;
     850       28900 :                 P2 = -H / H02;
     851             :             }
     852             : 
     853       28900 :             beta1 = std::pow(e, P1);
     854       28900 :             beta2 = std::pow(e, P2);
     855             : 
     856       28900 :             alpha1 = 1.0 - beta1;
     857       28900 :             alpha2 = 1.0 - beta2;
     858             : 
     859       28900 :             if (Tgap1 > Tgap2) {
     860         537 :                 Tup = (alpha1 * Tav1 + beta1 * alpha2 * Tav2) / (1.0 - beta1 * beta2);
     861         537 :                 Tdown = alpha2 * Tav2 + beta2 * Tup;
     862       28363 :             } else if (Tgap2 >= Tgap1) {
     863       28363 :                 Tdown = (alpha1 * Tav1 + beta1 * alpha2 * Tav2) / (1.0 - beta1 * beta2);
     864       28363 :                 Tup = alpha2 * Tav2 + beta2 * Tdown;
     865             :             }
     866             : 
     867       28900 :             TGapOld1 = Tgap1;
     868       28900 :             TGapOld2 = Tgap2;
     869             : 
     870       28900 :             if (Tgap1 > Tgap2) {
     871         537 :                 Temp1 = Tav1 - (H01 / H) * (Tup - Tdown);
     872         537 :                 Temp2 = Tav2 - (H02 / H) * (Tdown - Tup);
     873       28363 :             } else if (Tgap2 >= Tgap1) {
     874       28363 :                 Temp1 = Tav1 - (H01 / H) * (Tdown - Tup);
     875       28363 :                 Temp2 = Tav2 - (H02 / H) * (Tup - Tdown);
     876             :             }
     877             : 
     878       28900 :             Tgap1 = AirflowRelaxationParameter * Temp1 + (1.0 - AirflowRelaxationParameter) * TGapOld1;
     879       28900 :             Tgap2 = AirflowRelaxationParameter * Temp2 + (1.0 - AirflowRelaxationParameter) * TGapOld2;
     880             : 
     881       28900 :             converged = false;
     882       28900 :             if ((std::abs(Tgap1 - TGapOld1) < AirflowConvergenceTolerance) || (iter >= NumOfIterations)) {
     883       22063 :                 if (std::abs(Tgap2 - TGapOld2) < AirflowConvergenceTolerance) {
     884       20109 :                     converged = true;
     885             :                 }
     886             :             }
     887             :         }
     888             : 
     889       20109 :         hcv1 = 2.0 * hc1 + 4.0 * speed1;
     890       20109 :         hcv2 = 2.0 * hc2 + 4.0 * speed2;
     891             : 
     892       20109 :         if (Tgap2 >= Tgap1) {
     893       19759 :             qv1 = -dens1 * cp1 * speed1 * s1 * L * (Tdown - Tup) / (H * L);
     894       19759 :             qv2 = -dens2 * cp2 * speed2 * s2 * L * (Tup - Tdown) / (H * L);
     895         350 :         } else if (Tgap2 < Tgap1) {
     896         350 :             qv1 = dens1 * cp1 * speed1 * s1 * L * (Tdown - Tup) / (H * L);
     897         350 :             qv2 = dens2 * cp2 * speed2 * s2 * L * (Tup - Tdown) / (H * L);
     898             :         }
     899             : 
     900             :         //  write(*, *) Tup-Tdown
     901             :         //  write(*, 998) Tup - Tdown, qv1, qv2
     902             : 
     903             :         // 998  format(f15.9, f15.9, f15.9)
     904             : 
     905             :         // bi..  testing - velocities output file
     906             :         // bi      open(unit = 33, file = 'velocities.out', status='unknown', form='formatted', iostat = er)
     907             : 
     908             :         // bi  write(33, 987) speed1
     909             : 
     910       20109 :         qsmooth = (std::abs(qv1) + std::abs(qv2)) / 2.0;
     911             : 
     912       20109 :         if (qv1 > 0.0) {
     913       19759 :             qv1 = qsmooth;
     914       19759 :             qv2 = -qsmooth;
     915             :         } else {
     916         350 :             qv1 = -qsmooth;
     917         350 :             qv2 = qsmooth;
     918             :         }
     919             :     }
     920             : 
     921      134464 :     void shadingedge(EnergyPlusData &state,
     922             :                      const Array1D_int &iprop1,
     923             :                      const Array1D<Real64> &frct1,
     924             :                      Real64 const press1,
     925             :                      int const nmix1,
     926             :                      const Array1D_int &iprop2,
     927             :                      const Array1D<Real64> &frct2,
     928             :                      Real64 const press2,
     929             :                      int const nmix2,
     930             :                      const Array1D<Real64> &xwght,
     931             :                      Array2A<Real64> const xgcon,
     932             :                      Array2A<Real64> const xgvis,
     933             :                      Array2A<Real64> const xgcp,
     934             :                      Real64 &Atop,
     935             :                      Real64 &Abot,
     936             :                      Real64 const Al,
     937             :                      Real64 const Ar,
     938             :                      Real64 &Ah,
     939             :                      Real64 const s,
     940             :                      Real64 const H,
     941             :                      Real64 const L,
     942             :                      Real64 const angle,
     943             :                      Real64 const forcedspeed,
     944             :                      Real64 const hc,
     945             :                      Real64 const Tenv,
     946             :                      Real64 const Tav,
     947             :                      Real64 &Tgap,
     948             :                      Real64 &hcv,
     949             :                      Real64 &qv,
     950             :                      int &nperr,
     951             :                      std::string &ErrorMessage,
     952             :                      Real64 &speed)
     953             :     {
     954             :         //**************************************************************************************************************
     955             :         //  Input:
     956             :         //  iprop1      Vector of gas identifiers
     957             :         //  frct1      Fraction of gasses in a mixture
     958             :         //  nmix1      Number of gasses in a mixture
     959             :         //  press1      Pressure in mixture
     960             :         //  iprop2      Vector of gas identifiers
     961             :         //  frct2      Fraction of gasses in a mixture
     962             :         //  nmix2      Number of gasses in a mixture
     963             :         //  press2      Pressure in mixture
     964             :         //  Atop      Opening between top of shading device and top of glazing cavity [m^2]
     965             :         //  Abot      Opening between bottom of shading device and bottom of glazing cavity [m^2]
     966             :         //  Al        Opening between left of shading device and left end of glazing cavity [m^2]
     967             :         //  Ar        Opening between right of shading device and right end of glazing cavity [m^2]
     968             :         //  Ah        Total area holes in the shading device [m^2]
     969             :         //  s        Gap width [m]
     970             :         //  H        IGU cavity height [m]
     971             :         //  L        IGU cavity width [m]
     972             :         //  angle      Window angle [degrees]
     973             :         //  forcedspeed    Speed of forced ventilation [m/s]
     974             :         //  hc        Convective/conductive coefficient for non-vented gap
     975             :         //  Tenv      Enviromental temperature
     976             :         //  Tav        Average temperature of gap surfaces
     977             :         //  Output:
     978             :         //  Tgap      Temperature of vented gap
     979             :         //  hcv        Convective/conductive coefficient for vented gap
     980             :         //  qv        Heat transfer to the gap by vetilation [W/m^2]
     981             :         //  nperr      Error flag
     982             :         //  speed      Air velocity
     983             :         //**************************************************************************************************************
     984             : 
     985             :         // Using/Aliasing
     986             :         // Argument array dimensioning
     987      134464 :         EP_SIZE_CHECK(iprop1, maxgas);
     988      134464 :         EP_SIZE_CHECK(frct1, maxgas);
     989      134464 :         EP_SIZE_CHECK(iprop2, maxgas);
     990      134464 :         EP_SIZE_CHECK(frct2, maxgas);
     991      134464 :         EP_SIZE_CHECK(xwght, maxgas);
     992      134464 :         xgcon.dim(3, maxgas);
     993      134464 :         xgvis.dim(3, maxgas);
     994      134464 :         xgcp.dim(3, maxgas);
     995             : 
     996             :         // Locals
     997             :         Real64 A;
     998             :         Real64 A1;
     999             :         Real64 A2;
    1000             :         Real64 B1;
    1001             :         Real64 C1;
    1002             :         Real64 D1;
    1003             :         Real64 Zin1;
    1004             :         Real64 Zout1;
    1005             :         Real64 A1eqin;
    1006             :         Real64 A1eqout;
    1007             :         Real64 T0;
    1008             :         Real64 tilt;
    1009             :         Real64 dens0;
    1010             :         Real64 visc0;
    1011             :         Real64 con0;
    1012             :         Real64 pr0;
    1013             :         Real64 cp0;
    1014             :         // REAL(r64) :: dens1, visc1, con1, pr1, cp1
    1015             :         Real64 dens2;
    1016             :         Real64 visc2;
    1017             :         Real64 con2;
    1018             :         Real64 pr2;
    1019             :         Real64 cp2;
    1020             :         Real64 Tgapout;
    1021             :         Real64 H0;
    1022             :         Real64 P;
    1023             :         Real64 beta;
    1024             : 
    1025             :         // iteration parameters
    1026             :         int iter;
    1027             :         Real64 TGapOld;
    1028             :         bool converged;
    1029             : 
    1030      134464 :         tilt = DataGlobalConstants::Pi / 180.0 * (angle - 90.0);
    1031      134464 :         T0 = 0.0 + DataGlobalConstants::KelvinConv;
    1032             : 
    1033      134464 :         GASSES90(state,
    1034             :                  T0,
    1035             :                  iprop1,
    1036             :                  frct1,
    1037             :                  press1,
    1038             :                  nmix1,
    1039             :                  xwght,
    1040             :                  xgcon,
    1041             :                  xgvis,
    1042             :                  xgcp,
    1043             :                  con0,
    1044             :                  visc0,
    1045             :                  dens0,
    1046             :                  cp0,
    1047             :                  pr0,
    1048             :                  TARCOGGassesParams::Stdrd::ISO15099,
    1049             :                  nperr,
    1050             :                  ErrorMessage);
    1051             :         // call gasses90(Tenv, iprop1, frct1, press1, nmix1, xwght, xgcon, xgvis, xgcp, con1, visc1, dens1, cp1, pr1, 1, &
    1052             :         //                nperr, ErrorMessage)
    1053             : 
    1054             :         // exit on error:
    1055      134464 :         if ((nperr > 0) && (nperr < 1000)) return;
    1056             : 
    1057             :         // dr...check for error messages
    1058      134464 :         if ((Tgap * Tenv) == 0.0) {
    1059           0 :             nperr = 15;
    1060           0 :             ErrorMessage = "Temperature of vented air must be greater then 0 [K].";
    1061           0 :             return;
    1062             :         }
    1063             : 
    1064      134464 :         if ((Atop + Abot) == 0) {
    1065             :             //    nperr = 16
    1066             :             //    return
    1067      134464 :             Atop = 0.000001;
    1068      134464 :             Abot = 0.000001;
    1069             :         }
    1070      134464 :         if ((Ah + Al + Ar) == 0.0) {
    1071           0 :             Ah = 0.000001;
    1072             :         }
    1073             : 
    1074      134464 :         converged = false;
    1075      134464 :         iter = 0;
    1076      134464 :         Real64 const s_2 = pow_2(s);
    1077      134464 :         Real64 const abs_cos_tilt = std::abs(std::cos(tilt));
    1078             : 
    1079      554810 :         while (!converged) {
    1080      210173 :             ++iter;
    1081      210173 :             GASSES90(state,
    1082             :                      Tgap,
    1083             :                      iprop2,
    1084             :                      frct2,
    1085             :                      press2,
    1086             :                      nmix2,
    1087             :                      xwght,
    1088             :                      xgcon,
    1089             :                      xgvis,
    1090             :                      xgcp,
    1091             :                      con2,
    1092             :                      visc2,
    1093             :                      dens2,
    1094             :                      cp2,
    1095             :                      pr2,
    1096             :                      TARCOGGassesParams::Stdrd::ISO15099,
    1097             :                      nperr,
    1098             :                      ErrorMessage);
    1099             : 
    1100      210173 :             if ((nperr > 0) && (nperr < 1000)) return;
    1101             : 
    1102             :             //  A = dens0 * T0 * gravity * ABS(cos(tilt)) * ABS(Tgap - Tenv) / (Tgap * Tenv)
    1103             : 
    1104             :             // bi...Bug fix #00005:
    1105      210173 :             A = dens0 * T0 * DataGlobalConstants::GravityConstant * H * abs_cos_tilt * std::abs(Tgap - Tenv) / (Tgap * Tenv);
    1106             :             //  A = dens0 * T0 * GravityConstant * H * ABS(cos(tilt)) * (Tgap - Tenv) / (Tgap * Tenv)
    1107             : 
    1108      210173 :             B1 = dens2 / 2;
    1109      210173 :             C1 = 12.0 * visc2 * H / s_2;
    1110             : 
    1111      210173 :             if (Tgap > Tenv) {
    1112      113526 :                 A1eqin = Abot + 0.5 * Atop * (Al + Ar + Ah) / (Abot + Atop);
    1113      113526 :                 A1eqout = Atop + 0.5 * Abot * (Al + Ar + Ah) / (Abot + Atop);
    1114       96647 :             } else if (Tgap <= Tenv) {
    1115       96647 :                 A1eqout = Abot + 0.5 * Atop * (Al + Ar + Ah) / (Abot + Atop);
    1116       96647 :                 A1eqin = Atop + 0.5 * Abot * (Al + Ar + Ah) / (Abot + Atop);
    1117             :             }
    1118             : 
    1119      210173 :             Zin1 = pow_2((s * L / (0.6 * A1eqin)) - 1);
    1120      210173 :             Zout1 = pow_2((s * L / (0.6 * A1eqout)) - 1);
    1121             : 
    1122      210173 :             D1 = (dens2 / 2.0) * (Zin1 + Zout1);
    1123             : 
    1124      210173 :             A1 = B1 + D1;
    1125      210173 :             A2 = C1;
    1126             : 
    1127             :             // dr...recalculate speed if forced speed exist
    1128             :             // bi...skip forced vent for now
    1129             :             //  if (forcedspeed.ne.0) then
    1130      210173 :             if ((forcedspeed != 0.0) && (static_cast<int>(CalcForcedVentilation::Allow))) {
    1131           0 :                 speed = forcedspeed;
    1132             :             } else {
    1133      210173 :                 speed = (std::sqrt(pow_2(A2) + std::abs(4.0 * A * A1)) - A2) / (2.0 * A1);
    1134             :                 //  speed = ABS((SQRT((A2 ** 2) + (4 * A * A1)) - A2) / (2 * A1))
    1135             :             }
    1136             : 
    1137      210173 :             TGapOld = Tgap;
    1138             : 
    1139             :             // Speed is zero when environment temperature is equal to average layer temperatures
    1140             :             // For example, this can happen when inside and outside temperatures are equal
    1141      210173 :             if (speed != 0.0) {
    1142      210125 :                 H0 = (dens2 * cp2 * s * speed) / (4.0 * hc + 8.0 * speed);
    1143             : 
    1144      210125 :                 P = -H / H0;
    1145      210125 :                 if (P < -700.0) {
    1146        9330 :                     beta = 0.0;
    1147             :                 } else {
    1148      200795 :                     beta = std::pow(e, P);
    1149             :                 }
    1150      210125 :                 Tgapout = Tav - (Tav - Tenv) * beta;
    1151      210125 :                 Tgap = Tav - (H0 / H) * (Tgapout - Tenv);
    1152             :             } else {
    1153          48 :                 Tgapout = Tav;
    1154          48 :                 Tgap = Tav;
    1155             :             }
    1156             : 
    1157      210173 :             converged = false;
    1158      210173 :             if ((std::abs(Tgap - TGapOld) < AirflowConvergenceTolerance) || (iter >= NumOfIterations)) {
    1159      134464 :                 converged = true;
    1160             :             }
    1161             : 
    1162             :             // if (iter > NumOfIterations) then
    1163             :             //  converged = .TRUE.
    1164             :             // end if
    1165             :         }
    1166             : 
    1167             :         // bi...Test output:
    1168             :         //  write(*,101) tenv, tgap, tgapout
    1169             :         // 101  format(f15.9, f15.9, f15.9)
    1170             : 
    1171      134464 :         hcv = 2.0 * hc + 4.0 * speed;
    1172             : 
    1173      134464 :         qv = dens2 * cp2 * speed * s * L * (Tenv - Tgapout) / (H * L);
    1174             :     }
    1175             : 
    1176       37990 :     void updateEffectiveMultipliers(int const nlayer,                          // Number of layers
    1177             :                                     Real64 const width,                        // IGU width [m]
    1178             :                                     Real64 const height,                       // IGU height [m]
    1179             :                                     const Array1D<Real64> &Atop,               // Top openning area [m2]
    1180             :                                     const Array1D<Real64> &Abot,               // Bottom openning area [m2]
    1181             :                                     const Array1D<Real64> &Al,                 // Left side openning area [m2]
    1182             :                                     const Array1D<Real64> &Ar,                 // Right side openning area [m2]
    1183             :                                     const Array1D<Real64> &Ah,                 // Front side openning area [m2]
    1184             :                                     Array1D<Real64> &Atop_eff,                 // Output - Effective top openning area [m2]
    1185             :                                     Array1D<Real64> &Abot_eff,                 // Output - Effective bottom openning area [m2]
    1186             :                                     Array1D<Real64> &Al_eff,                   // Output - Effective left side openning area [m2]
    1187             :                                     Array1D<Real64> &Ar_eff,                   // Output - Effective right side openning area [m2]
    1188             :                                     Array1D<Real64> &Ah_eff,                   // Output - Effective front side openning area [m2]
    1189             :                                     const Array1D<TARCOGLayerType> &LayerType, // Layer type
    1190             :                                     const Array1D<Real64> &SlatAngle           // Venetian layer slat angle [deg]
    1191             :     )
    1192             :     {
    1193      144562 :         for (int i = 1; i <= nlayer; ++i) {
    1194      106572 :             if (LayerType(i) == TARCOGLayerType::VENETBLIND_HORIZ || LayerType(i) == TARCOGLayerType::VENETBLIND_VERT) {
    1195        5718 :                 const Real64 slatAngRad = SlatAngle(i) * 2 * DataGlobalConstants::Pi / 360;
    1196        5718 :                 Real64 C1_VENET(0);
    1197        5718 :                 Real64 C2_VENET(0);
    1198        5718 :                 Real64 C3_VENET(0);
    1199             : 
    1200        5718 :                 if (LayerType(i) == TARCOGLayerType::VENETBLIND_HORIZ) {
    1201        3028 :                     C1_VENET = C1_VENET_HORIZONTAL;
    1202        3028 :                     C2_VENET = C2_VENET_HORIZONTAL;
    1203        3028 :                     C3_VENET = C3_VENET_HORIZONTAL;
    1204             :                 }
    1205        5718 :                 if (LayerType(i) == TARCOGLayerType::VENETBLIND_VERT) {
    1206        2690 :                     C1_VENET = C1_VENET_VERTICAL;
    1207        2690 :                     C2_VENET = C2_VENET_VERTICAL;
    1208        2690 :                     C3_VENET = C3_VENET_VERTICAL;
    1209             :                 }
    1210        5718 :                 Ah_eff(i) = width * height * C1_VENET * pow((Ah(i) / (width * height)) * pow(cos(slatAngRad), C2_VENET), C3_VENET);
    1211        5718 :                 Al_eff(i) = 0.0;
    1212        5718 :                 Ar_eff(i) = 0.0;
    1213        5718 :                 Atop_eff(i) = Atop(i);
    1214        5718 :                 Abot_eff(i) = Abot(i);
    1215      100854 :             } else if (BITF_TEST_ANY(BITF(LayerType(i)),
    1216             :                                      BITF(TARCOGLayerType::PERFORATED) | BITF(TARCOGLayerType::DIFFSHADE) | BITF(TARCOGLayerType::BSDF) |
    1217             :                                          BITF(TARCOGLayerType::WOVSHADE))) {
    1218       24200 :                 Ah_eff(i) = width * height * C1_SHADE * pow((Ah(i) / (width * height)), C2_SHADE);
    1219       24200 :                 Al_eff(i) = Al(i) * C3_SHADE;
    1220       24200 :                 Ar_eff(i) = Ar(i) * C3_SHADE;
    1221       24200 :                 Atop_eff(i) = Atop(i) * C4_SHADE;
    1222       24200 :                 Abot_eff(i) = Abot(i) * C4_SHADE;
    1223             :             } else {
    1224       76654 :                 Ah_eff(i) = Ah(i);
    1225       76654 :                 Al_eff(i) = Al(i);
    1226       76654 :                 Ar_eff(i) = Ar(i);
    1227       76654 :                 Atop_eff(i) = Atop(i);
    1228       76654 :                 Abot_eff(i) = Abot(i);
    1229             :             }
    1230             :         }
    1231       37990 :     }
    1232             : 
    1233             : } // namespace TarcogShading
    1234             : 
    1235        2313 : } // namespace EnergyPlus

Generated by: LCOV version 1.13