LCOV - code coverage report
Current view: top level - EnergyPlus - PsychCacheData.hh (source / functions) Coverage Total Hit
Test: lcov.output.filtered Lines: 100.0 % 11 11
Test Date: 2025-05-22 16:09:37 Functions: 100.0 % 5 5

            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 PsychCacheData_hh_INCLUDED
      49              : #define PsychCacheData_hh_INCLUDED
      50              : 
      51              : #include <EnergyPlus/Data/BaseData.hh>
      52              : 
      53              : namespace EnergyPlus {
      54              : 
      55              : enum class PsychrometricFunction : int
      56              : {
      57              :     Invalid = -1,
      58              :     TdpFnTdbTwbPb,
      59              :     RhFnTdbWPb,
      60              :     TwbFnTdbWPb,
      61              :     VFnTdbWPb,
      62              :     WFnTdpPb,
      63              :     WFnTdbH,
      64              :     WFnTdbTwbPb,
      65              :     WFnTdbRhPb,
      66              :     PsatFnTemp,
      67              :     TsatFnHPb,
      68              :     TsatFnPb,
      69              :     RhFnTdbRhov,
      70              :     RhFnTdbRhovLBnd0C,
      71              :     TwbFnTdbWPb2,
      72              :     TwbFnTdbWPb3, // convergence,
      73              :     WFnTdbTwbPb2,
      74              :     TsatFnPb2, // iteration,
      75              :     TwbFnTdbWPb_cache,
      76              :     PsatFnTemp_cache,
      77              :     Num // The number of enums in this enum class
      78              : };
      79              : 
      80              : #ifdef EP_nocache_Psychrometrics
      81              : #    undef EP_cache_PsyTwbFnTdbWPb
      82              : #    undef EP_cache_PsyPsatFnTemp
      83              : #    undef EP_cache_PsyTsatFnPb
      84              : #    undef EP_cache_PsyTsatFnHPb
      85              : #else
      86              : #    define EP_cache_PsyTwbFnTdbWPb
      87              : #    define EP_cache_PsyPsatFnTemp
      88              : #    define EP_cache_PsyTsatFnPb
      89              : #    define EP_cache_PsyTsatFnHPb
      90              : #endif
      91              : 
      92              : #ifdef EP_cache_PsyTwbFnTdbWPb
      93              : constexpr int twbcache_size = 1024 * 1024;
      94              : constexpr int twbprecision_bits = 20;
      95              : #endif
      96              : #ifdef EP_cache_PsyPsatFnTemp
      97              : constexpr int psatcache_size = 1024 * 1024;
      98              : constexpr int psatprecision_bits = 24; // 28  //24  //32
      99              : constexpr Int64 psatcache_mask = psatcache_size - 1;
     100              : #endif
     101              : #ifdef EP_cache_PsyTsatFnPb
     102              : constexpr int tsatcache_size = 1024 * 1024;
     103              : constexpr Int64 tsatcache_mask = tsatcache_size - 1;
     104              : #endif
     105              : #ifdef EP_cache_PsyTsatFnHPb
     106              : constexpr int tsat_hbp_cache_size = 1024 * 1024;
     107              : constexpr int tsat_hbp_precision_bits = 28;
     108              : #endif
     109              : 
     110              : #ifdef EP_cache_PsyTwbFnTdbWPb
     111              : struct cached_twb_t
     112              : {
     113              :     // Members
     114              :     std::uint64_t iTdb{0};
     115              :     std::uint64_t iW{0};
     116              :     std::uint64_t iPb{0};
     117              :     Real64 Twb{0};
     118              : };
     119              : #endif
     120              : #ifdef EP_cache_PsyTsatFnHPb
     121              : struct cached_tsat_h_pb
     122              : {
     123              :     // Members
     124              :     Int64 iH;
     125              :     Int64 iPb;
     126              :     Real64 Tsat;
     127              : 
     128              :     // Default Constructor
     129   4464840864 :     cached_tsat_h_pb() : iH(0), iPb(0), Tsat(0.0)
     130              :     {
     131   4464840864 :     }
     132              : };
     133              : #endif
     134              : #ifdef EP_cache_PsyPsatFnTemp
     135              : struct cached_psat_t
     136              : {
     137              :     // Members
     138              :     Int64 iTdb;
     139              :     Real64 Psat;
     140              : 
     141              :     // Default Constructor
     142   2232420432 :     cached_psat_t() : iTdb(-1000), Psat(0.0)
     143              :     {
     144   2232420432 :     }
     145              : };
     146              : #endif
     147              : #ifdef EP_cache_PsyTsatFnPb
     148              : struct cached_tsat_pb
     149              : {
     150              :     // Members
     151              :     Int64 iPb;
     152              :     Real64 Tsat;
     153              : 
     154              :     // Default Constructor
     155              :     cached_tsat_pb() : iPb(-1000), Tsat(0.0)
     156              :     {
     157              :     }
     158              : };
     159              : 
     160              : #endif
     161              : 
     162              : struct PsychrometricCacheData : BaseGlobalStruct
     163              : {
     164              : 
     165              : #ifdef EP_cache_PsyTwbFnTdbWPb
     166              :     std::array<cached_twb_t, twbcache_size> cached_Twb;
     167              : #endif
     168              : #ifdef EP_cache_PsyPsatFnTemp
     169              :     std::array<cached_psat_t, psatcache_size> cached_Psat;
     170              : #endif
     171              : #ifdef EP_cache_PsyTsatFnPb
     172              :     std::array<cached_tsat_h_pb, tsatcache_size> cached_Tsat;
     173              :     int tsatprecision_bits = 24;
     174              : #endif
     175              : #ifdef EP_cache_PsyTsatFnHPb
     176              :     std::array<cached_tsat_h_pb, tsat_hbp_cache_size> cached_Tsat_HPb;
     177              : #endif
     178              : 
     179              : #ifdef EP_psych_stats
     180              :     std::array<std::int64_t, static_cast<int>(PsychrometricFunction::Num)> NumTimesCalled;
     181              :     std::array<int, static_cast<int>(PsychrometricFunction::Num)> NumIterations;
     182              : #endif
     183              : 
     184         2126 :     void init_constant_state([[maybe_unused]] EnergyPlusData &state) override
     185              :     {
     186         2126 :     }
     187              : 
     188         1152 :     void init_state([[maybe_unused]] EnergyPlusData &state) override
     189              :     {
     190         1152 :     }
     191              : 
     192         2100 :     void clear_state() override
     193              :     {
     194              : #ifdef EP_psych_stats
     195              :         NumTimesCalled.fill(0);
     196              :         NumIterations.fill(0);
     197              : #endif
     198              : #ifdef EP_cache_PsyTsatFnPb
     199         2100 :         tsatprecision_bits = 24;
     200              : #endif
     201         2100 :     }
     202              : };
     203              : 
     204              : } // namespace EnergyPlus
     205              : 
     206              : #endif // PsychCacheData_hh_INCLUDED
        

Generated by: LCOV version 2.0-1