LCOV - code coverage report
Current view: top level - EnergyPlus - ThermalEN673Calc.cc (source / functions) Hit Total Coverage
Test: lcov.output.filtered Lines: 1 198 0.5 %
Date: 2023-01-17 19:17:23 Functions: 2 6 33.3 %

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

Generated by: LCOV version 1.13