LCOV - code coverage report
Current view: top level - EnergyPlus - HeatBalanceHAMTManager.hh (source / functions) Coverage Total Hit
Test: lcov.output.filtered Lines: 32.1 % 28 9
Test Date: 2025-05-22 16:09:37 Functions: 50.0 % 6 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              : #ifndef HeatBalanceHAMTManager_hh_INCLUDED
      49              : #define HeatBalanceHAMTManager_hh_INCLUDED
      50              : 
      51              : // ObjexxFCL Headers
      52              : #include <ObjexxFCL/Optional.hh>
      53              : 
      54              : // EnergyPlus Headers
      55              : #include <EnergyPlus/Data/BaseData.hh>
      56              : #include <EnergyPlus/EnergyPlus.hh>
      57              : #include <EnergyPlus/Material.hh>
      58              : 
      59              : namespace EnergyPlus {
      60              : 
      61              : // Forward declarations
      62              : struct EnergyPlusData;
      63              : 
      64              : namespace HeatBalanceHAMTManager {
      65              : 
      66              :     // Data
      67              :     // MODULE PARAMETER DEFINITIONS:
      68              :     struct MaterialHAMT : public Material::MaterialBase
      69              :     {
      70              :         // HAMT
      71              :         int niso = -1;                                       // Number of data points
      72            0 :         Array1D<Real64> isodata = Array1D<Real64>(27, 0.0);  // isotherm values
      73            0 :         Array1D<Real64> isorh = Array1D<Real64>(27, 0.0);    // isotherm RH values
      74              :         int nsuc = -1;                                       // Number of data points
      75            0 :         Array1D<Real64> sucdata = Array1D<Real64>(27, 0.0);  // suction values
      76            0 :         Array1D<Real64> sucwater = Array1D<Real64>(27, 0.0); // suction water values
      77              :         int nred = -1;                                       // Number of data points
      78            0 :         Array1D<Real64> reddata = Array1D<Real64>(27, 0.0);  // redistribution values
      79            0 :         Array1D<Real64> redwater = Array1D<Real64>(27, 0.0); // redistribution water values
      80              :         int nmu = -1;                                        // Number of data points
      81            0 :         Array1D<Real64> mudata = Array1D<Real64>(27, 0.0);   // mu values
      82            0 :         Array1D<Real64> murh = Array1D<Real64>(27, 0.0);     // mu rh values
      83              :         int ntc = -1;                                        // Number of data points
      84            0 :         Array1D<Real64> tcdata = Array1D<Real64>(27, 0.0);   // thermal conductivity values
      85            0 :         Array1D<Real64> tcwater = Array1D<Real64>(27, 0.0);  // thermal conductivity water values
      86              :         Real64 itemp = 10.0;                                 // initial Temperature
      87              :         Real64 irh = 0.5;                                    // Initial RH
      88              :         Real64 iwater = 0.2;                                 // Initial water content kg/kg
      89              :         int divs = 3;                                        // Number of divisions
      90              :         Real64 divsize = 0.005;                              // Average Cell Size
      91              :         int divmin = 3;                                      // Minimum number of cells
      92              :         int divmax = 10;                                     // Maximum number of cells
      93              : 
      94            0 :         MaterialHAMT() : Material::MaterialBase()
      95              :         {
      96            0 :             group = Material::Group::Regular;
      97            0 :         }
      98            0 :         ~MaterialHAMT() = default;
      99              :     };
     100              : 
     101              :     constexpr int ittermax(150); // Maximum Number of itterations
     102              :     constexpr int adjmax(6);     // Maximum Number of Adjacent Cells
     103              : 
     104              :     constexpr Real64 wdensity(1000.0); // Density of water kg.m-3
     105              :     constexpr Real64 wspech(4180.0);   // Specific Heat Capacity of Water J.kg-1.K-1 (at 20C)
     106              :     constexpr Real64 whv(2489000.0);   // Evaporation enthalpy of water J.kg-1
     107              :     constexpr Real64 convt(0.002);     // Temperature convergence limit
     108              :     constexpr Real64 qvplim(100000.0); // Maximum latent heat W
     109              :     constexpr Real64 rhmax(1.01);      // Maximum RH value
     110              : 
     111              :     // Types
     112              :     struct subcell
     113              :     {
     114              :         // Members
     115              :         int matid;        // Material Id Number
     116              :         int sid;          // Surface Id Number
     117              :         Real64 Qadds;     // Additional sources of heat
     118              :         Real64 density;   // Density
     119              :         Real64 wthermalc; // Moisture Dependant Thermal Conductivity
     120              :         Real64 spech;     // Specific Heat capacity
     121              :         Real64 htc;       // Heat Transfer Coefficient
     122              :         Real64 vtc;       // Vapor Transfer Coefficient
     123              :         Real64 mu;        // Vapor Diffusion resistance Factor
     124              :         Real64 volume;    // Cell Volume
     125              :         Real64 temp;
     126              :         Real64 tempp1;
     127              :         Real64 tempp2;
     128              :         Real64 wreport; // Water content for reporting
     129              :         Real64 water;   // Water Content of cells
     130              :         Real64 vp;      // Vapor Pressure
     131              :         Real64 vpp1;    // Vapor Pressure
     132              :         Real64 vpsat;   // Saturation Vapor Pressure
     133              :         Real64 rh;
     134              :         Real64 rhp1;
     135              :         Real64 rhp2;             // Relative Humidity
     136              :         Real64 rhp;              // cell relative humidity (percent - reporting)
     137              :         Real64 dwdphi;           // Moisture storage capacity
     138              :         Real64 dw;               // Liquid transport Coefficient
     139              :         Array1D<Real64> origin;  // Cell origin. The geometric centre of the cell.
     140              :         Array1D<Real64> length;  // Cell lengths
     141              :         Array1D<Real64> overlap; // Area of overlap
     142              :         Array1D<Real64> dist;    // distance between cell origins
     143              :         Array1D_int adjs;
     144              :         Array1D_int adjsl;
     145              : 
     146              :         // Default Constructor
     147            0 :         subcell()
     148            0 :             : matid(-1), sid(-1), Qadds(0.0), density(-1.0), wthermalc(0.0), spech(0.0), htc(-1.0), vtc(-1.0), mu(-1.0), volume(0.0), temp(0.0),
     149            0 :               tempp1(0.0), tempp2(0.0), wreport(0.0), water(0.0), vp(0.0), vpp1(0.0), vpsat(0.0), rh(0.1), rhp1(0.1), rhp2(0.1), rhp(10.0),
     150            0 :               dwdphi(-1.0), dw(-1.0), origin(3, 0.0), length(3, 0.0), overlap(6, 0.0), dist(6, 0.0), adjs(6, 0), adjsl(6, 0)
     151              :         {
     152            0 :         }
     153              :     };
     154              : 
     155              :     void ManageHeatBalHAMT(EnergyPlusData &state, int const SurfNum, Real64 &SurfTempInTmp, Real64 &TempSurfOutTmp);
     156              : 
     157              :     void GetHeatBalHAMTInput(EnergyPlusData &state);
     158              : 
     159              :     void InitHeatBalHAMT(EnergyPlusData &state);
     160              : 
     161              :     void CalcHeatBalHAMT(EnergyPlusData &state, int const sid, Real64 &SurfTempInTmp, Real64 &TempSurfOutTmp);
     162              : 
     163              :     void UpdateHeatBalHAMT(EnergyPlusData &state, int const sid);
     164              : 
     165              :     void interp(int const ndata,
     166              :                 const Array1D<Real64> &xx,
     167              :                 const Array1D<Real64> &yy,
     168              :                 Real64 const invalue,
     169              :                 Real64 &outvalue,
     170              :                 ObjexxFCL::Optional<Real64> outgrad = _);
     171              : 
     172              :     Real64 RHtoVP(EnergyPlusData &state, Real64 const RH, Real64 const Temperature);
     173              : 
     174              :     Real64 WVDC(Real64 const Temperature, Real64 const ambp);
     175              : 
     176              :     //                                 COPYRIGHT NOTICE
     177              : 
     178              :     //     Portions Copyright (c) University College London 2007.  All rights
     179              :     //     reserved.
     180              : 
     181              :     //     UCL LEGAL NOTICE
     182              :     //     Neither UCL, members of UCL nor any person or organisation acting on
     183              :     //     behalf of either:
     184              : 
     185              :     //     A. Makes any warranty of representation, express or implied with
     186              :     //        respect to the accuracy, completeness, or usefulness of the
     187              :     //        information contained in this program, including any warranty of
     188              :     //        merchantability or fitness of any purpose with respect to the
     189              :     //        program, or that the use of any information disclosed in this
     190              :     //        program may not infringe privately-owned rights, or
     191              : 
     192              :     //     B. Assumes any liability with respect to the use of, or for any and
     193              :     //        all damages resulting from the use of the program or any portion
     194              :     //        thereof or any information disclosed therein.
     195              : 
     196              : } // namespace HeatBalanceHAMTManager
     197              : 
     198              : struct HeatBalHAMTMgrData : BaseGlobalStruct
     199              : {
     200              : 
     201              :     Array1D_int firstcell;
     202              :     Array1D_int lastcell;
     203              :     Array1D_int Extcell;
     204              :     Array1D_int ExtRadcell;
     205              :     Array1D_int ExtConcell;
     206              :     Array1D_int ExtSkycell;
     207              :     Array1D_int ExtGrncell;
     208              :     Array1D_int Intcell;
     209              :     Array1D_int IntConcell;
     210              :     Array1D<Real64> watertot;
     211              :     Array1D<Real64> surfrh;
     212              :     Array1D<Real64> surfextrh;
     213              :     Array1D<Real64> surftemp;
     214              :     Array1D<Real64> surfexttemp;
     215              :     Array1D<Real64> surfvp;
     216              :     Array1D<Real64> extvtc;   // External Surface vapor transfer coefficient
     217              :     Array1D<Real64> intvtc;   // Internal Surface Vapor Transfer Coefficient
     218              :     Array1D_bool extvtcflag;  // External Surface vapor transfer coefficient flag
     219              :     Array1D_bool intvtcflag;  // Internal Surface Vapor Transfer Coefficient flag
     220              :     Array1D_bool MyEnvrnFlag; // Flag to reset surface properties.
     221              :     Real64 deltat = 0.0;      // time step in seconds
     222              :     int TotCellsMax = 0;      // Maximum number of cells per material
     223              :     bool latswitch = false;   // latent heat switch,
     224              :     bool rainswitch = false;  // rain switch,
     225              :     Array1D<HeatBalanceHAMTManager::subcell> cells;
     226              :     bool OneTimeFlag = true;
     227              :     int qvpErrCount = 0;
     228              :     int qvpErrReport = 0;
     229              : 
     230         2126 :     void init_constant_state([[maybe_unused]] EnergyPlusData &state) override
     231              :     {
     232         2126 :     }
     233              : 
     234         1152 :     void init_state([[maybe_unused]] EnergyPlusData &state) override
     235              :     {
     236         1152 :     }
     237              : 
     238         2100 :     void clear_state() override
     239              :     {
     240         2100 :         this->OneTimeFlag = true;
     241         2100 :         this->qvpErrCount = 0;
     242         2100 :         this->qvpErrReport = 0;
     243         2100 :     }
     244              : };
     245              : 
     246              : } // namespace EnergyPlus
     247              : 
     248              : #endif
        

Generated by: LCOV version 2.0-1