LCOV - code coverage report
Current view: top level - EnergyPlus - TARCOGMain.cc (source / functions) Coverage Total Hit
Test: lcov.output.filtered Lines: 0.0 % 131 0
Test Date: 2025-05-22 16:09:37 Functions: 0.0 % 1 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/Data/EnergyPlusData.hh>
      53              : #include <EnergyPlus/TARCOGArgs.hh>
      54              : #include <EnergyPlus/TARCOGDeflection.hh>
      55              : #include <EnergyPlus/TARCOGGassesParams.hh>
      56              : #include <EnergyPlus/TARCOGMain.hh>
      57              : #include <EnergyPlus/TARCOGOutput.hh>
      58              : #include <EnergyPlus/TARCOGParams.hh>
      59              : #include <EnergyPlus/ThermalEN673Calc.hh>
      60              : #include <EnergyPlus/ThermalISO15099Calc.hh>
      61              : 
      62              : namespace EnergyPlus::TARCOGMain {
      63              : // TARCOG: Thermal Analysis Routine for Center of Glazing
      64              : 
      65              : // MODULE INFORMATION:
      66              : //       AUTHOR         D. Charlie Curcija
      67              : //       DATE WRITTEN   July 2000
      68              : //       MODIFIED       na
      69              : //       RE-ENGINEERED  (see information bellow)
      70              : //  Revision: 7.0.13  (March/27/2012), Simon Vidanovic
      71              : //   - feature: New set of equations is set instead of hhat coefficients and new approach to solution which improves
      72              : //               speed and stability.  Note that this solution does not include laminates
      73              : //  Revision: 7.0.12  (March/06/2012), Simon Vidanovic
      74              : //   - feature: Additional state for isky introduced.  Tarcog now can accept IR radiance from external source.
      75              : //  Revision: 7.0.11  (January/04/2012), Simon Vidanovic
      76              : //   - improvements/bug fixes: Several items merged from Windows tarcog version into this one:
      77              : //      - bug fix: Correct formatting for VacuumMaxGapThickness when program writes input file
      78              : //      - improvement: Gamma coefficient is now written in scientific notation (needed for correct output file generation)
      79              : //      - improvement: Gap data are now saved with higher precision to wincog input file (test purposes, debug mode only)
      80              : //      - bug fix: Gap temperatures are recalculated within iterations (for thermally driven and forced ventilation)
      81              : //  Revision: 7.0.10  (December/15/2011), Simon Vidanovic
      82              : //   - improvement: Flag for performing SHGC calculations
      83              : //  Revision: 7.0.09  (November/15/2011), Simon Vidanovic
      84              : //   - improvement: Added error message tolerance (This is necessary to handle error messages in correct way)
      85              : //  Revision: 7.0.08  (November/15/2011), Simon Vidanovic
      86              : //   - bug fix: Fixed program crashing when warning message 1007 occurred (output could not fit in string)
      87              : //   - feature: relaxation parameter changed
      88              : //  Revision: 7.0.07  (November/08/2011), Simon Vidanovic
      89              : //   - feature: Error message (as string) is now return from tarcog
      90              : //  Revision: 7.0.06  (November/07/2011), Simon Vidanovic
      91              : //   - bug fix: Error report now actually use passed VacuumMaxGapThickness value
      92              : //  Revision: 7.0.05  (November/07/2011), Simon Vidanovic
      93              : //   - bug fix: Troom and Tamb are not passed out of hhat routine after recalculation is performed.
      94              : //              This will cause differences in calculation of U-factor
      95              : //   - feature: VacuumMaxGapThickness is added to list of input parameters
      96              : //  Revision: 7.0.04  (November/03/2011), Simon Vidanovic
      97              : //   - bug fix: one of debug files did not update properly
      98              : //  Revision: 7.0.03  (November/01/2011), Simon Vidanovic
      99              : //   - tarcog will now exit if error code is in range from 2000 to 3000
     100              : //   - tarcog now accepts file name which is template for debug output files creation
     101              : //   - temperature correction added in case temperatures on the layers are equal
     102              : //     which in case of energy calculation will give division with zero
     103              : //   - iteration results now can be saved in the file (just for debugging purposes)
     104              : //  Revision: 7.0.02  (October/10/2011), Simon Vidanovic
     105              : //   - Deflection calculations implemented.
     106              : //  Revision: 7.0.01  (September/23/2011), Simon Vidanovic
     107              : //   - Support pillars implemented.
     108              : //  Revision: 7.0.00  (August/23/2011), Simon Vidanovic
     109              : //   - Added comments to input arguments; Fixed bug in Nu calculation for angle between 60 and 90 degrees.
     110              : //  Revision: 6.0.36  (June/22/2010)
     111              : //   - Converted to F95; refactoring.
     112              : //  Revision: 6.0.35  (June/4/2010)
     113              : //   - Fixed a few potential bugs
     114              : //  Revision: 6.0.34  (May/26/2009)
     115              : //   - Updated creation of W6 debug file (added ClosedBlind flag)
     116              : //  Revision: 6.0.33  (March/03/2008)
     117              : //   - Fixed a bug in arguments checking.
     118              : //   - Added creation of WINCOG input file in debug mode.
     119              : //  Revision: 6.0.32  (February/29/2008)
     120              : //   - Applied CSM thermal model to Woven Shades layers.
     121              : //   - Introduced a new error message (#39)
     122              : //  Revision: 6.0.31  (February/15/2008)
     123              : //   - EN673 Design and Declared standards added/fixed (it used to be EN673 and ISO 10292).
     124              : //  Revision: 6.0.30  (May/05/2007)
     125              : //   - Scalar model (CSM) fixed.
     126              : //  Revision: 6.0.29  (September/14/2006)
     127              : //   - Fixed a bug in CSM calculation that affected some cases.
     128              : //  Revision: 6.0.28  (September/05/2006)
     129              : //   - Woven Shade layer type introduced. These layers will be treated
     130              : //    the same way as Venetian Blind layers.
     131              : //  Revision: 6.0.27  (August/24/2006)
     132              : //   - Implemented new thermal model (thermal model 2 - Convection Scalar Model)
     133              : //   - Added new input argument - SDScalar:
     134              : //      0.0  - No SD (in terms of convection)
     135              : //      1.0  - Closed SD (SD treated as a 'regular' specular layer)
     136              : //      between 0 and 1 - combination of No SD and Closed SD cases
     137              : //   - A bug in unshaded run (remapping gas properties in removal of indoor SD layer) was fixed
     138              : //   - TARCOG error codes have been updated (error codes 30 and 37 added)
     139              : //  Revision: 6.0.26  (May/31/2006)
     140              : //   - Hard-coded Xenon gas properties for EN673 were updated.
     141              : //   - hrin equation in EN673 routine was updated.
     142              : //  Revision: 6.0.25  (March/29/2006)
     143              : //   - Bug fixes in EN673/ISO10292 procedure:
     144              : //    .values of gas properties for EN673 and ISO10292 procedure can now be passed to TARCOG
     145              : //     via A coefficients in gvis, gcon and gcp matrices and wght array
     146              : //    .gas mixture buid-up limited to number of gasses used in the mix
     147              : //    .dT array is now updated correctly after each iteration
     148              : //    .hrin formula fixed
     149              : //   - Bug fix (checking of slat tilt angle - negative values are now allowed)
     150              : //  Revision: 6.0.24  (November/25/2005)
     151              : //   - Code responsible for ETR calculation (in U factor calculation)
     152              : //    has been redesigned and cleared of all bugs.
     153              : //  Revision: 6.0.23  (November/24/2005)
     154              : //   - Bug fix (wrong U factor results for IGUs with one glass + indoor SD)
     155              : //   - Bug fix (wrong results for Hc modification ratios)
     156              : //    when fixed H or fixed Hc model is used.
     157              : //   - Allowed DiffuseShade as layer type (does not affect calculation algorithm).
     158              : //   - hflux value has been updated - includes contribution from freely ventilated air
     159              : //    around indoor SD layer (this affects SHGC value)
     160              : //   - Debug file has been updated:
     161              : //      . qr is shown in each gap,
     162              : //      . hcgas values have been updated to include contribution from freely ventilated air
     163              : //        around SD layers (this affects output argument as well),
     164              : //      . hrgas values have been introduced in debug file.
     165              : //  Revision: 6.0.22  (November/04/2005)
     166              : //   - Added an internal "unshaded" calculation run for glazing systems with
     167              : //     outdoor and/or indoor SD layer(s). This run is needed for proper calculation
     168              : //     of Hc modification ratios.
     169              : //   - Added two new output arguments needed for connection with T6:
     170              : //      HcUnshadedOut,
     171              : //      HcUnshadeIn.
     172              : //   - Changed the way ShadeHcRatioOut and ShadeHcRatioIn are calculated.
     173              : //  Revision: 6.0.21  (October/28/2005)
     174              : //   - Fixed another serious bug in new routine for calculation of U factor.
     175              : //  Revision: 6.0.20  (October/20/2005)
     176              : //   - Fixed a bug in new calculation of U factor.
     177              : //   - Fixed a bug in formulas for calculation of SD thickness.
     178              : //   - Forced ventilation calc has been disabled (since v6.0.19)
     179              : //  Revision: 6.0.19  (October/19/2005)
     180              : //   - New input arguments added:
     181              : //      SlatThick, SlatWidth, SlatAngle, SlatCond, SlatSpacing, SlatCurve, ThermalMod.
     182              : //   - Argument gltype renamed to LayerType.
     183              : //   - Thermal_model_1 implemented
     184              : //   - U factor calculation has been updated.
     185              : //   - Description of arguments has been updated.
     186              : //   - Forced ventilation calc has been disabled.
     187              : //  Revision: 6.0.18  (September/16/2005)
     188              : //   - Changed Tvent for outdoor and indoor SD layers to Tout and Tin, respectively.
     189              : //   - Keff is now calculated for each gap.
     190              : //  Revision: 6.0.17  (September/08/2005)
     191              : //   - Fixed a bug involving Al, Ar & Ah values (patch for a case of Al+Ar+Ah = 0).
     192              : //  Revision: 6.0.16  (September/07/2005)
     193              : //   - Added new output arguments needed for connection with T6:
     194              : //      ShadeEmisRatioOut,
     195              : //      ShadeEmisRatioIn,
     196              : //      ShadeHcRatioOut,
     197              : //      ShadeHcRatioIn,
     198              : //      Keff,
     199              : //      ShadeGapKeffConv
     200              : //  Revision: 6.0.15  (August/30/2005)
     201              : //   - Removed CHDIR call; used filepath//filename instead.
     202              : //  Revision: 6.0.14  (August/26/2005)
     203              : //   - New arguments introduced:
     204              : //      Debug_dir  - character array: target directory for debug output
     205              : //      Window_ID  - integer: window ID (from W6)
     206              : //      IGU_ID  - integer: IGU ID (from W6)
     207              : //  Revision: 6.0.13  (August/19/2005)
     208              : //   - Bug fix #9 - allows calculations for Atop=Abot=0, by setting both values to 1e-6
     209              : //  Revision: 6.0.12  (August/12/2005)
     210              : //   - Minor change in Picard coefficients for vented gaps - MaxIter cannot
     211              : //     be less than 800. This solves issue with theta buffer in Therm1d.
     212              : //   - Implemented creation of TARCOG debug file w/ i/o arguments/results (Tarcog.dbg)
     213              : //     (feature #8); debug file will be created depending on Debug_mode switch:
     214              : //      Debug_mode = 0 : debug file will not be created
     215              : //      Debug_mode = 1 : debug file will be appended
     216              : //      Debug_mode = 2 : new debug file will be created
     217              : //   - Bug fix #7- qin result corrected in SHGC run.
     218              : //  Revision: 6.0.11  (July/15/2005)
     219              : //   - Bug fix #4: an issue in original formulas that causes Therm1d
     220              : //     to fail to converge for in certain cases. Changes were made in Therm1d
     221              : //     that allow regular calculation outcome in these cases.
     222              : //  Revision: 6.0.10  (June/3/2005)
     223              : //   - Bug fix #00005: added IGU Height in term A in ShadingIn and ShadingEdge
     224              : //     procedures. This term is used in calculations of free vent air velocity
     225              : //  Revision: 6.0.09  (May/16/2005)
     226              : //   - Bug fix #00001: for fixed combined coef. BC -> Trmout = Tout, Trmin = Tind
     227              : //  Revision: 6.0.08  (May/12/2005)
     228              : //   - Debug flag introduced in Tarcog, Therm1d and dtemp procedures:
     229              : //     debug info is stored in two files: tarcog.dbg and temps.out
     230              : //  Revision: 6.0.07  (April/12/2005)
     231              : //   - Fixed a bug (#00002) in calculation of
     232              : //     Picard method coefficients, in Therm1d procedure:
     233              : //     fixes SD ventilation velocity related calcs.
     234              : //  Revision: 6.0.06  (October/22/2004)
     235              : //   - Fixed a bug in velocity calculations
     236              : //  Revision: 6.0.05  (October/01/2004)
     237              : //   - Changed name from w5cog to TARCOG
     238              : //   - Changed version numbering
     239              : //---------------------------------------------
     240              : //  Revision: 5.3.105  (September/07/04)
     241              : //   - Changed argument 'standard' from string to integer
     242              : //  Revision: 5.3.02.03  (January/16/04)
     243              : //   - Slice temperatures calculated
     244              : //   - Write out Nusselt and Rayleigh (in debug mode)
     245              : //   - sol converted to asol in input format
     246              : //  Revision: 5.3.02.02  (11/14/03)
     247              : //   - Implemented CEN Standard
     248              : //  Revision: 5.3.02.01  (11/06/03)
     249              : //   - implemented Laminate procedure
     250              : //  Revision: 5.3.01  (09/22/03)
     251              : //   - fixed bug in Tgap initial calculation
     252              : //   - reduce dimension of Tgap
     253              : //  Revision: 5.3.00  (08/25/03)
     254              : //   - make code more readable and rename version
     255              : //  Revision: 6.0.07  (08/10/03)
     256              : //   - implemented arrays for ventilation temperature and speed
     257              : //   - repaired equation 121 in ISO (instead of cos(tilt) now is ABS(cos(tilt)))
     258              : //   - implemented input field for forced ventilation velocity (for all cases)
     259              : //   - fixed bug in shading edge: coefficients B1, C1 and D1 repaired to calculate value for gap temperature (not environment)
     260              : //   - fixed bug in routine shading edge: characteristic Height is calculated for gap (not for environment)
     261              : //   - fixed bug in processing error messages (this was produced slightly wrong in some cases results)
     262              : //  Revision: 6.0.06 rv  (04/22/03)
     263              : //   - write out heat flux calculation for shading device panes
     264              : //   - qv smoothing: make vented heat flux same in adjacent gaps (gaps are divided by shading pane)
     265              : //   - fixed bug in routine "shadingin": make that vented heat flow direction is calculated correct, according
     266              : //     to temperatures in adjacent gaps
     267              : //  Revision: 6.0.05  (04/14/03)
     268              : //   - implemented "Picard" method in iteration loop
     269              : //   - number of iterations is increased to 1000
     270              : //   - alpha coefficient is set to 0.01 (Picard method)
     271              : //  Revision: 6.0.04  (03/03/03)
     272              : //   - implemented forced ventilation for indoor and outdoor shading devices
     273              : //   - maximum number of iterations is increased to 100
     274              : //  Revision: 6.0.03 (02/25/03)
     275              : //   - fixed bug in error message for "nlayer<1"
     276              : //   - error messages update
     277              : //   - repaired U-value calculation and Tgap1, Tgap2 calculation for shading inside
     278              : //   - shading devices implemented
     279              : //   - error messages and warnings updated and tolerance is decreased to 1e-5
     280              : //   - write out heat fluxes
     281              : //   - fixed bug in hrin and hrout calculation
     282              : //   - fixed bug in nusselt number for gap calculation for angle > 90 degrees
     283              : //    and new error messages are added
     284              : // pr  Revision: 5.13 (01/16/02)
     285              : // pr
     286              : // pr   - pi value updated
     287              : // pr
     288              : //  Revision: 5.12 (10/27/01)
     289              : //   - deleted extra lines in hatter (just cleanup)
     290              : //  Revision: 5.11 (10/23/01)
     291              : //   - fixed bug in reporting SHGC
     292              : // pr  Revision: 5.10 (10/15/01) [Not included here - under testing]
     293              : // pr
     294              : // pr  - updated gas properties for Xenon (for EN673 standard)
     295              : // pr  Revision: 5.09 (10/12/01) [Not included here - under testing]
     296              : // pr
     297              : // pr  - implemented EN673 standard
     298              : //  Revision: 5.08 (10/11/01)
     299              : //   - corrected reporting for solar conditions
     300              : //   - corrected array declaration for nmix in filmg
     301              : //  Revision: 5.07 (9/21/01) [not included here - under testing]
     302              : //   - implemented Laminate procedure
     303              : // pr  Revision: 5.06(09/18/00) [not included here - under testing]
     304              : // pr
     305              : // pr  - implemented CEN algorithms
     306              : // Revised: June, 2001
     307              : //   - further implementation of ISO 15099
     308              : //     * new def. of shgc
     309              : //     * revised gas constants
     310              : //     * implemented mean radiant temperature on indoor side
     311              : //     *
     312              : //   - cleaned bugs
     313              : //     * fixed film coefficient didn't work correctly
     314              : //   - removed condensation calculations (part of main w5 code now)
     315              : //   - implemented environmental temperatures
     316              : // Revised: January, 2001
     317              : //   - revised input format
     318              : //   - streamlined code
     319              : //   - implemented dll's
     320              : // Revised: July 2000 (Major revision of the new code)
     321              : //   - checked for accuracy, cleaned bunch of bugs
     322              : //   - implemented gas mixtures
     323              : // Initial update of the old "therm" (WINDOW 4.1) code: Around 1998/99
     324              : 
     325              : // PURPOSE OF THIS MODULE:
     326              : //   Module For Calculation of Thermal Performance Indices For Center
     327              : //     of Glass According to ISO 15099/ASHRAE SPC142, ISO10292, and EN673
     328              : 
     329              : // METHODOLOGY EMPLOYED:
     330              : //  Standard ISO 15099/ASHRAE SPC142, ISO10292 and EN673
     331              : 
     332              : // REFERENCES:
     333              : // ISO 15099/ASHRAE SPC142, ISO10292, EN673, Tarcog technical documentation
     334              : 
     335              : // Using/Aliasing
     336              : using namespace TARCOGOutput;
     337              : using namespace TARCOGGassesParams;
     338              : using namespace TARCOGParams;
     339              : using namespace TARCOGArgs;
     340              : using namespace ThermalISO15099Calc;
     341              : using namespace ThermalEN673Calc;
     342              : using namespace TARCOGDeflection;
     343              : 
     344              : // Functions
     345              : 
     346            0 : void TARCOG90(EnergyPlusData &state,
     347              :               int const nlayer,                           // Number of layers (glass + SD)
     348              :               int const iwd,                              // Wind direction:
     349              :               Real64 &tout,                               // Outdoor temperature [K]
     350              :               Real64 &tind,                               // Indoor temperature [K]
     351              :               Real64 &trmin,                              // Indoor mean radiant temperature [K]
     352              :               Real64 const wso,                           // Outdoor wind speed [m/s]
     353              :               Real64 const wsi,                           // Inside forced air speed [m/s]
     354              :               Real64 const dir,                           // Direct solar radiation [W/m2]
     355              :               Real64 const outir,                         // IR radiance of window's exterior surround [W/m2]
     356              :               int const isky,                             // Flag for sky temperature(Tsky) and sky emittance(esky)
     357              :               Real64 const tsky,                          // Night sky temperature [K]
     358              :               Real64 &esky,                               // Effective night sky emittance
     359              :               Real64 const fclr,                          // Fraction of sky that is clear
     360              :               Real64 const VacuumPressure,                // maximal pressure for gas to be considered as vacuum
     361              :               Real64 &VacuumMaxGapThickness,              // maximum allowed thickness without producing warning message
     362              :               DeflectionCalculation const CalcDeflection, // Deflection calculation flag:
     363              :               Real64 const Pa,                            // Atmospheric (outside/inside) pressure (used only if CalcDeflection = 1)
     364              :               Real64 const Pini,                          // Initial pressure at time of fabrication (used only if CalcDeflection = 1)
     365              :               Real64 const Tini,                          // Initial temperature at time of fabrication (used only if CalcDeflection = 1)
     366              :               Array1D<Real64> &gap,                       // Vector of gap widths [m]
     367              :               Array1D<Real64> &GapDefMax,                 // Vector of gap widths in deflected state. It will be used as input
     368              :               Array1D<Real64> &thick,                     // Vector of glazing layer thicknesses [m]
     369              :               Array1D<Real64> &scon,                      // Vector of conductivities of each glazing layer  [W/mK]
     370              :               const Array1D<Real64> &YoungsMod,           // Youngs Modulus coefficients used in deflection calculations
     371              :               const Array1D<Real64> &PoissonsRat,         // Poissons Ratio coefficients used in deflection calculations
     372              :               const Array1D<Real64> &tir,                 // Vector of IR transmittances of each surface
     373              :               const Array1D<Real64> &emis,                // Vector of IR emittances of each surface
     374              :               Real64 const totsol,                        // Total solar transmittance of the IGU
     375              :               Real64 const tilt,                          // Window tilt [degrees]
     376              :               const Array1D<Real64> &asol,                // Vector of Absorbed solar energy fractions for each layer
     377              :               Real64 const height,                        // IGU cavity height
     378              :               Real64 const heightt,                       // Window height
     379              :               Real64 const width,                         // Window width
     380              :               const Array1D<Real64> &presure,             // Vector of gas pressures in gaps [N/m2]
     381              :               Array2A_int const iprop,                    // Matrix of gas codes - see mgas definition
     382              :               Array2A<Real64> const frct,                 // Matrix of mass percentages in gap mixtures
     383              :               Array2A<Real64> const xgcon,                // Matrix of constants for gas conductivity calc
     384              :               Array2A<Real64> const xgvis,                // Matrix of constants for gas dynamic viscosity calc
     385              :               Array2A<Real64> const xgcp,                 // Matrix of constants for gas specific heat calc at constant pressure
     386              :               const Array1D<Real64> &xwght,               // Vector of Molecular weights for gasses
     387              :               const Array1D<Real64> &gama,                // Vector of specific heat ration for low pressure calc
     388              :               const Array1D_int &nmix,                    // Vector of number of gasses in gas mixture of each gap
     389              :               const Array1D_int &SupportPillar,           // Shows whether or not gap have support pillar
     390              :               const Array1D<Real64> &PillarSpacing,       // Pillar spacing for each gap (used in case there is support pillar)
     391              :               const Array1D<Real64> &PillarRadius,        // Pillar radius for each gap (used in case there is support pillar)
     392              :               Array1D<Real64> &theta,                     // Vector of average temperatures of glazing surfaces [K]
     393              :               Array1D<Real64> &LayerDef,                  // Vector of layers deflection. [m]
     394              :               Array1D<Real64> &q,                         // Vector of various heat fluxes [W/m2]
     395              :               Array1D<Real64> &qv,                        // Vector of heat fluxes to each gap by ventilation [W/m2]
     396              :               Real64 &ufactor,                            // Center of glass U-value [W/m2 K]
     397              :               Real64 &sc,                                 // Shading Coefficient
     398              :               Real64 &hflux,                              // Net heat flux between room and window [W/m2]
     399              :               Real64 &hcin,                               // Indoor convective surface heat transfer coefficient  [W/m2 K]
     400              :               Real64 &hcout,                              // Outdoor convective surface heat transfer coefficient [W/m2 K]
     401              :               Real64 &hrin,                               // Indoor radiative surface heat transfer coefficient [W/m2 K]
     402              :               Real64 &hrout,                              // Outdoor radiative surface heat transfer coefficient [W/m2 K]
     403              :               Real64 &hin,                                // Indoor combined film coefficient (if non-zero) [W/m2K]
     404              :               Real64 &hout,                               // Outdoor combined film coefficient (if non-zero) [W/m2K]
     405              :               Array1D<Real64> &hcgas,                     // Convective part of gap effective conductivity (including in and out)
     406              :               Array1D<Real64> &hrgas,                     // Radiative part of gap effective conductivity (including in and out)
     407              :               Real64 &shgc,                               // Solar heat gain coefficient - per ISO 15099
     408              :               int &nperr,                                 // Error code
     409              :               std::string &ErrorMessage,                  // To store error message from tarcog execution
     410              :               Real64 &shgct,                              // Solar heat gain coefficient - per old procedure
     411              :               Real64 &tamb,                               // Outdoor environmental temperature [K]
     412              :               Real64 &troom,                              // Indoor environmental temperature [K]
     413              :               const Array1D_int &ibc,                     // Vector of boundary condition flags (ibc(1) - outdoor, ibc(2) - indoor
     414              :               const Array1D<Real64> &Atop,                // Vector with areas of top openings - between SD layers and top of
     415              :               const Array1D<Real64> &Abot,                // Vector with areas of bottom openings - between SD layers and
     416              :               const Array1D<Real64> &Al,                  // Vector with areas of left-hand side openings - between SD layers and
     417              :               const Array1D<Real64> &Ar,                  // Vector of areas of right-hand side openings - between SD layers and
     418              :               const Array1D<Real64> &Ah,                  // Vector of total areas of holes for each SD [m2]
     419              :               const Array1D<Real64> &SlatThick,           // Thickness of the slat material [m]
     420              :               const Array1D<Real64> &SlatWidth,           // Slat width [m]
     421              :               const Array1D<Real64> &SlatAngle,           // Slat tilt angle [deg]
     422              :               const Array1D<Real64> &SlatCond,            // Conductivity of the slat material [W/m.K]
     423              :               const Array1D<Real64> &SlatSpacing,         // Distance between slats [m]
     424              :               const Array1D<Real64> &SlatCurve,           // Curvature radius of the slat [m]
     425              :               const Array1D<Real64> &vvent,               // Vector of velocities for forced ventilation, for each gap, and for
     426              :               const Array1D<Real64> &tvent,               // Vector of temperatures of ventilation gas for forced ventilation,
     427              :               const Array1D<TARCOGLayerType> &LayerType,  // Glazing layer type flag
     428              :               const Array1D_int &nslice,                  // Vector of numbers of slices in a laminated glazing layers
     429              :               const Array1D<Real64> &LaminateA,           // Left-hand side array for creating slice equations
     430              :               const Array1D<Real64> &LaminateB,           // Right-hand side array for creating slice equations
     431              :               const Array1D<Real64> &sumsol,              // Array of absorbed solar energy fractions for each laminated
     432              :               Array1D<Real64> &hg,                        // Gas conductance of the glazing cavity [W/m2 K]
     433              :               Array1D<Real64> &hr,                        // Radiation conductance of the glazing cavity [W/m2 K]
     434              :               Array1D<Real64> &hs,                        // Thermal conductance of the glazing cavity [W/m2 K]
     435              :               Real64 &he,                                 // External heat transfer coefficient [W/m2 K] - EN673 and ISO 10292 procedure
     436              :               Real64 &hi,                                 // Internal heat transfer coefficient [W/m2 K] - EN673 and ISO 10292 procedure
     437              :               Array1D<Real64> &Ra,                        // Vector of Rayleigh numbers, for each gap
     438              :               Array1D<Real64> &Nu,                        // Vector of Nusselt numbers, for each gap
     439              :               TARCOGGassesParams::Stdrd const standard,   // Calculation standard switch:
     440              :               TARCOGThermalModel const ThermalMod,        // Thermal model:
     441              :               int const Debug_mode,                       // Switch for debug output files:
     442              :               std::string const &Debug_dir,               // Target directory for debug files
     443              :               std::string const &Debug_file,              // File name template for debug files
     444              :               int const win_ID,                           // ID of window (passed by W6)
     445              :               int const igu_ID,                           // ID of the IGU (passed by W6)
     446              :               Real64 &ShadeEmisRatioOut,                  // Ratio of modified to glass emissivity at the outermost glazing surface
     447              :               Real64 &ShadeEmisRatioIn,                   // Ratio of modified to glass emissivity at the innermost glazing surface
     448              :               Real64 &ShadeHcRatioOut,                    // Ratio of modified to unshaded Hc at the outermost glazing surface
     449              :               Real64 &ShadeHcRatioIn,                     // Ratio of modified to unshaded Hc at the innermost glazing surface
     450              :               Real64 &HcUnshadedOut,                      // Hc value at outermost glazing surface of an unshaded subsystem [W/m2 K]
     451              :               Real64 &HcUnshadedIn,                       // Hc value at innermost glazing surface of an unshaded subsystem [W/m2 K]
     452              :               Array1D<Real64> &Keff,                      // Vector of keff values for gaps [W/m.K]
     453              :               Array1D<Real64> &ShadeGapKeffConv,          // Vector of convective keff values for areas above/below
     454              :               Real64 const SDScalar,                      // Factor of Venetian SD layer contribution to convection
     455              :               int const SHGCCalc,                         // SHGC calculation switch:
     456              :               int &NumOfIterations,                       // Number of iterations for reaching solution
     457              :               Real64 const edgeGlCorrFac                  // Edge of glass correction factor
     458              : )
     459              : {
     460              : 
     461              :     /// function attributes:
     462              : 
     463              :     /// INPUTS:
     464              : 
     465              :     /// General:
     466              : 
     467              :     // Argument array dimensioning
     468            0 :     EP_SIZE_CHECK(gap, maxlay);
     469            0 :     EP_SIZE_CHECK(GapDefMax, MaxGap);
     470            0 :     EP_SIZE_CHECK(thick, maxlay);
     471            0 :     EP_SIZE_CHECK(scon, maxlay);
     472            0 :     EP_SIZE_CHECK(YoungsMod, maxlay);
     473            0 :     EP_SIZE_CHECK(PoissonsRat, maxlay);
     474            0 :     EP_SIZE_CHECK(tir, maxlay2);
     475            0 :     EP_SIZE_CHECK(emis, maxlay2);
     476            0 :     EP_SIZE_CHECK(asol, maxlay);
     477            0 :     EP_SIZE_CHECK(presure, maxlay1);
     478            0 :     iprop.dim(maxgas, maxlay1);
     479            0 :     frct.dim(maxgas, maxlay1);
     480            0 :     xgcon.dim(3, maxgas);
     481            0 :     xgvis.dim(3, maxgas);
     482            0 :     xgcp.dim(3, maxgas);
     483            0 :     EP_SIZE_CHECK(xwght, maxgas);
     484            0 :     EP_SIZE_CHECK(gama, maxgas);
     485            0 :     EP_SIZE_CHECK(nmix, maxlay1);
     486            0 :     EP_SIZE_CHECK(SupportPillar, maxlay);
     487            0 :     EP_SIZE_CHECK(PillarSpacing, maxlay);
     488            0 :     EP_SIZE_CHECK(PillarRadius, maxlay);
     489            0 :     EP_SIZE_CHECK(theta, maxlay2);
     490            0 :     EP_SIZE_CHECK(LayerDef, maxlay);
     491            0 :     EP_SIZE_CHECK(q, maxlay3);
     492            0 :     EP_SIZE_CHECK(qv, maxlay1);
     493            0 :     EP_SIZE_CHECK(hcgas, maxlay1);
     494            0 :     EP_SIZE_CHECK(hrgas, maxlay1);
     495            0 :     EP_SIZE_CHECK(ibc, 2);
     496            0 :     EP_SIZE_CHECK(Atop, maxlay);
     497            0 :     EP_SIZE_CHECK(Abot, maxlay);
     498            0 :     EP_SIZE_CHECK(Al, maxlay);
     499            0 :     EP_SIZE_CHECK(Ar, maxlay);
     500            0 :     EP_SIZE_CHECK(Ah, maxlay);
     501            0 :     EP_SIZE_CHECK(SlatThick, maxlay);
     502            0 :     EP_SIZE_CHECK(SlatWidth, maxlay);
     503            0 :     EP_SIZE_CHECK(SlatAngle, maxlay);
     504            0 :     EP_SIZE_CHECK(SlatCond, maxlay);
     505            0 :     EP_SIZE_CHECK(SlatSpacing, maxlay);
     506            0 :     EP_SIZE_CHECK(SlatCurve, maxlay);
     507            0 :     EP_SIZE_CHECK(vvent, maxlay1);
     508            0 :     EP_SIZE_CHECK(tvent, maxlay1);
     509            0 :     EP_SIZE_CHECK(LayerType, maxlay);
     510            0 :     EP_SIZE_CHECK(nslice, maxlay);
     511            0 :     EP_SIZE_CHECK(LaminateA, maxlay);
     512            0 :     EP_SIZE_CHECK(LaminateB, maxlay);
     513            0 :     EP_SIZE_CHECK(sumsol, maxlay);
     514            0 :     EP_SIZE_CHECK(hg, maxlay);
     515            0 :     EP_SIZE_CHECK(hr, maxlay);
     516            0 :     EP_SIZE_CHECK(hs, maxlay);
     517            0 :     EP_SIZE_CHECK(Ra, maxlay);
     518            0 :     EP_SIZE_CHECK(Nu, maxlay);
     519            0 :     EP_SIZE_CHECK(Keff, maxlay);
     520            0 :     EP_SIZE_CHECK(ShadeGapKeffConv, MaxGap);
     521              : 
     522              :     // Locals
     523              :     //    1 - ISO15099
     524              :     //    2 - ISO10292
     525              :     //    3 - EN673
     526              :     //    0 - ISO15099
     527              :     //    1 - Thermal model 1
     528              :     //    2 - Thermal model 2 (not implemented)
     529              :     //    0 - don't create debug output files
     530              :     //    1 - append results to existing debug output file
     531              :     //    2 - store results in new debug output file
     532              :     //   3 - save in-between results (in all iterations) to existing debug file
     533              :     //    0 - do not perform SHGC calculations
     534              :     //    1 - perform SHGC calculations
     535              : 
     536              :     /// Environment related:
     537              :     //    0 - windward
     538              :     //    1 - leeward
     539              :     //    0 - both Tsky and Esky are specified
     540              :     //    1 - Tsky specified; esky = 1
     541              :     //    2 - Swinbank model for effective sky emittance
     542              :     //    3 - IR radiance is provided from external source
     543              :     // integer, intent(in) :: mgas  ! Flag for gas property constants:
     544              :     //    0 - gas constants supplied (through gcon, gvis and gcp arrays)
     545              :     //    1 - use internal constants; when internal then first index
     546              :     //        in gcon, gciv and gcp is:
     547              :     //          1 - Air
     548              :     //          2 - Argon
     549              :     //          3 - Krypton
     550              :     //          4 - Xenon
     551              :     //    0 - h to be calculated
     552              :     //    1 - combined film coefficient h prescribed
     553              :     //    2 - convective film coefficient (hc) prescribed
     554              :     // Also used in old algorithms for calculating h, accessible through negative
     555              :     // values for flags:
     556              :     //    -1 - old SPC142 correlation
     557              :     //    -2 - Klems-Yazdanian correlation (applicable to outdoor only)
     558              :     //    -3 - Kimura correlation (applicable to outdoor only)
     559              : 
     560              :     /// Layers:
     561              :     //    0 - Specular layer
     562              :     //    1 - Venetian blind (SD)
     563              :     //    2 - Woven shade (SD) (not implemented)
     564              :     //    3 - Diffuse shade
     565              : 
     566              :     /// Venetians:
     567              :     // glazing cavity [m2]
     568              :     // bottom of glazing cavity [m2]
     569              :     // left end of glazing cavity [m2]
     570              :     // right end of glazing cavity [m2]
     571              :     // outdoor and indoor environment [m/s]
     572              :     // for each gap, and for outdoor and indoor environment
     573              : 
     574              :     /// Laminates:
     575              :     // (0 - monolithic layer)
     576              :     // glazing layer [W/m2]
     577              : 
     578              :     /// Gaps:
     579              :     //  (A, B, C for max of 10 gasses)
     580              :     //  (A, B, C for max of 10 gasses)
     581              :     //  (A, B, C for max of 10 gasses)
     582              : 
     583              :     //   0 - does not have support pillar
     584              :     //   1 - have support pillar
     585              : 
     586              :     // (used in conjunction with Thermal Model 2; otherwise, this value is ignored by TARCOG)
     587              :     // - REAL(r64) value between 0 (SD contribution to convection is neglected) and
     588              :     //  1 (SD treated as "closed" - as if it is a glass layer with thermal
     589              :     //  properties of SD slat material)
     590              : 
     591              :     // Deflection
     592              :     //    0 - no deflection calculations
     593              :     //    1 - perform deflection calculation (input is Pressure/Temp)
     594              :     //    2 - perform deflection calculation (input is measured deflection)
     595              :     // if CalcDeflection = 2. In case CalcDeflection = 1 it will return
     596              :     // recalculated gap widths. [m]
     597              : 
     598              :     //// INPUTS/OUTPUTS:
     599              : 
     600              :     /// OUTPUTS:
     601              :     /// Overall:
     602              : 
     603              :     /// Layers:
     604              :     // depending on element index:
     605              :     //    1 - qout (heat flux from outer-most glazing surface to outdoor space)
     606              :     //    2*i = qpane(i) (heat flux through i-th glazing layer
     607              :     //    2*i-1 = qgap(i) (heat flux from i-th glazing cavity to indoor-faced
     608              :     //                      surface of the adjacent glazing layer)
     609              :     //    2*nlayer + 1 = qin (heat flux from indoor space to inner-most glazing
     610              :     //                        surface)
     611              : 
     612              :     /// Gaps:
     613              :     //      - EN673 and ISO 10292 procedure
     614              :     //      - EN673 and ISO 10292 procedure
     615              :     //      - EN673 and ISO 10292 procedure
     616              : 
     617              :     /// Shading related:
     618              :     //  SD layers [W/m.K]
     619              : 
     620              :     // temporary variables stored between deflection iterations because tarcog need to produce result with exact same
     621              :     // input variables
     622              :     Real64 eskyTemp;
     623              :     Real64 trminTemp;
     624              :     Real64 hinTemp;
     625              :     Real64 houtTemp;
     626              : 
     627              :     // REAL(r64), dimension(maxlay) ::  sol ! Vector of Absorbed solar energy for each layer [W/m2] = dir*asol
     628              : 
     629              :     Real64 dtmax;
     630              :     int i;
     631              :     int counter;
     632              : 
     633              :     //!! Body of TARCOG90
     634              : 
     635            0 :     he = 0.0;
     636            0 :     hi = 0.0;
     637            0 :     hcin = 0.0;
     638            0 :     hrin = 0.0;
     639            0 :     hcout = 0.0;
     640            0 :     hrout = 0.0;
     641            0 :     LayerDef = 0.0;
     642            0 :     dtmax = 0.0;
     643            0 :     i = 0;
     644            0 :     counter = 0;
     645            0 :     eskyTemp = 0.0;
     646            0 :     trminTemp = 0.0;
     647            0 :     hinTemp = 0.0;
     648            0 :     houtTemp = 0.0;
     649            0 :     ErrorMessage = "Normal Termination";
     650              : 
     651            0 :     for (i = 1; i <= nlayer - 1; ++i) {
     652            0 :         state.dataTARCOGMain->CurGap(i) = gap(i);
     653              :     }
     654              : 
     655            0 :     Files files;
     656              : 
     657              :     //  Prepare common debug variables:
     658            0 :     PrepDebugFilesAndVariables(state, files, Debug_dir, Debug_file, Debug_mode, win_ID, igu_ID);
     659              : 
     660              :     // Check input arguments:
     661            0 :     nperr = ArgCheck(state,
     662              :                      files,
     663              :                      nlayer,
     664              :                      iwd,
     665              :                      tout,
     666              :                      tind,
     667              :                      trmin,
     668              :                      wso,
     669              :                      wsi,
     670              :                      dir,
     671              :                      outir,
     672              :                      isky,
     673              :                      tsky,
     674              :                      esky,
     675              :                      fclr,
     676              :                      VacuumPressure,
     677              :                      VacuumMaxGapThickness,
     678              :                      CalcDeflection,
     679              :                      Pa,
     680              :                      Pini,
     681              :                      Tini,
     682              :                      gap,
     683              :                      GapDefMax,
     684              :                      thick,
     685              :                      scon,
     686              :                      YoungsMod,
     687              :                      PoissonsRat,
     688              :                      tir,
     689              :                      emis,
     690              :                      totsol,
     691              :                      tilt,
     692              :                      asol,
     693              :                      height,
     694              :                      heightt,
     695              :                      width,
     696              :                      presure,
     697              :                      iprop,
     698              :                      frct,
     699              :                      xgcon,
     700              :                      xgvis,
     701              :                      xgcp,
     702              :                      xwght,
     703              :                      gama,
     704              :                      nmix,
     705              :                      SupportPillar,
     706              :                      PillarSpacing,
     707              :                      PillarRadius,
     708              :                      hin,
     709              :                      hout,
     710              :                      ibc,
     711              :                      Atop,
     712              :                      Abot,
     713              :                      Al,
     714              :                      Ar,
     715              :                      Ah,
     716              :                      SlatThick,
     717              :                      SlatWidth,
     718              :                      SlatAngle,
     719              :                      SlatCond,
     720              :                      SlatSpacing,
     721              :                      SlatCurve,
     722              :                      vvent,
     723              :                      tvent,
     724              :                      LayerType,
     725              :                      nslice,
     726              :                      LaminateA,
     727              :                      LaminateB,
     728              :                      sumsol,
     729              :                      standard,
     730              :                      ThermalMod,
     731              :                      SDScalar,
     732              :                      ErrorMessage);
     733              : 
     734              :     // in case of provided deflected gap widths just store deflected widths before temperatures calculation
     735              :     // deflections in this case do not depend of temperatures and it should be calculated before to avoid
     736              :     // one extra call of temperatures calculations
     737            0 :     if (CalcDeflection == DeflectionCalculation::GAP_WIDTHS) {
     738            0 :         PanesDeflection(CalcDeflection,
     739              :                         width,
     740              :                         height,
     741              :                         nlayer,
     742              :                         Pa,
     743              :                         Pini,
     744              :                         Tini,
     745              :                         thick,
     746              :                         gap,
     747              :                         GapDefMax,
     748            0 :                         state.dataTARCOGMain->GapDefMean,
     749              :                         theta,
     750              :                         YoungsMod,
     751              :                         PoissonsRat,
     752              :                         LayerDef,
     753              :                         nperr,
     754              :                         ErrorMessage);
     755            0 :         for (i = 1; i <= nlayer - 1; ++i) {
     756            0 :             state.dataTARCOGMain->CurGap(i) = state.dataTARCOGMain->GapDefMean(i);
     757              :         } // do i = 1, nlayer - 1
     758              :     }
     759              : 
     760              :     // in case of deflection calculation for temperature & pressure input some variables needs to be stored because
     761              :     // Calc_ISO15099 and EN673 routines will change them and for deflection recalculation everything needs to be
     762              :     // called in same way except for changed gap widths
     763            0 :     if (CalcDeflection == DeflectionCalculation::TEMPERATURE) {
     764            0 :         eskyTemp = esky;
     765            0 :         trminTemp = trmin;
     766            0 :         hinTemp = hin;
     767            0 :         houtTemp = hout;
     768            0 :         state.dataTARCOGMain->sconTemp = scon;
     769            0 :         state.dataTARCOGMain->thickTemp = thick;
     770              :     }
     771              : 
     772            0 :     if (GoAhead(nperr)) {
     773              : 
     774            0 :         if (standard == TARCOGGassesParams::Stdrd::ISO15099) {
     775            0 :             Calc_ISO15099(state,
     776              :                           files,
     777              :                           nlayer,
     778              :                           iwd,
     779              :                           tout,
     780              :                           tind,
     781              :                           trmin,
     782              :                           wso,
     783              :                           wsi,
     784              :                           dir,
     785              :                           outir,
     786              :                           isky,
     787              :                           tsky,
     788              :                           esky,
     789              :                           fclr,
     790              :                           VacuumPressure,
     791              :                           VacuumMaxGapThickness,
     792            0 :                           state.dataTARCOGMain->CurGap,
     793              :                           thick,
     794              :                           scon,
     795              :                           tir,
     796              :                           emis,
     797              :                           totsol,
     798              :                           tilt,
     799              :                           asol,
     800              :                           height,
     801              :                           heightt,
     802              :                           width,
     803              :                           presure,
     804              :                           iprop,
     805              :                           frct,
     806              :                           xgcon,
     807              :                           xgvis,
     808              :                           xgcp,
     809              :                           xwght,
     810              :                           gama,
     811              :                           nmix,
     812              :                           SupportPillar,
     813              :                           PillarSpacing,
     814              :                           PillarRadius,
     815              :                           theta,
     816              :                           q,
     817              :                           qv,
     818              :                           ufactor,
     819              :                           sc,
     820              :                           hflux,
     821              :                           hcin,
     822              :                           hcout,
     823              :                           hrin,
     824              :                           hrout,
     825              :                           hin,
     826              :                           hout,
     827              :                           hcgas,
     828              :                           hrgas,
     829              :                           shgc,
     830              :                           nperr,
     831              :                           ErrorMessage,
     832              :                           shgct,
     833              :                           tamb,
     834              :                           troom,
     835              :                           ibc,
     836              :                           Atop,
     837              :                           Abot,
     838              :                           Al,
     839              :                           Ar,
     840              :                           Ah,
     841              :                           SlatThick,
     842              :                           SlatWidth,
     843              :                           SlatAngle,
     844              :                           SlatCond,
     845              :                           SlatSpacing,
     846              :                           SlatCurve,
     847              :                           vvent,
     848              :                           tvent,
     849              :                           LayerType,
     850              :                           nslice,
     851              :                           LaminateA,
     852              :                           LaminateB,
     853              :                           sumsol,
     854              :                           Ra,
     855              :                           Nu,
     856              :                           ThermalMod,
     857              :                           Debug_mode,
     858              :                           ShadeEmisRatioOut,
     859              :                           ShadeEmisRatioIn,
     860              :                           ShadeHcRatioOut,
     861              :                           ShadeHcRatioIn,
     862              :                           HcUnshadedOut,
     863              :                           HcUnshadedIn,
     864              :                           Keff,
     865              :                           ShadeGapKeffConv,
     866              :                           SDScalar,
     867              :                           SHGCCalc,
     868              :                           NumOfIterations,
     869              :                           edgeGlCorrFac);
     870            0 :         } else if ((standard == TARCOGGassesParams::Stdrd::EN673) || (standard == TARCOGGassesParams::Stdrd::EN673Design)) {
     871            0 :             Calc_EN673(state,
     872              :                        files,
     873              :                        standard,
     874              :                        nlayer,
     875              :                        tout,
     876              :                        tind,
     877            0 :                        state.dataTARCOGMain->CurGap,
     878              :                        thick,
     879              :                        scon,
     880              :                        emis,
     881              :                        totsol,
     882              :                        tilt,
     883              :                        dir,
     884              :                        asol,
     885              :                        presure,
     886              :                        iprop,
     887              :                        frct,
     888              :                        nmix,
     889              :                        xgcon,
     890              :                        xgvis,
     891              :                        xgcp,
     892              :                        xwght,
     893              :                        theta,
     894              :                        ufactor,
     895              :                        hcin,
     896              :                        hin,
     897              :                        hout,
     898              :                        shgc,
     899              :                        nperr,
     900              :                        ErrorMessage,
     901              :                        ibc,
     902              :                        hg,
     903              :                        hr,
     904              :                        hs,
     905              :                        Ra,
     906              :                        Nu);
     907              :         } else {
     908              :         }
     909              :     }
     910              : 
     911              :     // Deflection calculations in case of temperature & pressure inputs
     912            0 :     if (GoAhead(nperr)) {
     913            0 :         if (!(GoAhead(nperr))) {
     914            0 :             return;
     915              :         }
     916              : 
     917            0 :         if (CalcDeflection == DeflectionCalculation::TEMPERATURE) {
     918            0 :             state.dataTARCOGMain->converged = false;
     919            0 :             while (!(state.dataTARCOGMain->converged)) {
     920            0 :                 PanesDeflection(CalcDeflection,
     921              :                                 width,
     922              :                                 height,
     923              :                                 nlayer,
     924              :                                 Pa,
     925              :                                 Pini,
     926              :                                 Tini,
     927              :                                 thick,
     928              :                                 gap,
     929              :                                 GapDefMax,
     930            0 :                                 state.dataTARCOGMain->GapDefMean,
     931              :                                 theta,
     932              :                                 YoungsMod,
     933              :                                 PoissonsRat,
     934              :                                 LayerDef,
     935              :                                 nperr,
     936              :                                 ErrorMessage);
     937              : 
     938            0 :                 if (!(GoAhead(nperr))) {
     939            0 :                     return;
     940              :                 }
     941              : 
     942              :                 // store temperatures before new calculations are performed. This is necessary in order to determine
     943            0 :                 for (i = 1; i <= 2 * nlayer; ++i) {
     944            0 :                     state.dataTARCOGMain->told(i) = theta(i);
     945              :                 } // do i=1, 2*nlayer
     946              : 
     947              :                 // before calling thermal calculations, return back old variables
     948            0 :                 esky = eskyTemp;
     949            0 :                 trmin = trminTemp;
     950            0 :                 hin = hinTemp;
     951            0 :                 hout = houtTemp;
     952            0 :                 scon = state.dataTARCOGMain->sconTemp;
     953            0 :                 thick = state.dataTARCOGMain->thickTemp;
     954              : 
     955              :                 // after performed deflection recalculate temperatures with new gap widths
     956            0 :                 if (standard == TARCOGGassesParams::Stdrd::ISO15099) {
     957            0 :                     Calc_ISO15099(state,
     958              :                                   files,
     959              :                                   nlayer,
     960              :                                   iwd,
     961              :                                   tout,
     962              :                                   tind,
     963              :                                   trmin,
     964              :                                   wso,
     965              :                                   wsi,
     966              :                                   dir,
     967              :                                   outir,
     968              :                                   isky,
     969              :                                   tsky,
     970              :                                   esky,
     971              :                                   fclr,
     972              :                                   VacuumPressure,
     973              :                                   VacuumMaxGapThickness,
     974            0 :                                   state.dataTARCOGMain->GapDefMean,
     975              :                                   thick,
     976              :                                   scon,
     977              :                                   tir,
     978              :                                   emis,
     979              :                                   totsol,
     980              :                                   tilt,
     981              :                                   asol,
     982              :                                   height,
     983              :                                   heightt,
     984              :                                   width,
     985              :                                   presure,
     986              :                                   iprop,
     987              :                                   frct,
     988              :                                   xgcon,
     989              :                                   xgvis,
     990              :                                   xgcp,
     991              :                                   xwght,
     992              :                                   gama,
     993              :                                   nmix,
     994              :                                   SupportPillar,
     995              :                                   PillarSpacing,
     996              :                                   PillarRadius,
     997              :                                   theta,
     998              :                                   q,
     999              :                                   qv,
    1000              :                                   ufactor,
    1001              :                                   sc,
    1002              :                                   hflux,
    1003              :                                   hcin,
    1004              :                                   hcout,
    1005              :                                   hrin,
    1006              :                                   hrout,
    1007              :                                   hin,
    1008              :                                   hout,
    1009              :                                   hcgas,
    1010              :                                   hrgas,
    1011              :                                   shgc,
    1012              :                                   nperr,
    1013              :                                   ErrorMessage,
    1014              :                                   shgct,
    1015              :                                   tamb,
    1016              :                                   troom,
    1017              :                                   ibc,
    1018              :                                   Atop,
    1019              :                                   Abot,
    1020              :                                   Al,
    1021              :                                   Ar,
    1022              :                                   Ah,
    1023              :                                   SlatThick,
    1024              :                                   SlatWidth,
    1025              :                                   SlatAngle,
    1026              :                                   SlatCond,
    1027              :                                   SlatSpacing,
    1028              :                                   SlatCurve,
    1029              :                                   vvent,
    1030              :                                   tvent,
    1031              :                                   LayerType,
    1032              :                                   nslice,
    1033              :                                   LaminateA,
    1034              :                                   LaminateB,
    1035              :                                   sumsol,
    1036              :                                   Ra,
    1037              :                                   Nu,
    1038              :                                   ThermalMod,
    1039              :                                   Debug_mode,
    1040              :                                   ShadeEmisRatioOut,
    1041              :                                   ShadeEmisRatioIn,
    1042              :                                   ShadeHcRatioOut,
    1043              :                                   ShadeHcRatioIn,
    1044              :                                   HcUnshadedOut,
    1045              :                                   HcUnshadedIn,
    1046              :                                   Keff,
    1047              :                                   ShadeGapKeffConv,
    1048              :                                   SDScalar,
    1049              :                                   SHGCCalc,
    1050              :                                   NumOfIterations,
    1051              :                                   edgeGlCorrFac);
    1052            0 :                 } else if ((standard == TARCOGGassesParams::Stdrd::EN673) || (standard == TARCOGGassesParams::Stdrd::EN673Design)) {
    1053            0 :                     Calc_EN673(state,
    1054              :                                files,
    1055              :                                standard,
    1056              :                                nlayer,
    1057              :                                tout,
    1058              :                                tind,
    1059            0 :                                state.dataTARCOGMain->GapDefMean,
    1060              :                                thick,
    1061              :                                scon,
    1062              :                                emis,
    1063              :                                totsol,
    1064              :                                tilt,
    1065              :                                dir,
    1066              :                                asol,
    1067              :                                presure,
    1068              :                                iprop,
    1069              :                                frct,
    1070              :                                nmix,
    1071              :                                xgcon,
    1072              :                                xgvis,
    1073              :                                xgcp,
    1074              :                                xwght,
    1075              :                                theta,
    1076              :                                ufactor,
    1077              :                                hcin,
    1078              :                                hin,
    1079              :                                hout,
    1080              :                                shgc,
    1081              :                                nperr,
    1082              :                                ErrorMessage,
    1083              :                                ibc,
    1084              :                                hg,
    1085              :                                hr,
    1086              :                                hs,
    1087              :                                Ra,
    1088              :                                Nu);
    1089              :                 } else {
    1090              :                 } // select case (standard)
    1091              : 
    1092            0 :                 if (!(GoAhead(nperr))) {
    1093            0 :                     return;
    1094              :                 }
    1095              : 
    1096              :                 // calc error
    1097            0 :                 dtmax = 0.0;
    1098            0 :                 for (i = 1; i <= 2 * nlayer; ++i) {
    1099            0 :                     dtmax = std::abs(state.dataTARCOGMain->told(i) - theta(i));
    1100              :                 } // do i=1, 2*nlayer
    1101              : 
    1102            0 :                 if (dtmax < DeflectionErrorMargin) {
    1103            0 :                     state.dataTARCOGMain->converged = true;
    1104              :                 }
    1105            0 :                 ++counter;
    1106              : 
    1107            0 :                 if (counter > DeflectionMaxIterations) {
    1108            0 :                     state.dataTARCOGMain->converged = true;
    1109            0 :                     nperr = 41; // Deflection calculations failed to converge
    1110            0 :                     ErrorMessage = "Deflection calculations failed to converge";
    1111              :                 }
    1112              :             } // do while (.not.(converged))
    1113              :         }     // if ((CalcDeflection.eq.DeflectionCalculation::TEMPERATURE).or.(CalcDeflection.eq.DeflectionCalculation::GAP_WIDTHS)) then
    1114              :     }         // if (GoAhead(nperr)) then
    1115              : 
    1116            0 :     FinishDebugOutputFiles(files, nperr);
    1117            0 : }
    1118              : 
    1119              : } // namespace EnergyPlus::TARCOGMain
        

Generated by: LCOV version 2.0-1