LCOV - code coverage report
Current view: top level - EnergyPlus - TarcogShading.cc (source / functions) Coverage Total Hit
Test: lcov.output.filtered Lines: 8.8 % 320 28
Test Date: 2025-05-22 16:09:37 Functions: 20.0 % 5 1

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

Generated by: LCOV version 2.0-1