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

            Line data    Source code
       1              : // EnergyPlus, Copyright (c) 1996-2025, The Board of Trustees of the University of Illinois,
       2              : // The Regents of the University of California, through Lawrence Berkeley National Laboratory
       3              : // (subject to receipt of any required approvals from the U.S. Dept. of Energy), Oak Ridge
       4              : // National Laboratory, managed by UT-Battelle, Alliance for Sustainable Energy, LLC, and other
       5              : // contributors. All rights reserved.
       6              : //
       7              : // NOTICE: This Software was developed under funding from the U.S. Department of Energy and the
       8              : // U.S. Government consequently retains certain rights. As such, the U.S. Government has been
       9              : // granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable,
      10              : // worldwide license in the Software to reproduce, distribute copies to the public, prepare
      11              : // derivative works, and perform publicly and display publicly, and to permit others to do so.
      12              : //
      13              : // Redistribution and use in source and binary forms, with or without modification, are permitted
      14              : // provided that the following conditions are met:
      15              : //
      16              : // (1) Redistributions of source code must retain the above copyright notice, this list of
      17              : //     conditions and the following disclaimer.
      18              : //
      19              : // (2) Redistributions in binary form must reproduce the above copyright notice, this list of
      20              : //     conditions and the following disclaimer in the documentation and/or other materials
      21              : //     provided with the distribution.
      22              : //
      23              : // (3) Neither the name of the University of California, Lawrence Berkeley National Laboratory,
      24              : //     the University of Illinois, U.S. Dept. of Energy nor the names of its contributors may be
      25              : //     used to endorse or promote products derived from this software without specific prior
      26              : //     written permission.
      27              : //
      28              : // (4) Use of EnergyPlus(TM) Name. If Licensee (i) distributes the software in stand-alone form
      29              : //     without changes from the version obtained under this License, or (ii) Licensee makes a
      30              : //     reference solely to the software portion of its product, Licensee must refer to the
      31              : //     software as "EnergyPlus version X" software, where "X" is the version number Licensee
      32              : //     obtained under this License and may not use a different name for the software. Except as
      33              : //     specifically required in this Section (4), Licensee shall not use in a company name, a
      34              : //     product name, in advertising, publicity, or other promotional activities any name, trade
      35              : //     name, trademark, logo, or other designation of "EnergyPlus", "E+", "e+" or confusingly
      36              : //     similar designation, without the U.S. Department of Energy's prior written consent.
      37              : //
      38              : // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
      39              : // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
      40              : // AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
      41              : // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
      42              : // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
      43              : // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
      44              : // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
      45              : // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
      46              : // POSSIBILITY OF SUCH DAMAGE.
      47              : 
      48              : // ObjexxFCL Headers
      49              : #include <ObjexxFCL/Array1D.hh>
      50              : 
      51              : // EnergyPlus Headers
      52              : #include <EnergyPlus/DataGlobals.hh>
      53              : #include <EnergyPlus/TARCOGArgs.hh>
      54              : #include <EnergyPlus/TARCOGCommon.hh>
      55              : #include <EnergyPlus/TARCOGGasses90.hh>
      56              : #include <EnergyPlus/TARCOGGassesParams.hh>
      57              : #include <EnergyPlus/TARCOGOutput.hh>
      58              : #include <EnergyPlus/TARCOGParams.hh>
      59              : #include <EnergyPlus/ThermalEN673Calc.hh>
      60              : 
      61              : namespace EnergyPlus {
      62              : 
      63              : namespace ThermalEN673Calc {
      64              : 
      65              :     // MODULE INFORMATION:
      66              :     //       AUTHOR         D. Charlie Curcija
      67              :     //       DATE WRITTEN   July/2000
      68              :     //       MODIFIED       na
      69              :     //       RE-ENGINEERED  na
      70              : 
      71              :     // PURPOSE OF THIS MODULE:
      72              :     // Calculate thermal properties of IGU according to EN673 standard
      73              : 
      74              :     // METHODOLOGY EMPLOYED:
      75              :     // <description>
      76              : 
      77              :     // REFERENCES:
      78              :     // na
      79              : 
      80              :     // OTHER NOTES:
      81              :     // na
      82              : 
      83              :     // USE STATEMENTS:
      84              : 
      85              :     // Using/Aliasing
      86              :     using namespace TARCOGCommon;
      87              :     using namespace TARCOGGassesParams;
      88              :     using namespace TARCOGGasses90;
      89              :     using namespace TARCOGParams;
      90              : 
      91              :     // Functions
      92              : 
      93            0 :     void Calc_EN673(EnergyPlusData &state,
      94              :                     TARCOGOutput::Files &files,
      95              :                     TARCOGGassesParams::Stdrd const standard,
      96              :                     int const nlayer,
      97              :                     Real64 const tout,
      98              :                     Real64 const tind,
      99              :                     Array1D<Real64> &gap,
     100              :                     Array1D<Real64> &thick,
     101              :                     Array1D<Real64> &scon,
     102              :                     const Array1D<Real64> &emis,
     103              :                     Real64 const totsol,
     104              :                     Real64 const tilt,
     105              :                     Real64 const dir,
     106              :                     const Array1D<Real64> &asol,
     107              :                     const Array1D<Real64> &presure,
     108              :                     Array2A_int const iprop,
     109              :                     Array2A<Real64> const frct,
     110              :                     const Array1D_int &nmix,
     111              :                     Array2A<Real64> const xgcon,
     112              :                     Array2A<Real64> const xgvis,
     113              :                     Array2A<Real64> const xgcp,
     114              :                     const Array1D<Real64> &xwght,
     115              :                     Array1D<Real64> &theta,
     116              :                     Real64 &ufactor,
     117              :                     Real64 &hcin,
     118              :                     Real64 &hin,
     119              :                     Real64 &hout,
     120              :                     Real64 &shgc,
     121              :                     int &nperr,
     122              :                     std::string &ErrorMessage,
     123              :                     const Array1D_int &ibc,
     124              :                     Array1D<Real64> &hg,
     125              :                     Array1D<Real64> &hr,
     126              :                     Array1D<Real64> &hs,
     127              :                     Array1D<Real64> &Ra,
     128              :                     Array1D<Real64> &Nu)
     129              :     {
     130              : 
     131              :         // Using/Aliasing
     132              :         using TARCOGArgs::GoAhead;
     133              :         using namespace TARCOGOutput;
     134              : 
     135              :         /// function attributes:
     136              : 
     137              :         /// INPUTS:
     138              : 
     139              :         /// General:
     140              : 
     141              :         // Argument array dimensioning
     142            0 :         EP_SIZE_CHECK(gap, MaxGap);
     143            0 :         EP_SIZE_CHECK(thick, maxlay);
     144            0 :         EP_SIZE_CHECK(scon, maxlay);
     145            0 :         EP_SIZE_CHECK(emis, maxlay2);
     146            0 :         EP_SIZE_CHECK(asol, maxlay);
     147            0 :         EP_SIZE_CHECK(presure, maxlay1);
     148            0 :         iprop.dim(maxgas, maxlay1);
     149            0 :         frct.dim(maxgas, maxlay1);
     150            0 :         EP_SIZE_CHECK(nmix, maxlay1);
     151            0 :         xgcon.dim(3, maxgas);
     152            0 :         xgvis.dim(3, maxgas);
     153            0 :         xgcp.dim(3, maxgas);
     154            0 :         EP_SIZE_CHECK(xwght, maxgas);
     155            0 :         EP_SIZE_CHECK(theta, maxlay2);
     156            0 :         EP_SIZE_CHECK(ibc, 2);
     157            0 :         EP_SIZE_CHECK(hg, maxlay);
     158            0 :         EP_SIZE_CHECK(hr, maxlay);
     159            0 :         EP_SIZE_CHECK(hs, maxlay);
     160            0 :         EP_SIZE_CHECK(Ra, maxlay);
     161            0 :         EP_SIZE_CHECK(Nu, maxlay);
     162              : 
     163              :         // Locals
     164              :         /// Environment related:
     165              : 
     166              :         /// Layers:
     167              : 
     168              :         /// Gaps:
     169              : 
     170              :         //// INPUTS/OUTPUTS:
     171              : 
     172              :         /// OUTPUTS:
     173              :         /// Overall:
     174              : 
     175              :         /// Layers:
     176              : 
     177              :         /// Gaps:
     178              : 
     179            0 :         Array1D<Real64> rs(maxlay3);
     180              :         Real64 rtot;
     181              :         Real64 sft;
     182              : 
     183              :         // call  propcon90(standard, mgas, gcon, gvis, gcp, grho, wght, nperr)
     184            0 :         rtot = 0.0;
     185            0 :         sft = 0.0;
     186            0 :         if (GoAhead(nperr)) {
     187            0 :             EN673ISO10292(state,
     188              :                           nlayer,
     189              :                           tout,
     190              :                           tind,
     191              :                           emis,
     192              :                           gap,
     193              :                           thick,
     194              :                           scon,
     195              :                           tilt,
     196              :                           iprop,
     197              :                           frct,
     198              :                           xgcon,
     199              :                           xgvis,
     200              :                           xgcp,
     201              :                           xwght,
     202              :                           presure,
     203              :                           nmix,
     204              :                           theta,
     205              :                           standard,
     206              :                           hg,
     207              :                           hr,
     208              :                           hs,
     209              :                           hin,
     210              :                           hout,
     211              :                           hcin,
     212              :                           ibc,
     213              :                           rs,
     214              :                           ufactor,
     215              :                           Ra,
     216              :                           Nu,
     217              :                           nperr,
     218              :                           ErrorMessage);
     219              : 
     220            0 :             if (GoAhead(nperr)) {
     221            0 :                 rtot = 1.0 / ufactor;
     222            0 :                 solar_EN673(dir, totsol, rtot, rs, nlayer, asol, sft, standard, nperr, ErrorMessage);
     223            0 :                 if (GoAhead(nperr)) {
     224            0 :                     shgc = sft;
     225            0 :                     if (files.WriteDebugOutput)
     226            0 :                         WriteOutputEN673(files.DebugOutputFile, files.DBGD, nlayer, ufactor, hout, hin, Ra, Nu, hg, hr, hs, nperr);
     227              :                 } // GoAhead after solar
     228              :             }     // GoAhead after EN673ISO10292
     229              :         }         // GopAhead after propcon90
     230            0 :     }
     231              : 
     232            0 :     void EN673ISO10292(EnergyPlusData &state,
     233              :                        int const nlayer,
     234              :                        Real64 const tout,
     235              :                        Real64 const tind,
     236              :                        const Array1D<Real64> &emis,
     237              :                        const Array1D<Real64> &gap,
     238              :                        const Array1D<Real64> &thick,
     239              :                        const Array1D<Real64> &scon,
     240              :                        Real64 const tilt,
     241              :                        Array2A_int const iprop,
     242              :                        Array2A<Real64> const frct,
     243              :                        Array2A<Real64> const xgcon,
     244              :                        Array2A<Real64> const xgvis,
     245              :                        Array2A<Real64> const xgcp,
     246              :                        const Array1D<Real64> &xwght,
     247              :                        const Array1D<Real64> &presure,
     248              :                        const Array1D_int &nmix,
     249              :                        Array1D<Real64> &theta,
     250              :                        TARCOGGassesParams::Stdrd const standard,
     251              :                        Array1D<Real64> &hg,
     252              :                        Array1D<Real64> &hr,
     253              :                        Array1D<Real64> &hs,
     254              :                        Real64 &hin,
     255              :                        Real64 const hout,
     256              :                        Real64 &hcin,
     257              :                        const Array1D_int &ibc,
     258              :                        Array1D<Real64> &rs,
     259              :                        Real64 &ufactor,
     260              :                        Array1D<Real64> &Ra,
     261              :                        Array1D<Real64> &Nu,
     262              :                        int &nperr,
     263              :                        std::string &ErrorMessage)
     264              :     {
     265              :         // Using
     266              :         // Argument array dimensioning
     267            0 :         EP_SIZE_CHECK(emis, maxlay2);
     268            0 :         EP_SIZE_CHECK(gap, MaxGap);
     269            0 :         EP_SIZE_CHECK(thick, maxlay);
     270            0 :         EP_SIZE_CHECK(scon, maxlay);
     271            0 :         iprop.dim(maxgas, maxlay1);
     272            0 :         frct.dim(maxgas, maxlay1);
     273            0 :         xgcon.dim(3, maxgas);
     274            0 :         xgvis.dim(3, maxgas);
     275            0 :         xgcp.dim(3, maxgas);
     276            0 :         EP_SIZE_CHECK(xwght, maxgas);
     277            0 :         EP_SIZE_CHECK(presure, maxlay1);
     278            0 :         EP_SIZE_CHECK(nmix, maxlay1);
     279            0 :         EP_SIZE_CHECK(theta, maxlay2);
     280            0 :         EP_SIZE_CHECK(hg, maxlay);
     281            0 :         EP_SIZE_CHECK(hr, maxlay);
     282            0 :         EP_SIZE_CHECK(hs, maxlay);
     283            0 :         EP_SIZE_CHECK(ibc, 2);
     284            0 :         EP_SIZE_CHECK(rs, maxlay3);
     285            0 :         EP_SIZE_CHECK(Ra, maxlay);
     286            0 :         EP_SIZE_CHECK(Nu, maxlay);
     287              : 
     288              :         // Locals
     289              :         // dr...internal variables
     290              :         Real64 Tm;
     291              :         Real64 diff;
     292              :         Real64 Rg;
     293            0 :         Array1D<Real64> dT(maxlay1);
     294              :         int i;
     295              :         int j;
     296              :         int iter;
     297              :         Real64 dens;
     298              :         Real64 visc;
     299              :         Real64 con;
     300              :         Real64 cp;
     301              :         Real64 pr;
     302            0 :         Array1D<Real64> Gr(maxlay);
     303              :         Real64 A;
     304              :         Real64 n;
     305              :         Real64 hrin;
     306              :         Real64 sumRs;
     307              :         Real64 sumRsold;
     308              : 
     309            0 :         Real64 constexpr eps(1.0e-4); // set iteration accuracy
     310              : 
     311            0 :         Array1D<Real64> frctg(maxgas);
     312            0 :         Array1D_int ipropg(maxgas);
     313              : 
     314              :         // jel..hrin is 4.4 for standard clear glass:
     315            0 :         if ((emis(2 * nlayer) < 0.85) && (emis(2 * nlayer) > 0.83)) {
     316            0 :             hrin = 4.4;
     317              :         } else {
     318            0 :             hrin = 4.4 * emis(2 * nlayer) / 0.837;
     319              :             //       hrin = 4.4 * emis(2*nlayer) / 0.84  !old formula
     320              :         }
     321              : 
     322            0 :         if (ibc(1) != 1) {
     323            0 :             nperr = 38;
     324              :             ErrorMessage = "Boundary conditions for EN673 can be combined hout for outdoor and either convective (hcin) or combined (hin) for "
     325            0 :                            "indoor.  Others are not supported currently.";
     326            0 :             return;
     327              :         }
     328              : 
     329            0 :         if (ibc(2) == 1) {
     330              : 
     331            0 :         } else if (ibc(2) == 2) {
     332            0 :             hcin = hin;
     333            0 :             hin = hcin + hrin;
     334              :         } else {
     335            0 :             nperr = 39;
     336            0 :             ErrorMessage = "CSM and SCW thermal models cannot be used for outdoor and indoor SD layers.";
     337            0 :             return;
     338              :         }
     339              : 
     340            0 :         rs(1) = 1.0 / hout;
     341            0 :         rs(2 * nlayer + 1) = 1.0 / hin;
     342              : 
     343            0 :         Tm = 283.0;
     344            0 :         iter = 1;
     345            0 :         sumRs = 0.0;
     346            0 :         Rg = 0.0;
     347              : 
     348              :         // bi Init vectors:
     349            0 :         Gr = 0.0;
     350            0 :         Nu = 0.0;
     351            0 :         Ra = 0.0;
     352            0 :         con = 0.0;
     353              : 
     354            0 :         for (i = 1; i <= nlayer; ++i) {
     355            0 :             rs(2 * i) = thick(i) / scon(i); // thermal resistance of each glazing layer
     356            0 :             Rg += rs(2 * i);                // cumulative thermal resistance of glazing layers
     357              :         }
     358              : 
     359            0 :         if (nlayer == 1) { // Calc U-Factor and glazing temperature for simgle glazing and return
     360            0 :             ufactor = 1.0 / (1.0 / hin + 1.0 / hout + Rg);
     361            0 :             theta(1) = ufactor * (tind - tout) / hout + tout;
     362            0 :             theta(2) = tind - ufactor * (tind - tout) / hin;
     363            0 :             return;
     364              :         } else {
     365            0 :             if (tind > tout) {
     366              :                 // dr...linear interpolation for gas conductance coefficients
     367            0 :                 if (tilt == 0.0) {
     368            0 :                     A = 0.16;
     369            0 :                     n = 0.28;
     370            0 :                 } else if ((tilt > 0.0) && (tilt < 45.0)) {
     371            0 :                     linint(0.0, 45.0, 0.16, 0.1, tilt, A);
     372            0 :                     linint(0.0, 45.0, 0.28, 0.31, tilt, n);
     373            0 :                 } else if (tilt == 45.0) {
     374            0 :                     A = 0.10;
     375            0 :                     n = 0.31;
     376            0 :                 } else if ((tilt > 45.0) && (tilt < 90.0)) {
     377            0 :                     linint(45.0, 90.0, 0.1, 0.035, tilt, A);
     378            0 :                     linint(45.0, 90.0, 0.31, 0.38, tilt, n);
     379            0 :                 } else if (tilt == 90) {
     380            0 :                     A = 0.035;
     381            0 :                     n = 0.38;
     382              :                 } // tilt
     383              : 
     384              :                 // c   gas constants
     385              :                 //    open(unit=18,  file='gas.dbg',  status='unknown', position='APPEND',
     386              :                 //  2            form='formatted', iostat=nperr)
     387              :                 //    write(18,*) 'New calc'
     388            0 :                 for (i = 1; i <= nlayer - 1; ++i) {
     389              :                     // 22222  format('Gas #', I3, ' : Dens=', F9.7, ' Visc=', F12.9, ' Cond=', F9.7, ' Cp=', F9.7)
     390              :                     //   write(18, 22222) iprop(i+1, j), tempDens, gvis(iprop(i+1,j), 1), gcon(iprop(i+1,j), 1), gcp(iprop(i+1,j), 1)
     391            0 :                     dT(i) = 15.0 / (nlayer - 1); // set initial temperature distribution
     392            0 :                     for (j = 1; j <= nmix(i + 1); ++j) {
     393            0 :                         ipropg(j) = iprop(i + 1, j);
     394            0 :                         frctg(j) = frct(i + 1, j);
     395              :                     }
     396            0 :                     GASSES90(state,
     397              :                              Tm,
     398              :                              ipropg,
     399              :                              frctg,
     400            0 :                              presure(i + 1),
     401            0 :                              nmix(i + 1),
     402              :                              xwght,
     403              :                              xgcon,
     404              :                              xgvis,
     405              :                              xgcp,
     406              :                              con,
     407              :                              visc,
     408              :                              dens,
     409              :                              cp,
     410              :                              pr,
     411              :                              standard,
     412              :                              nperr,
     413              :                              ErrorMessage);
     414            0 :                     Gr(i) = (Constant::Gravity * pow_3(gap(i)) * dT(i) * pow_2(dens)) / (Tm * pow_2(visc));
     415            0 :                     Ra(i) = Gr(i) * pr;
     416            0 :                     Nu(i) = A * std::pow(Ra(i), n);
     417            0 :                     if (Nu(i) < 1.0) {
     418            0 :                         Nu(i) = 1.0;
     419              :                     }
     420            0 :                     hg(i) = Nu(i) * con / gap(i);
     421              :                 } // gaps
     422              :             } else {
     423            0 :                 for (i = 1; i <= nlayer - 1; ++i) {
     424            0 :                     Nu(i) = 1.0;
     425            0 :                     hg(i) = Nu(i) * con / gap(i); // Autodesk:Uninit con was uninitialized
     426              :                 }
     427              :             }
     428            0 :             for (i = 1; i <= nlayer - 1; ++i) {
     429            0 :                 hr(i) = 4.0 * Constant::StefanBoltzmann * std::pow(1.0 / emis(2 * i) + 1.0 / emis(2 * i + 1) - 1.0, -1.0) * pow_3(Tm);
     430            0 :                 hs(i) = hg(i) + hr(i);
     431            0 :                 rs(2 * i + 1) = 1.0 / hs(i); // Thermal resistance of each gap
     432            0 :                 sumRs += rs(2 * i + 1);
     433              :             }
     434              :             //    write(18,*) '------'
     435              :             //    close(18)
     436              : 
     437            0 :             ufactor = 1.0 / (1.0 / hin + 1.0 / hout + sumRs + Rg);
     438            0 :             theta(1) = ufactor * (tind - tout) / hout + tout;
     439            0 :             theta(2 * nlayer) = tind - ufactor * (tind - tout) / hin;
     440            0 :             for (i = 2; i <= nlayer; ++i) {
     441            0 :                 theta(2 * i - 2) = ufactor * (tind - tout) * thick(1) / scon(1) + theta(2 * i - 3);
     442            0 :                 theta(2 * i - 1) = ufactor * (tind - tout) / hs(i - 1) + theta(2 * i - 2);
     443              :             } // end of first iteration
     444              : 
     445              :             // bi More iterations:
     446              :             while (true) {
     447            0 :                 sumRsold = sumRs;
     448            0 :                 sumRs = 0.0;
     449              : 
     450            0 :                 if ((standard == TARCOGGassesParams::Stdrd::EN673) && (nlayer == 2)) {
     451            0 :                     return; // If EN673 declared values path and glazing has 2 layers, end claculations and return
     452              :                 } else {
     453            0 :                     if (tind > tout) {
     454            0 :                         for (i = 1; i <= nlayer - 1; ++i) {
     455            0 :                             dT(i) = 15.0 * (1.0 / hs(i)) / sumRsold; // updated temperature distribution
     456            0 :                             if (standard == TARCOGGassesParams::Stdrd::EN673) {
     457            0 :                                 Tm = 283.0;
     458              :                             } else {
     459            0 :                                 Tm = (theta(2 * i) + theta(2 * i + 1)) / 2.0;
     460              :                             }
     461            0 :                             for (j = 1; j <= nmix(i + 1); ++j) {
     462            0 :                                 ipropg(j) = iprop(i + 1, j);
     463            0 :                                 frctg(j) = frct(i + 1, j);
     464              :                             } // j, gas mix
     465            0 :                             GASSES90(state,
     466              :                                      Tm,
     467              :                                      ipropg,
     468              :                                      frctg,
     469            0 :                                      presure(i + 1),
     470            0 :                                      nmix(i + 1),
     471              :                                      xwght,
     472              :                                      xgcon,
     473              :                                      xgvis,
     474              :                                      xgcp,
     475              :                                      con,
     476              :                                      visc,
     477              :                                      dens,
     478              :                                      cp,
     479              :                                      pr,
     480              :                                      standard,
     481              :                                      nperr,
     482              :                                      ErrorMessage);
     483            0 :                             Gr(i) = (Constant::Gravity * pow_3(gap(i)) * dT(i) * pow_2(dens)) / (Tm * pow_2(visc));
     484            0 :                             Ra(i) = Gr(i) * pr;
     485            0 :                             Nu(i) = A * std::pow(Ra(i), n);
     486            0 :                             if (Nu(i) < 1.0) {
     487            0 :                                 Nu(i) = 1.0;
     488              :                             }
     489            0 :                             hg(i) = Nu(i) * con / gap(i);
     490              :                         } // i, gaps
     491              :                     } else {
     492            0 :                         for (i = 1; i <= nlayer - 1; ++i) {
     493            0 :                             Nu(i) = 1.0;
     494            0 :                             hg(i) = Nu(i) * con / gap(i); // Autodesk:Uninit con was possibly uninitialized
     495              :                         }
     496              :                     } // tind > tout
     497              :                 }
     498              : 
     499            0 :                 for (i = 1; i <= nlayer - 1; ++i) {
     500              :                     //      hr(i) = 4 * sigma * (1/emis(2*i) + 1/emis(2*i+1) - 1)**(-1) * Tm**3
     501            0 :                     hs(i) = hg(i) + hr(i);
     502            0 :                     rs(2 * i + 1) = 1.0 / hs(i); // Thermal resistance of each gap
     503            0 :                     sumRs += rs(2 * i + 1);
     504              :                 }
     505            0 :                 ufactor = 1.0 / (1.0 / hin + 1.0 / hout + sumRs + Rg);
     506            0 :                 theta(1) = ufactor * (tind - tout) / hout + tout;
     507            0 :                 theta(2 * nlayer) = tind - ufactor * (tind - tout) / hin;
     508            0 :                 for (i = 2; i <= nlayer; ++i) {
     509            0 :                     theta(2 * i - 2) = ufactor * (tind - tout) * thick(1) / scon(1) + theta(2 * i - 3);
     510            0 :                     theta(2 * i - 1) = ufactor * (tind - tout) / hs(i - 1) + theta(2 * i - 2);
     511              :                 }
     512            0 :                 ++iter; // end of next iteration
     513            0 :                 diff = std::abs(sumRs - sumRsold);
     514              :                 // bi: perhaps we should also limit No. of iterations?
     515            0 :                 if (diff < eps) break; // tolerance was met - exit loop
     516              :             }                          // remaining iterations
     517              :         }
     518              : 
     519              :         // dr...END OF ITERATIONS
     520            0 :     }
     521              : 
     522            0 :     void linint(Real64 const x1, Real64 const x2, Real64 const y1, Real64 const y2, Real64 const x, Real64 &y)
     523              :     {
     524              : 
     525            0 :         y = (y2 - y1) / (x2 - x1) * (x - x1) + y1; // Autodesk:DivZero Should protect against divide by zero
     526            0 :     }
     527              : 
     528            0 :     void solar_EN673(Real64 const dir,
     529              :                      Real64 const totsol,
     530              :                      Real64 const rtot,
     531              :                      const Array1D<Real64> &rs,
     532              :                      int const nlayer,
     533              :                      const Array1D<Real64> &absol,
     534              :                      Real64 &sf,
     535              :                      TARCOGGassesParams::Stdrd const standard,
     536              :                      int &nperr,
     537              :                      std::string &ErrorMessage)
     538              :     {
     539              :         //***********************************************************************
     540              :         //   This subroutine calculates the shading coefficient for a window.
     541              :         //***********************************************************************
     542              :         //  Inputs:
     543              :         //    absol     array of absorped fraction of solar radiation in lites
     544              :         //    totsol    total solar transmittance
     545              :         //    rtot      total thermal resistance of window
     546              :         //    rs        array of thermal resistances of each gap and layer
     547              :         //    layer     number of layers
     548              :         //  Outputs:
     549              :         //    sf        solar gain of space
     550              : 
     551              :         // Argument array dimensioning
     552            0 :         EP_SIZE_CHECK(rs, maxlay3);
     553            0 :         EP_SIZE_CHECK(absol, maxlay);
     554              : 
     555              :         // Locals
     556              :         int i;
     557              :         int j;
     558              :         Real64 fract;
     559              :         Real64 flowin;
     560              : 
     561            0 :         fract = 0.0;
     562            0 :         flowin = 0.0;
     563            0 :         sf = 0.0;
     564              : 
     565              :         // evaluate inward flowing fraction of absorbed radiation:
     566            0 :         if ((standard == TARCOGGassesParams::Stdrd::EN673) || (standard == TARCOGGassesParams::Stdrd::EN673Design)) {
     567            0 :             if (nlayer == 1) {
     568            0 :                 fract = dir * absol(1) * (rs(1) * rs(3)) / (rs(1) * (rs(1) + rs(3)));
     569              :             } else {
     570            0 :                 flowin = (rs(1) + 0.5 * rs(2)) / rtot;
     571            0 :                 fract = dir * absol(1) * rs(10);
     572            0 :                 for (i = 2; i <= nlayer; ++i) {
     573            0 :                     j = 2 * i;
     574            0 :                     flowin += (0.5 * (rs(j - 2) + 0.5 * rs(j)) + rs(j - 1)) / rtot;
     575            0 :                     fract += absol(i) * flowin;
     576              :                 }
     577            0 :                 fract += dir * absol(nlayer) * rs(2 * nlayer) / 2.0;
     578              :             }
     579              :         } else {
     580            0 :             nperr = 28;
     581            0 :             ErrorMessage = "Invalid code for standard.";
     582            0 :             return;
     583              :         }
     584              : 
     585            0 :         sf = totsol + fract; // add inward fraction to directly transmitted fraction
     586              :     }
     587              : 
     588              : } // namespace ThermalEN673Calc
     589              : 
     590              : } // namespace EnergyPlus
        

Generated by: LCOV version 2.0-1