LCOV - code coverage report
Current view: top level - EnergyPlus - TARCOGDeflection.cc (source / functions) Coverage Total Hit
Test: lcov.output.filtered Lines: 97.6 % 84 82
Test Date: 2025-06-02 07:23:51 Functions: 100.0 % 3 3

            Line data    Source code
       1              : // EnergyPlus, Copyright (c) 1996-2025, The Board of Trustees of the University of Illinois,
       2              : // The Regents of the University of California, through Lawrence Berkeley National Laboratory
       3              : // (subject to receipt of any required approvals from the U.S. Dept. of Energy), Oak Ridge
       4              : // National Laboratory, managed by UT-Battelle, Alliance for Sustainable Energy, LLC, and other
       5              : // contributors. All rights reserved.
       6              : //
       7              : // NOTICE: This Software was developed under funding from the U.S. Department of Energy and the
       8              : // U.S. Government consequently retains certain rights. As such, the U.S. Government has been
       9              : // granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable,
      10              : // worldwide license in the Software to reproduce, distribute copies to the public, prepare
      11              : // derivative works, and perform publicly and display publicly, and to permit others to do so.
      12              : //
      13              : // Redistribution and use in source and binary forms, with or without modification, are permitted
      14              : // provided that the following conditions are met:
      15              : //
      16              : // (1) Redistributions of source code must retain the above copyright notice, this list of
      17              : //     conditions and the following disclaimer.
      18              : //
      19              : // (2) Redistributions in binary form must reproduce the above copyright notice, this list of
      20              : //     conditions and the following disclaimer in the documentation and/or other materials
      21              : //     provided with the distribution.
      22              : //
      23              : // (3) Neither the name of the University of California, Lawrence Berkeley National Laboratory,
      24              : //     the University of Illinois, U.S. Dept. of Energy nor the names of its contributors may be
      25              : //     used to endorse or promote products derived from this software without specific prior
      26              : //     written permission.
      27              : //
      28              : // (4) Use of EnergyPlus(TM) Name. If Licensee (i) distributes the software in stand-alone form
      29              : //     without changes from the version obtained under this License, or (ii) Licensee makes a
      30              : //     reference solely to the software portion of its product, Licensee must refer to the
      31              : //     software as "EnergyPlus version X" software, where "X" is the version number Licensee
      32              : //     obtained under this License and may not use a different name for the software. Except as
      33              : //     specifically required in this Section (4), Licensee shall not use in a company name, a
      34              : //     product name, in advertising, publicity, or other promotional activities any name, trade
      35              : //     name, trademark, logo, or other designation of "EnergyPlus", "E+", "e+" or confusingly
      36              : //     similar designation, without the U.S. Department of Energy's prior written consent.
      37              : //
      38              : // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
      39              : // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
      40              : // AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
      41              : // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
      42              : // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
      43              : // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
      44              : // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
      45              : // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
      46              : // POSSIBILITY OF SUCH DAMAGE.
      47              : 
      48              : // ObjexxFCL Headers
      49              : #include <ObjexxFCL/Array1D.hh>
      50              : 
      51              : // EnergyPlus Headers
      52              : #include <EnergyPlus/DataGlobals.hh>
      53              : #include <EnergyPlus/TARCOGCommon.hh>
      54              : #include <EnergyPlus/TARCOGDeflection.hh>
      55              : #include <EnergyPlus/TARCOGParams.hh>
      56              : 
      57              : namespace EnergyPlus::TARCOGDeflection {
      58              : 
      59              : // MODULE INFORMATION:
      60              : //       AUTHOR         Simon Vidanovic
      61              : //       DATE WRITTEN   October/22/2011
      62              : //       MODIFIED       na
      63              : //       RE-ENGINEERED  na
      64              : //  Revision: 7.0.02  (October 22, 2011)
      65              : //   - Initial setup
      66              : 
      67              : // PURPOSE OF THIS MODULE:
      68              : // A module which contains functions for deflection calculation
      69              : 
      70              : // Using/Aliasing
      71              : using namespace TARCOGParams;
      72              : using namespace TARCOGCommon;
      73              : 
      74         4036 : void PanesDeflection(DeflectionCalculation const DeflectionStandard,
      75              :                      Real64 const W,
      76              :                      Real64 const H,
      77              :                      int const nlayer,
      78              :                      Real64 const Pa,
      79              :                      Real64 const Pini,
      80              :                      Real64 const Tini,
      81              :                      const Array1D<Real64> &PaneThickness,
      82              :                      const Array1D<Real64> &NonDeflectedGapWidth,
      83              :                      Array1D<Real64> &DeflectedGapWidthMax,
      84              :                      Array1D<Real64> &DeflectedGapWidthMean,
      85              :                      const Array1D<Real64> &PanelTemps,
      86              :                      const Array1D<Real64> &YoungsMod,
      87              :                      const Array1D<Real64> &PoissonsRat,
      88              :                      Array1D<Real64> &LayerDeflection,
      89              :                      int &nperr,
      90              :                      std::string &ErrorMessage)
      91              : {
      92              :     //***********************************************************************
      93              :     // PanesDeflection - calculates deflection of panes and recalculate gap
      94              :     //                   widths at maximal point of deflection
      95              :     //***********************************************************************
      96              : 
      97              :     // Argument array dimensioning
      98         4036 :     EP_SIZE_CHECK(PaneThickness, maxlay);
      99         4036 :     EP_SIZE_CHECK(NonDeflectedGapWidth, MaxGap);
     100         4036 :     EP_SIZE_CHECK(DeflectedGapWidthMax, MaxGap);
     101         4036 :     EP_SIZE_CHECK(DeflectedGapWidthMean, MaxGap);
     102         4036 :     EP_SIZE_CHECK(PanelTemps, maxlay2);
     103         4036 :     EP_SIZE_CHECK(YoungsMod, maxlay);
     104         4036 :     EP_SIZE_CHECK(PoissonsRat, maxlay);
     105         4036 :     EP_SIZE_CHECK(LayerDeflection, maxlay);
     106              : 
     107              :     // Localy used
     108         4036 :     Array1D<Real64> DCoeff(maxlay);
     109              : 
     110              :     // first calculate D coefficients since that will be necessary for any of selected standards
     111        16144 :     for (int i = 1; i <= nlayer; ++i) {
     112        12108 :         DCoeff(i) = YoungsMod(i) * pow_3(PaneThickness(i)) / (12 * (1 - pow_2(PoissonsRat(i))));
     113              :     }
     114         4036 :     if (DeflectionStandard == DeflectionCalculation::TEMPERATURE) {
     115         2018 :         DeflectionTemperatures(nlayer,
     116              :                                W,
     117              :                                H,
     118              :                                Pa,
     119              :                                Pini,
     120              :                                Tini,
     121              :                                NonDeflectedGapWidth,
     122              :                                DeflectedGapWidthMax,
     123              :                                DeflectedGapWidthMean,
     124              :                                PanelTemps,
     125              :                                DCoeff,
     126              :                                LayerDeflection,
     127              :                                nperr,
     128              :                                ErrorMessage);
     129         2018 :     } else if (DeflectionStandard == DeflectionCalculation::GAP_WIDTHS) {
     130         2018 :         DeflectionWidths(nlayer, W, H, DCoeff, NonDeflectedGapWidth, DeflectedGapWidthMax, DeflectedGapWidthMean, LayerDeflection);
     131              :     } else { // including NO_DEFLECTION_CALCULATION
     132            0 :         return;
     133              :     }
     134         4036 : }
     135              : 
     136         2018 : void DeflectionTemperatures(int const nlayer,
     137              :                             Real64 const W,
     138              :                             Real64 const H,
     139              :                             Real64 const Pa,
     140              :                             Real64 const Pini,
     141              :                             Real64 const Tini,
     142              :                             const Array1D<Real64> &NonDeflectedGapWidth,
     143              :                             Array1D<Real64> &DeflectedGapWidthMax,
     144              :                             Array1D<Real64> &DeflectedGapWidthMean,
     145              :                             const Array1D<Real64> &PanelTemps,
     146              :                             Array1D<Real64> &DCoeff,
     147              :                             Array1D<Real64> &LayerDeflection,
     148              :                             int &nperr,
     149              :                             std::string &ErrorMessage)
     150              : {
     151              :     //***********************************************************************************************************
     152              :     // DeflectionTemperatures - calculates deflection of panes and recalculate gap
     153              :     //                          widths at maximal point of deflection based on gap pressures and temperatures
     154              :     //***********************************************************************************************************
     155              : 
     156              :     // Argument array dimensioning
     157         2018 :     EP_SIZE_CHECK(NonDeflectedGapWidth, MaxGap);
     158         2018 :     EP_SIZE_CHECK(DeflectedGapWidthMax, MaxGap);
     159         2018 :     EP_SIZE_CHECK(DeflectedGapWidthMean, MaxGap);
     160         2018 :     EP_SIZE_CHECK(PanelTemps, maxlay2);
     161         2018 :     EP_SIZE_CHECK(DCoeff, maxlay);
     162         2018 :     EP_SIZE_CHECK(LayerDeflection, maxlay);
     163              : 
     164              :     // Static constants
     165         2018 :     static Real64 const Pi_6(pow_6(Constant::Pi));
     166              : 
     167              :     // localy used
     168         2018 :     Array1D<Real64> DPressure(maxlay); // delta pressure at each glazing layer
     169         2018 :     Array1D<Real64> Vini(MaxGap);
     170         2018 :     Array1D<Real64> Vgap(MaxGap);
     171         2018 :     Array1D<Real64> Pgap(MaxGap);
     172         2018 :     Array1D<Real64> Tgap(MaxGap);
     173              :     Real64 MaxLDSum;
     174              :     Real64 MeanLDSum;
     175              :     Real64 Ratio;
     176              : 
     177              :     // calculate Vini for each gap
     178         4036 :     for (int i = 1; i <= nlayer - 1; ++i) {
     179         2018 :         Vini(i) = NonDeflectedGapWidth(i) * W * H;
     180              :     } // do i = 1, nlayer
     181              : 
     182         2018 :     MaxLDSum = LDSumMax(W, H);
     183         2018 :     MeanLDSum = LDSumMean(W, H);
     184         2018 :     Ratio = MeanLDSum / MaxLDSum;
     185              : 
     186              :     // calculate Vgap for each gap
     187         2018 :     Real64 const W_H_Ratio(W * H * Ratio);
     188         4036 :     for (int i = 1; i <= nlayer - 1; ++i) {
     189         2018 :         Vgap(i) = Vini(i) + W_H_Ratio * (LayerDeflection(i) - LayerDeflection(i + 1));
     190              :     } // do i = 1, nlayer
     191              : 
     192              :     // calculate Tgap for each gap
     193         4036 :     for (int i = 1; i <= nlayer - 1; ++i) {
     194         2018 :         int const j = 2 * i;
     195         2018 :         Tgap(i) = (PanelTemps(j) + PanelTemps(j + 1)) / 2;
     196              :     } // do i = 1, nlayer
     197              : 
     198         4036 :     for (int i = 1; i <= nlayer - 1; ++i) {
     199         2018 :         Pgap(i) = Pini * Vini(i) * Tgap(i) / (Tini * Vgap(i));
     200              :     } // do i = 1, nlayer
     201              : 
     202         2018 :     DPressure(1) = Pgap(1) - Pa;
     203         2018 :     if (nlayer > 1) {
     204         2018 :         DPressure(nlayer) = Pa - Pgap(nlayer - 1);
     205              :     }
     206              : 
     207         2018 :     for (int i = 2; i <= nlayer - 1; ++i) {
     208            0 :         DPressure(i) = Pgap(i) - Pgap(i - 1);
     209              :     } // do i = 1, nlayer
     210              : 
     211         2018 :     Real64 const deflection_fac(DeflectionRelaxation * MaxLDSum * 16);
     212         6054 :     for (int i = 1; i <= nlayer; ++i) {
     213         4036 :         LayerDeflection(i) += deflection_fac * DPressure(i) / (Pi_6 * DCoeff(i));
     214              :     }
     215              : 
     216         4036 :     for (int i = 1; i <= nlayer - 1; ++i) {
     217         2018 :         DeflectedGapWidthMax(i) = NonDeflectedGapWidth(i) + LayerDeflection(i) - LayerDeflection(i + 1);
     218         2018 :         if (DeflectedGapWidthMax(i) < 0.0) {
     219         2018 :             nperr = 2001; // glazing panes collapsed
     220         2018 :             ErrorMessage = "Glazing panes collapsed";
     221              :         }
     222              :     }
     223              : 
     224         4036 :     for (int i = 1; i <= nlayer - 1; ++i) {
     225         2018 :         DeflectedGapWidthMean(i) = NonDeflectedGapWidth(i) + Ratio * (DeflectedGapWidthMax(i) - NonDeflectedGapWidth(i));
     226              :     }
     227         2018 : }
     228              : 
     229         2018 : void DeflectionWidths(int const nlayer,
     230              :                       Real64 const W,
     231              :                       Real64 const H,
     232              :                       Array1D<Real64> &DCoeff,
     233              :                       const Array1D<Real64> &NonDeflectedGapWidth,
     234              :                       const Array1D<Real64> &DeflectedGapWidthMax,
     235              :                       Array1D<Real64> &DeflectedGapWidthMean,
     236              :                       Array1D<Real64> &LayerDeflection)
     237              : {
     238              :     // Argument array dimensioning
     239         2018 :     EP_SIZE_CHECK(DCoeff, maxlay);
     240         2018 :     EP_SIZE_CHECK(NonDeflectedGapWidth, MaxGap);
     241         2018 :     EP_SIZE_CHECK(DeflectedGapWidthMax, MaxGap);
     242         2018 :     EP_SIZE_CHECK(DeflectedGapWidthMean, MaxGap);
     243         2018 :     EP_SIZE_CHECK(LayerDeflection, maxlay);
     244              : 
     245         2018 :     Real64 nominator = 0.0;
     246         8072 :     for (int i = 1; i <= nlayer - 1; ++i) {
     247         6054 :         Real64 SumL = 0.0;
     248        18162 :         for (int j = i; j <= nlayer - 1; ++j) {
     249        12108 :             SumL += NonDeflectedGapWidth(j) - DeflectedGapWidthMax(j);
     250              :         }
     251         6054 :         nominator += SumL * DCoeff(i);
     252              :     }
     253              : 
     254         2018 :     Real64 denominator = 0.0;
     255        10090 :     for (int i = 1; i <= nlayer; ++i) {
     256         8072 :         denominator += DCoeff(i);
     257              :     }
     258              : 
     259         2018 :     LayerDeflection(nlayer) = nominator / denominator;
     260              : 
     261         8072 :     for (int i = nlayer - 1; i >= 1; --i) {
     262         6054 :         LayerDeflection(i) = DeflectedGapWidthMax(i) - NonDeflectedGapWidth(i) + LayerDeflection(i + 1);
     263              :     }
     264              : 
     265         2018 :     Real64 MaxLDSum = LDSumMax(W, H);
     266         2018 :     Real64 MeanLDSum = LDSumMean(W, H);
     267         2018 :     Real64 Ratio = MeanLDSum / MaxLDSum;
     268              : 
     269         8072 :     for (int i = 1; i <= nlayer - 1; ++i) {
     270         6054 :         DeflectedGapWidthMean(i) = NonDeflectedGapWidth(i) + Ratio * (DeflectedGapWidthMax(i) - NonDeflectedGapWidth(i));
     271              :     }
     272         2018 : }
     273              : 
     274              : } // namespace EnergyPlus::TARCOGDeflection
        

Generated by: LCOV version 2.0-1