LCOV - code coverage report
Current view: top level - EnergyPlus - TARCOGArgs.cc (source / functions) Hit Total Coverage
Test: lcov.output.filtered Lines: 154 258 59.7 %
Date: 2023-01-17 19:17:23 Functions: 5 5 100.0 %

          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             : #include <EnergyPlus/DataGlobals.hh>
      49             : 
      50             : // EnergyPlus Headers
      51             : #include <EnergyPlus/TARCOGArgs.hh>
      52             : #include <EnergyPlus/TARCOGCommon.hh>
      53             : #include <EnergyPlus/TARCOGGassesParams.hh>
      54             : #include <EnergyPlus/TARCOGParams.hh>
      55             : 
      56             : namespace EnergyPlus::TARCOGArgs {
      57             : 
      58             : // MODULE INFORMATION:
      59             : //       AUTHOR         Simon Vidanovic
      60             : //       DATE WRITTEN   June/22/2010
      61             : //       MODIFIED       na
      62             : //       RE-ENGINEERED  na
      63             : //  Revision: 6.0.36  (June/22/2010)
      64             : //   - Initial setup, extracted from TARCOG.for
      65             : 
      66             : // PURPOSE OF THIS MODULE:
      67             : // A module which contains common functions for error checking and
      68             : //    preparation of arguments and intermediate variables
      69             : 
      70             : // Using/Aliasing
      71             : using namespace TARCOGCommon;
      72             : using namespace TARCOGGassesParams;
      73             : using namespace TARCOGOutput;
      74             : using namespace TARCOGParams;
      75             : 
      76       37990 : int ArgCheck(EnergyPlusData &state,
      77             :              Files &files,
      78             :              int const nlayer,
      79             :              int const iwd,
      80             :              Real64 const tout,
      81             :              Real64 const tind,
      82             :              Real64 const trmin,
      83             :              Real64 const wso,
      84             :              Real64 const wsi,
      85             :              Real64 const dir,
      86             :              Real64 const outir,
      87             :              int const isky,
      88             :              Real64 const tsky,
      89             :              Real64 const esky,
      90             :              Real64 const fclr,
      91             :              Real64 const VacuumPressure,
      92             :              Real64 const VacuumMaxGapThickness,
      93             :              DeflectionCalculation const CalcDeflection,
      94             :              Real64 const Pa,
      95             :              Real64 const Pini,
      96             :              Real64 const Tini,
      97             :              const Array1D<Real64> &gap,
      98             :              const Array1D<Real64> &GapDef,
      99             :              const Array1D<Real64> &thick,
     100             :              const Array1D<Real64> &scon,
     101             :              const Array1D<Real64> &YoungsMod,
     102             :              const Array1D<Real64> &PoissonsRat,
     103             :              const Array1D<Real64> &tir,
     104             :              const Array1D<Real64> &emis,
     105             :              Real64 const totsol,
     106             :              Real64 const tilt,
     107             :              const Array1D<Real64> &asol,
     108             :              Real64 const height,
     109             :              Real64 const heightt,
     110             :              Real64 const width,
     111             :              const Array1D<Real64> &presure,
     112             :              Array2A_int const iprop,
     113             :              Array2A<Real64> const frct,
     114             :              Array2A<Real64> const xgcon,
     115             :              Array2A<Real64> const xgvis,
     116             :              Array2A<Real64> const xgcp,
     117             :              const Array1D<Real64> &xwght,
     118             :              const Array1D<Real64> &gama,
     119             :              const Array1D_int &nmix,
     120             :              const Array1D_int &SupportPillar,     // Shows whether or not gap have support pillar
     121             :              const Array1D<Real64> &PillarSpacing, // Pillar spacing for each gap (used in case there is support pillar)
     122             :              const Array1D<Real64> &PillarRadius,  // Pillar radius for each gap (used in case there is support pillar)
     123             :              Real64 &hin,
     124             :              Real64 &hout,
     125             :              const Array1D_int &ibc,
     126             :              const Array1D<Real64> &Atop,
     127             :              const Array1D<Real64> &Abot,
     128             :              const Array1D<Real64> &Al,
     129             :              const Array1D<Real64> &Ar,
     130             :              const Array1D<Real64> &Ah,
     131             :              const Array1D<Real64> &SlatThick,
     132             :              const Array1D<Real64> &SlatWidth,
     133             :              const Array1D<Real64> &SlatAngle,
     134             :              const Array1D<Real64> &SlatCond,
     135             :              const Array1D<Real64> &SlatSpacing,
     136             :              const Array1D<Real64> &SlatCurve,
     137             :              const Array1D<Real64> &vvent,
     138             :              const Array1D<Real64> &tvent,
     139             :              const Array1D<TARCOGParams::TARCOGLayerType> &LayerType,
     140             :              const Array1D_int &nslice,
     141             :              const Array1D<Real64> &LaminateA,
     142             :              const Array1D<Real64> &LaminateB,
     143             :              const Array1D<Real64> &sumsol,
     144             :              TARCOGGassesParams::Stdrd const standard,
     145             :              TARCOGThermalModel const ThermalMod,
     146             :              Real64 const SDScalar,
     147             :              std::string &ErrorMessage)
     148             : {
     149             : 
     150             :     // Return value
     151             :     int ArgCheck;
     152             : 
     153             :     // Argument array dimensioning
     154       37990 :     EP_SIZE_CHECK(gap, maxlay);
     155       37990 :     EP_SIZE_CHECK(GapDef, MaxGap);
     156       37990 :     EP_SIZE_CHECK(thick, maxlay);
     157       37990 :     EP_SIZE_CHECK(scon, maxlay);
     158       37990 :     EP_SIZE_CHECK(YoungsMod, maxlay);
     159       37990 :     EP_SIZE_CHECK(PoissonsRat, maxlay);
     160       37990 :     EP_SIZE_CHECK(tir, maxlay2);
     161       37990 :     EP_SIZE_CHECK(emis, maxlay2);
     162       37990 :     EP_SIZE_CHECK(asol, maxlay);
     163       37990 :     EP_SIZE_CHECK(presure, maxlay1);
     164       37990 :     iprop.dim(maxgas, maxlay1);
     165       37990 :     frct.dim(maxgas, maxlay1);
     166       37990 :     xgcon.dim(3, maxgas);
     167       37990 :     xgvis.dim(3, maxgas);
     168       37990 :     xgcp.dim(3, maxgas);
     169       37990 :     EP_SIZE_CHECK(xwght, maxgas);
     170       37990 :     EP_SIZE_CHECK(gama, maxgas);
     171       37990 :     EP_SIZE_CHECK(nmix, maxlay1);
     172       37990 :     EP_SIZE_CHECK(SupportPillar, maxlay);
     173       37990 :     EP_SIZE_CHECK(PillarSpacing, maxlay);
     174       37990 :     EP_SIZE_CHECK(PillarRadius, maxlay);
     175       37990 :     EP_SIZE_CHECK(ibc, 2);
     176       37990 :     EP_SIZE_CHECK(Atop, maxlay);
     177       37990 :     EP_SIZE_CHECK(Abot, maxlay);
     178       37990 :     EP_SIZE_CHECK(Al, maxlay);
     179       37990 :     EP_SIZE_CHECK(Ar, maxlay);
     180       37990 :     EP_SIZE_CHECK(Ah, maxlay);
     181       37990 :     EP_SIZE_CHECK(SlatThick, maxlay);
     182       37990 :     EP_SIZE_CHECK(SlatWidth, maxlay);
     183       37990 :     EP_SIZE_CHECK(SlatAngle, maxlay);
     184       37990 :     EP_SIZE_CHECK(SlatCond, maxlay);
     185       37990 :     EP_SIZE_CHECK(SlatSpacing, maxlay);
     186       37990 :     EP_SIZE_CHECK(SlatCurve, maxlay);
     187       37990 :     EP_SIZE_CHECK(vvent, maxlay1);
     188       37990 :     EP_SIZE_CHECK(tvent, maxlay1);
     189       37990 :     EP_SIZE_CHECK(LayerType, maxlay);
     190       37990 :     EP_SIZE_CHECK(nslice, maxlay);
     191       37990 :     EP_SIZE_CHECK(LaminateA, maxlay);
     192       37990 :     EP_SIZE_CHECK(LaminateB, maxlay);
     193       37990 :     EP_SIZE_CHECK(sumsol, maxlay);
     194             : 
     195             :     // bi...Write debug output files - if debug flag = 1:
     196             : 
     197       37990 :     if (files.WriteDebugOutput) {
     198             : 
     199           0 :         WriteInputArguments(state,
     200             :                             files.DebugOutputFile,
     201             :                             files.DBGD,
     202             :                             tout,
     203             :                             tind,
     204             :                             trmin,
     205             :                             wso,
     206             :                             iwd,
     207             :                             wsi,
     208             :                             dir,
     209             :                             outir,
     210             :                             isky,
     211             :                             tsky,
     212             :                             esky,
     213             :                             fclr,
     214             :                             VacuumPressure,
     215             :                             VacuumMaxGapThickness,
     216             :                             ibc,
     217             :                             hout,
     218             :                             hin,
     219             :                             standard,
     220             :                             ThermalMod,
     221             :                             SDScalar,
     222             :                             height,
     223             :                             heightt,
     224             :                             width,
     225             :                             tilt,
     226             :                             totsol,
     227             :                             nlayer,
     228             :                             LayerType,
     229             :                             thick,
     230             :                             scon,
     231             :                             asol,
     232             :                             tir,
     233             :                             emis,
     234             :                             Atop,
     235             :                             Abot,
     236             :                             Al,
     237             :                             Ar,
     238             :                             Ah,
     239             :                             SlatThick,
     240             :                             SlatWidth,
     241             :                             SlatAngle,
     242             :                             SlatCond,
     243             :                             SlatSpacing,
     244             :                             SlatCurve,
     245             :                             nslice,
     246             :                             LaminateA,
     247             :                             LaminateB,
     248             :                             sumsol,
     249             :                             gap,
     250             :                             vvent,
     251             :                             tvent,
     252             :                             presure,
     253             :                             nmix,
     254             :                             iprop,
     255             :                             frct,
     256             :                             xgcon,
     257             :                             xgvis,
     258             :                             xgcp,
     259             :                             xwght);
     260             : 
     261           0 :         std::string const VersionNumber(" 7.0.15.00 ");
     262           0 :         WriteTARCOGInputFile(state,
     263             :                              files,
     264             :                              VersionNumber,
     265             :                              tout,
     266             :                              tind,
     267             :                              trmin,
     268             :                              wso,
     269             :                              iwd,
     270             :                              wsi,
     271             :                              dir,
     272             :                              outir,
     273             :                              isky,
     274             :                              tsky,
     275             :                              esky,
     276             :                              fclr,
     277             :                              VacuumPressure,
     278             :                              VacuumMaxGapThickness,
     279             :                              CalcDeflection,
     280             :                              Pa,
     281             :                              Pini,
     282             :                              Tini,
     283             :                              ibc,
     284             :                              hout,
     285             :                              hin,
     286             :                              standard,
     287             :                              ThermalMod,
     288             :                              SDScalar,
     289             :                              height,
     290             :                              heightt,
     291             :                              width,
     292             :                              tilt,
     293             :                              totsol,
     294             :                              nlayer,
     295             :                              LayerType,
     296             :                              thick,
     297             :                              scon,
     298             :                              YoungsMod,
     299             :                              PoissonsRat,
     300             :                              asol,
     301             :                              tir,
     302             :                              emis,
     303             :                              Atop,
     304             :                              Abot,
     305             :                              Al,
     306             :                              Ar,
     307             :                              Ah,
     308             :                              SupportPillar,
     309             :                              PillarSpacing,
     310             :                              PillarRadius,
     311             :                              SlatThick,
     312             :                              SlatWidth,
     313             :                              SlatAngle,
     314             :                              SlatCond,
     315             :                              SlatSpacing,
     316             :                              SlatCurve,
     317             :                              nslice,
     318             :                              gap,
     319             :                              GapDef,
     320             :                              vvent,
     321             :                              tvent,
     322             :                              presure,
     323             :                              nmix,
     324             :                              iprop,
     325             :                              frct,
     326             :                              xgcon,
     327             :                              xgvis,
     328             :                              xgcp,
     329             :                              xwght,
     330             :                              gama);
     331             : 
     332             :     } // if debug=1 - write dbg output file
     333             : 
     334             :     // bi...assume All OK
     335       37990 :     ArgCheck = 0;
     336             : 
     337             :     // dr...check for error messages
     338       37990 :     if (nlayer < 1) {
     339           0 :         ArgCheck = 17;
     340           0 :         ErrorMessage = "Number of layers must be >0.";
     341           0 :         return ArgCheck;
     342             :     }
     343             : 
     344       37990 :     if ((static_cast<int>(standard) < MinStandard) || (static_cast<int>(standard) > MaxStandard)) {
     345           0 :         ArgCheck = 28;
     346           0 :         ErrorMessage = "Invalid code for standard.";
     347           0 :         return ArgCheck;
     348             :     }
     349             : 
     350       37990 :     if ((ThermalMod != TARCOGThermalModel::ISO15099) && (ThermalMod != TARCOGThermalModel::SCW) && (ThermalMod != TARCOGThermalModel::CSM)) {
     351           0 :         ArgCheck = 29;
     352           0 :         ErrorMessage = "Invalid code for thermal mode.";
     353           0 :         return ArgCheck;
     354             :     }
     355             : 
     356       37990 :     if ((iwd != 0) && (iwd != 1)) {
     357           0 :         ArgCheck = 18;
     358           0 :         ErrorMessage = "Wind direction can be windward (=0) or leeward (=1).";
     359           0 :         return ArgCheck;
     360             :     }
     361             : 
     362       37990 :     if ((fclr < 0.0) || (fclr > 1.0)) {
     363           0 :         ArgCheck = 19;
     364           0 :         ErrorMessage = "Fraction of sky that is clear can be in range between 0 and 1.";
     365           0 :         return ArgCheck;
     366             :     }
     367             : 
     368      106572 :     for (int i = 1; i <= nlayer - 1; ++i) {
     369       68582 :         if (gap(i) <= 0.0) {
     370           0 :             ArgCheck = 20;
     371           0 :             ErrorMessage = format("Gap width is less than (or equal to) zero. Gap #{:3}", i);
     372           0 :             return ArgCheck;
     373             :         }
     374             :     }
     375             : 
     376      144562 :     for (int i = 1; i <= nlayer; ++i) {
     377      106572 :         if (thick(i) <= 0.0) {
     378           0 :             ArgCheck = 21;
     379           0 :             ErrorMessage = format("Layer width is less than (or equal to) zero. Layer #{:3}", i);
     380           0 :             return ArgCheck;
     381             :         }
     382      106572 :         if ((i < nlayer) && IsShadingLayer(LayerType(i)) && IsShadingLayer(LayerType(i + 1))) {
     383           0 :             ArgCheck = 37;
     384           0 :             ErrorMessage = "Cannot handle two consecutive shading layers.";
     385           0 :             return ArgCheck;
     386             :         }
     387             :         // Deflection cannot be calculated with IGU containing shading layer. This error check is to be
     388             :         // removed once that extension is programmed
     389      106572 :         if ((CalcDeflection != TARCOGParams::DeflectionCalculation::NONE) && (LayerType(i) != TARCOGParams::TARCOGLayerType::SPECULAR)) {
     390           0 :             ArgCheck = 42;
     391           0 :             ErrorMessage = "Cannot calculate deflection with IGU containing shading devices.";
     392           0 :             return ArgCheck;
     393             :         }
     394             :     }
     395             : 
     396       37990 :     if (height <= 0.0) {
     397           0 :         ArgCheck = 23;
     398           0 :         ErrorMessage = "IGU cavity height must be greater than zero.";
     399           0 :         return ArgCheck;
     400             :     }
     401             : 
     402       37990 :     if (heightt <= 0.0) {
     403           0 :         ArgCheck = 24;
     404           0 :         ErrorMessage = "Total window height must be greater than zero.";
     405           0 :         return ArgCheck;
     406             :     }
     407             : 
     408       37990 :     if (width <= 0.0) {
     409           0 :         ArgCheck = 25;
     410           0 :         ErrorMessage = "Window width must be greater than zero.";
     411           0 :         return ArgCheck;
     412             :     }
     413             : 
     414       37990 :     if ((SDScalar < 0.0) || (SDScalar > 1.0)) {
     415           0 :         ArgCheck = 30;
     416           0 :         ErrorMessage = "SDscalar is out of range (<0.0 or >1.0).";
     417           0 :         return ArgCheck;
     418             :     }
     419             : 
     420             :     // bi...Check layers and update Venetian blinds properties:
     421      144562 :     for (int i = 1; i <= nlayer; ++i) {
     422      106572 :         if (scon(i) <= 0.0) {
     423           0 :             ArgCheck = 26;
     424           0 :             ErrorMessage = format("Layer {:3} has conductivity whcih is less or equal to zero.", i);
     425           0 :             return ArgCheck;
     426             :         }
     427             : 
     428      106572 :         if (BITF_TEST_NONE(BITF(LayerType(i)),
     429             :                            BITF(TARCOGLayerType::SPECULAR) | BITF(TARCOGLayerType::WOVSHADE) | BITF(TARCOGLayerType::VENETBLIND_HORIZ) |
     430             :                                BITF(TARCOGLayerType::PERFORATED) | BITF(TARCOGLayerType::DIFFSHADE) | BITF(TARCOGLayerType::BSDF) |
     431             :                                BITF(TARCOGLayerType::VENETBLIND_VERT)))
     432             : 
     433             :         {
     434           0 :             ArgCheck = 22;
     435           0 :             ErrorMessage = format("Incorrect layer type for layer #{:3}"
     436             :                                   ".  Layer type can either be 0 (glazing layer), 1 (Venetian blind), 2 (woven shade), 3 (perforated), 4 (diffuse "
     437             :                                   "shade) or 5 (bsdf).",
     438           0 :                                   i);
     439           0 :             return ArgCheck;
     440             :         }
     441             : 
     442             :         // bi...TEMPORARY! Don't allow CSW and CSM method for outdoor and indoor SD layers
     443      106572 :         if ((IsShadingLayer(LayerType(1))) && ((ThermalMod == TARCOGThermalModel::SCW) || (ThermalMod == TARCOGThermalModel::CSM))) {
     444           0 :             ArgCheck = 39;
     445           0 :             ErrorMessage = "CSM and SCW thermal models cannot be used for outdoor and indoor SD layers.";
     446           0 :             return ArgCheck;
     447             :         }
     448      106572 :         if ((IsShadingLayer(LayerType(nlayer))) && ((ThermalMod == TARCOGThermalModel::SCW) || (ThermalMod == TARCOGThermalModel::CSM))) {
     449           0 :             ArgCheck = 39;
     450           0 :             ErrorMessage = "CSM and SCW thermal models cannot be used for outdoor and indoor SD layers.";
     451           0 :             return ArgCheck;
     452             :         }
     453             : 
     454      210116 :         if (LayerType(i) == TARCOGParams::TARCOGLayerType::VENETBLIND_HORIZ ||
     455      103544 :             LayerType(i) == TARCOGParams::TARCOGLayerType::VENETBLIND_VERT) { // Venetian blind specific:
     456        5718 :             if (SlatThick(i) <= 0) {
     457           0 :                 ArgCheck = 31;
     458           0 :                 ErrorMessage = format("Invalid slat thickness (must be >0). Layer #{:3}", i);
     459           0 :                 return ArgCheck;
     460             :             }
     461        5718 :             if (SlatWidth(i) <= 0.0) {
     462           0 :                 ArgCheck = 32;
     463           0 :                 ErrorMessage = format("Invalid slat width (must be >0). Layer #{:3}", i);
     464           0 :                 return ArgCheck;
     465             :             }
     466        5718 :             if ((SlatAngle(i) < -90.0) || (SlatAngle(i) > 90.0)) {
     467           0 :                 ArgCheck = 33;
     468           0 :                 ErrorMessage = format("Invalid slat angle (must be between -90 and 90). Layer #{:3}", i);
     469           0 :                 return ArgCheck;
     470             :             }
     471        5718 :             if (SlatCond(i) <= 0.0) {
     472           0 :                 ArgCheck = 34;
     473           0 :                 ErrorMessage = format("Invalid conductivity of slat material (must be >0). Layer #{:3}", i);
     474           0 :                 return ArgCheck;
     475             :             }
     476        5718 :             if (SlatSpacing(i) <= 0.0) {
     477           0 :                 ArgCheck = 35;
     478           0 :                 ErrorMessage = format("Invalid slat spacing (must be >0). Layer #{:3}", i);
     479           0 :                 return ArgCheck;
     480             :             }
     481        5718 :             if ((SlatCurve(i) != 0.0) && (std::abs(SlatCurve(i)) <= (SlatWidth(i) / 2.0))) {
     482           0 :                 ArgCheck = 36;
     483           0 :                 ErrorMessage = format("Invalid curvature radius (absolute value must be >SlatWidth/2, or 0 for flat slats). Layer #{:3}", i);
     484           0 :                 return ArgCheck;
     485             :             }
     486             : 
     487             :         } //  LayerType is Venetian
     488             : 
     489             :     } // Layers...
     490             : 
     491      365104 :     for (int i = 1; i <= nlayer + 1; ++i) {
     492      144562 :         if (presure(i) < 0.0) {
     493           0 :             ArgCheck = 27;
     494           0 :             if ((i == 1) || (i == (nlayer + 1))) {
     495           0 :                 ErrorMessage = "One of enviroments (inside or outside) has pressure which is less than zero.";
     496             :             } else {
     497           0 :                 ErrorMessage = format("One of gaps has pressure which is less than zero. Gap #{:3}", i);
     498             :             }
     499           0 :             return ArgCheck;
     500             :         }
     501             :     }
     502             : 
     503       37990 :     return ArgCheck;
     504             : }
     505             : 
     506       37990 : void PrepVariablesISO15099(int const nlayer,
     507             :                            Real64 const tout,
     508             :                            Real64 const tind,
     509             :                            Real64 &trmin,
     510             :                            int const isky,
     511             :                            Real64 const outir,
     512             :                            // IR radiance of window's exterior/interior surround (W/m2)
     513             :                            Real64 const tsky,
     514             :                            Real64 &esky,
     515             :                            Real64 const fclr,
     516             :                            Array1D<Real64> &gap,
     517             :                            Array1D<Real64> &thick,
     518             :                            Array1D<Real64> &scon,
     519             :                            const Array1D<Real64> &tir,
     520             :                            const Array1D<Real64> &emis,
     521             :                            Real64 const tilt,
     522             :                            Real64 &hin,
     523             :                            Real64 &hout,
     524             :                            const Array1D_int &ibc,
     525             :                            const Array1D<Real64> &SlatThick,
     526             :                            const Array1D<Real64> &SlatWidth,
     527             :                            const Array1D<Real64> &SlatAngle,
     528             :                            const Array1D<Real64> &SlatCond,
     529             :                            const Array1D<TARCOGLayerType> &LayerType,
     530             :                            TARCOGThermalModel const ThermalMod,
     531             :                            Real64 const SDScalar,
     532             :                            Real64 &ShadeEmisRatioOut,
     533             :                            Real64 &ShadeEmisRatioIn,
     534             :                            Real64 &ShadeHcRatioOut,
     535             :                            Real64 &ShadeHcRatioIn,
     536             :                            Array1D<Real64> &Keff,
     537             :                            Array1D<Real64> &ShadeGapKeffConv,
     538             :                            Real64 &sc,
     539             :                            Real64 &shgc,
     540             :                            Real64 &ufactor,
     541             :                            Real64 &flux,
     542             :                            Array1D<Real64> &LaminateAU,
     543             :                            Array1D<Real64> &sumsolU,
     544             :                            Array1D<Real64> &sol0,
     545             :                            Real64 &hint,
     546             :                            Real64 &houtt,
     547             :                            Real64 &trmout,
     548             :                            Real64 &ebsky,
     549             :                            Real64 &ebroom,
     550             :                            Real64 &Gout,
     551             :                            Real64 &Gin,
     552             :                            Array1D<Real64> &rir,
     553             :                            Array1D<Real64> &vfreevent,
     554             :                            int &nperr,
     555             :                            std::string &ErrorMessage)
     556             : {
     557             : 
     558             :     // Argument array dimensioning
     559       37990 :     EP_SIZE_CHECK(gap, MaxGap);
     560       37990 :     EP_SIZE_CHECK(thick, maxlay);
     561       37990 :     EP_SIZE_CHECK(scon, maxlay);
     562       37990 :     EP_SIZE_CHECK(tir, maxlay2);
     563       37990 :     EP_SIZE_CHECK(emis, maxlay2);
     564       37990 :     EP_SIZE_CHECK(ibc, 2);
     565       37990 :     EP_SIZE_CHECK(SlatThick, maxlay);
     566       37990 :     EP_SIZE_CHECK(SlatWidth, maxlay);
     567       37990 :     EP_SIZE_CHECK(SlatAngle, maxlay);
     568       37990 :     EP_SIZE_CHECK(SlatCond, maxlay);
     569       37990 :     EP_SIZE_CHECK(LayerType, maxlay);
     570       37990 :     EP_SIZE_CHECK(Keff, maxlay);
     571       37990 :     EP_SIZE_CHECK(ShadeGapKeffConv, MaxGap);
     572       37990 :     EP_SIZE_CHECK(LaminateAU, maxlay);
     573       37990 :     EP_SIZE_CHECK(sumsolU, maxlay);
     574       37990 :     EP_SIZE_CHECK(sol0, maxlay);
     575       37990 :     EP_SIZE_CHECK(rir, maxlay2);
     576       37990 :     EP_SIZE_CHECK(vfreevent, maxlay1);
     577             : 
     578             :     int k1;
     579             :     Real64 tiltr;
     580             :     Real64 Rsky;
     581             :     Real64 Fsky;
     582             :     Real64 Fground;
     583             :     Real64 e0;
     584       75980 :     std::string a;
     585             : 
     586             :     //! Scalars:
     587       37990 :     ShadeEmisRatioOut = 1.0;
     588       37990 :     ShadeEmisRatioIn = 1.0;
     589       37990 :     ShadeHcRatioOut = 1.0;
     590       37990 :     ShadeHcRatioIn = 1.0;
     591             : 
     592             :     //! re-initialize iteration parameters:
     593       37990 :     sc = 0.0;
     594       37990 :     shgc = 0.0;
     595       37990 :     ufactor = 0.0;
     596       37990 :     flux = 0.0;
     597             : 
     598             :     //! Vectors:
     599       37990 :     LaminateAU = 0.0;
     600       37990 :     sumsolU = 0.0;
     601       37990 :     vfreevent = 0.0;
     602       37990 :     sol0 = 0.0;
     603             :     // bi...    Clear keff, keffc elements:
     604       37990 :     Keff = 0.0;
     605       37990 :     ShadeGapKeffConv = 0.0;
     606             : 
     607             :     // Adjust shading layer properties
     608      144562 :     for (int i = 1; i <= nlayer; ++i) {
     609      210116 :         if ((TARCOGLayerType)LayerType(i) == TARCOGParams::TARCOGLayerType::VENETBLIND_HORIZ ||
     610      103544 :             (TARCOGLayerType)LayerType(i) == TARCOGParams::TARCOGLayerType::VENETBLIND_VERT) {
     611        5718 :             scon(i) = SlatCond(i);
     612        5718 :             if (ThermalMod == TARCOGThermalModel::SCW) {
     613             :                 // bi...the idea here is to have glass-to-glass width the same as before scaling
     614             :                 // bi...TODO: check for outdoor and indoor blinds! SCW model is only applicable to in-between SDs!!!
     615           0 :                 thick(i) = SlatWidth(i) * std::cos(SlatAngle(i) * DataGlobalConstants::Pi / 180.0);
     616           0 :                 if (i > 1) gap(i - 1) += (1.0 - SDScalar) / 2.0 * thick(i); // Autodesk:BoundsViolation gap(i-1) @ i=1: Added if condition
     617           0 :                 gap(i) += (1.0 - SDScalar) / 2.0 * thick(i);
     618           0 :                 thick(i) *= SDScalar;
     619           0 :                 if (thick(i) < SlatThick(i)) thick(i) = SlatThick(i);
     620        5718 :             } else if ((ThermalMod == TARCOGThermalModel::ISO15099) || (ThermalMod == TARCOGThermalModel::CSM)) {
     621        5718 :                 thick(i) = SlatThick(i);
     622        5718 :                 const Real64 slatAngRad = SlatAngle(i) * 2.0 * DataGlobalConstants::Pi / 360.0;
     623        5718 :                 Real64 C4_VENET(0);
     624        5718 :                 if ((TARCOGLayerType)LayerType(i) == TARCOGParams::TARCOGLayerType::VENETBLIND_HORIZ) {
     625        3028 :                     C4_VENET = C4_VENET_HORIZONTAL;
     626             :                 }
     627        5718 :                 if ((TARCOGLayerType)LayerType(i) == TARCOGParams::TARCOGLayerType::VENETBLIND_VERT) {
     628        2690 :                     C4_VENET = C4_VENET_VERTICAL;
     629             :                 }
     630        5718 :                 thick(i) = C4_VENET * (SlatWidth(i) * cos(slatAngRad) + thick(i) * sin(slatAngRad));
     631             :             }
     632             :         } // Venetian
     633             :     }
     634             : 
     635       37990 :     hint = hin;
     636       37990 :     houtt = hout;
     637       37990 :     tiltr = tilt * 2.0 * DataGlobalConstants::Pi / 360.0; // convert tilt in degrees to radians
     638             : 
     639             :     // external radiation term
     640       37990 :     switch (isky) {
     641       37968 :     case 3:
     642       37968 :         Gout = outir;
     643       37968 :         trmout = root_4(Gout / DataGlobalConstants::StefanBoltzmann);
     644       37968 :         break;
     645           0 :     case 2: // effective clear sky emittance from swinbank (SPC142/ISO15099 equations 131, 132, ...)
     646           0 :         Rsky = 5.31e-13 * pow_6(tout);
     647           0 :         esky = Rsky / (DataGlobalConstants::StefanBoltzmann * pow_4(tout)); // check esky const, also check what esky to use when tsky input...
     648           0 :         break;
     649           0 :     case 1:
     650           0 :         esky = pow_4(tsky) / pow_4(tout);
     651           0 :         break;
     652          22 :     case 0: // for isky=0 it is assumed that actual values for esky and Tsky are specified
     653          22 :         esky *= pow_4(tsky) / pow_4(tout);
     654          22 :         break;
     655           0 :     default:
     656           0 :         nperr = 1; // error 2010: isky can be: 0(esky,Tsky input), 1(Tsky input), or 2(Swinbank model)
     657           0 :         return;
     658             :     }
     659             : 
     660             :     // Simon: In this case we do not need to recalculate Gout and Trmout again
     661       37990 :     if (isky != 3) {
     662          22 :         Fsky = (1.0 + std::cos(tiltr)) / 2.0;
     663          22 :         Fground = 1.0 - Fsky;
     664          22 :         e0 = Fground + (1.0 - fclr) * Fsky + Fsky * fclr * esky;
     665             :         //  Trmout = Tout * e0**0.25d0
     666             : 
     667             :         // bi   Set mean radiant temps for fixed combined film coef. case:
     668             : 
     669          22 :         if (ibc(1) == 1) { // outside BC - fixed combined film coef.
     670           0 :             trmout = tout;
     671             :         } else {
     672          22 :             trmout = tout * root_4(e0);
     673             :         }
     674             : 
     675          22 :         Gout = DataGlobalConstants::StefanBoltzmann * pow_4(trmout);
     676             :     } // if (isky.ne.3) then
     677             : 
     678       37990 :     ebsky = Gout;
     679             : 
     680       37990 :     if (ibc(2) == 1) { // inside BC - fixed combined film coef.
     681           0 :         trmin = tind;
     682             :     }
     683             : 
     684       37990 :     Gin = DataGlobalConstants::StefanBoltzmann * pow_4(trmin);
     685       37990 :     ebroom = Gin;
     686             : 
     687             :     // calculate ir reflectance:
     688      144562 :     for (int k = 1; k <= nlayer; ++k) {
     689      106572 :         k1 = 2 * k - 1;
     690      106572 :         rir(k1) = 1 - tir(k1) - emis(k1);
     691      106572 :         rir(k1 + 1) = 1 - tir(k1) - emis(k1 + 1);
     692      106572 :         if ((tir(k1) < 0.0) || (tir(k1) > 1.0) || (tir(k1 + 1) < 0.0) || (tir(k1 + 1) > 1.0)) {
     693           0 :             nperr = 4;
     694           0 :             ErrorMessage = format("Layer transmissivity is our of range (<0 or >1). Layer #{:3}", k);
     695           0 :             return;
     696             :         }
     697      106572 :         if ((emis(k1) < 0.0) || (emis(k1) > 1.0) || (emis(k1 + 1) < 0.0) || (emis(k1 + 1) > 1.0)) {
     698           0 :             nperr = 14;
     699           0 :             ErrorMessage = format("Layer emissivity is our of range (<0 or >1). Layer #{:3}", k);
     700           0 :             return;
     701             :         }
     702      106572 :         if ((rir(k1) < 0.0) || (rir(k1) > 1.0) || (rir(k1 + 1) < 0.0) || (rir(k1 + 1) > 1.0)) {
     703           0 :             nperr = 3;
     704           0 :             ErrorMessage = format("Layer reflectivity is our of range (<0 or >1). Layer #{:3}", k);
     705           0 :             return;
     706             :         }
     707             :     }
     708             : }
     709             : 
     710     1070301 : bool GoAhead(int const nperr)
     711             : {
     712     1070301 :     return !(((nperr > 0) && (nperr < 1000)) || ((nperr > 2000) && (nperr < 3000)));
     713             : }
     714             : 
     715        2313 : } // namespace EnergyPlus::TARCOGArgs

Generated by: LCOV version 1.13