LCOV - code coverage report
Current view: top level - EnergyPlus - SurfaceGroundHeatExchanger.hh (source / functions) Coverage Total Hit
Test: lcov.output.filtered Lines: 75.5 % 49 37
Test Date: 2025-05-22 16:09:37 Functions: 71.4 % 7 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 SurfaceGroundHeatExchanger_hh_INCLUDED
      49              : #define SurfaceGroundHeatExchanger_hh_INCLUDED
      50              : 
      51              : // ObjexxFCL Headers
      52              : #include <ObjexxFCL/Array1D.hh>
      53              : 
      54              : // EnergyPlus Headers
      55              : #include <EnergyPlus/Construction.hh>
      56              : #include <EnergyPlus/DataGlobalConstants.hh>
      57              : #include <EnergyPlus/DataGlobals.hh>
      58              : #include <EnergyPlus/EnergyPlus.hh>
      59              : #include <EnergyPlus/Material.hh>
      60              : #include <EnergyPlus/Plant/PlantLocation.hh>
      61              : #include <EnergyPlus/PlantComponent.hh>
      62              : 
      63              : namespace EnergyPlus {
      64              : 
      65              : // Forward declarations
      66              : struct EnergyPlusData;
      67              : 
      68              : namespace SurfaceGroundHeatExchanger {
      69              : 
      70              :     struct SurfaceGroundHeatExchangerData : PlantComponent
      71              :     {
      72            0 :         ~SurfaceGroundHeatExchangerData() = default;
      73              : 
      74              :         std::string Name;             // name of surface GHE
      75              :         std::string ConstructionName; // name of the associated construction
      76              :         std::string InletNode;        // surface GHE inlet fluid node
      77              :         std::string OutletNode;       // surface GHE outlet fluid node
      78              :         Real64 DesignMassFlowRate;
      79              :         Real64 TubeDiameter;                     // hydronic tube inside diameter
      80              :         Real64 TubeSpacing;                      // tube spacing
      81              :         Real64 SurfaceLength;                    // active length of surface GHE
      82              :         Real64 SurfaceWidth;                     // active width of surface GHE
      83              :         Real64 TopThermAbs;                      // Thermal absortivity of top layer
      84              :         Real64 TopSolarAbs;                      // solar absortivity of top layer
      85              :         Real64 BtmThermAbs;                      // Thermal absortivity of bottom layer
      86              :         int LowerSurfCond;                       // Type of lower surf. boundary condition
      87              :         int TubeCircuits;                        // number of circuits in total
      88              :         int ConstructionNum;                     // construction index number
      89              :         int InletNodeNum;                        // inlet node number
      90              :         int OutletNodeNum;                       // oulet node number
      91              :         Material::SurfaceRoughness TopRoughness; // roughness of top layer
      92              :         Material::SurfaceRoughness BtmRoughness; // roughness of bottom layer
      93              :         int FrozenErrIndex1;                     // recurring error index
      94              :         int FrozenErrIndex2;                     // recurring error index
      95              :         int ConvErrIndex1;                       // recurring error index
      96              :         int ConvErrIndex2;                       // recurring error index
      97              :         int ConvErrIndex3;                       // recurring error index
      98              :                                                  // loop topology variables
      99              :         PlantLocation plantLoc;
     100              : 
     101              :         // QTF Constants
     102              :         Real64 TsrcConstCoef;
     103              :         Real64 TsrcVarCoef;
     104              :         Real64 QbtmConstCoef;
     105              :         Real64 QbtmVarCoef;
     106              :         Real64 QtopConstCoef;
     107              :         Real64 QtopVarCoef;
     108              :         // conventional CTF terms
     109              :         int NumCTFTerms; // number of terms for surface
     110              :         // could be allocated rather than hard dimensioning.
     111              :         std::array<Real64, Construction::MaxCTFTerms> CTFin{};    // surf flux in ctf - X
     112              :         std::array<Real64, Construction::MaxCTFTerms> CTFout{};   // surf flux in ctf - Z
     113              :         std::array<Real64, Construction::MaxCTFTerms> CTFcross{}; // surf flux in ctf - Y
     114              :         std::array<Real64, Construction::MaxCTFTerms> CTFflux{};  // surf flux in ctf - F
     115              :         // QTF coefficients
     116              :         std::array<Real64, Construction::MaxCTFTerms> CTFSourceIn{};   // surf flux in ctf - Wi
     117              :         std::array<Real64, Construction::MaxCTFTerms> CTFSourceOut{};  // surf flux out ctf - Wo
     118              :         std::array<Real64, Construction::MaxCTFTerms> CTFTSourceOut{}; // surf flux in qtf - x
     119              :         std::array<Real64, Construction::MaxCTFTerms> CTFTSourceIn{};  // surf flux in qtf - y
     120              :         std::array<Real64, Construction::MaxCTFTerms> CTFTSourceQ{};   // surf flux in qtf - f
     121              :         // History data
     122              :         std::array<Real64, Construction::MaxCTFTerms> TbtmHistory{};
     123              :         std::array<Real64, Construction::MaxCTFTerms> TtopHistory{};
     124              :         std::array<Real64, Construction::MaxCTFTerms> TsrcHistory{};
     125              :         std::array<Real64, Construction::MaxCTFTerms> QbtmHistory{};
     126              :         std::array<Real64, Construction::MaxCTFTerms> QtopHistory{};
     127              :         std::array<Real64, Construction::MaxCTFTerms> QsrcHistory{};
     128              :         Real64 QSrc;
     129              :         Real64 QSrcAvg;
     130              :         Real64 LastQSrc;
     131              :         Real64 LastSysTimeElapsed;
     132              :         Real64 LastTimeStepSys;
     133              : 
     134              :         // Report data
     135              :         Real64 InletTemp;            // water inlet temperature
     136              :         Real64 OutletTemp;           // water outlet temperature
     137              :         Real64 MassFlowRate;         // water mass flow rate
     138              :         Real64 TopSurfaceTemp;       // Top surface temperature
     139              :         Real64 BtmSurfaceTemp;       // Bottom  surface temperature
     140              :         Real64 TopSurfaceFlux;       // Top  surface heat flux
     141              :         Real64 BtmSurfaceFlux;       // Bottom  surface heat flux
     142              :         Real64 HeatTransferRate;     // total fluid heat transfer rate, Watts
     143              :         Real64 SurfHeatTransferRate; // total surface heat transfer rate, Watts
     144              :         Real64 Energy;               // cumulative energy, Joules
     145              :         Real64 SurfEnergy;           // cumulative energy, Joules
     146              :         Real64 SourceTemp;           // Source temperature
     147              : 
     148              :         bool MyFlag;
     149              :         bool InitQTF;
     150              :         bool MyEnvrnFlag;
     151              :         Real64 SurfaceArea; // surface GHE surface area
     152              :         bool firstTimeThrough;
     153              : 
     154              :         // Default Constructor
     155            0 :         SurfaceGroundHeatExchangerData()
     156            0 :             : DesignMassFlowRate(0.0), TubeDiameter(0.0), TubeSpacing(0.0), SurfaceLength(0.0), SurfaceWidth(0.0), TopThermAbs(0.0), TopSolarAbs(0.0),
     157            0 :               BtmThermAbs(0.0), LowerSurfCond(0), TubeCircuits(0), ConstructionNum(0), InletNodeNum(0), OutletNodeNum(0),
     158            0 :               TopRoughness(Material::SurfaceRoughness::Invalid), BtmRoughness(Material::SurfaceRoughness::Invalid), FrozenErrIndex1(0),
     159            0 :               FrozenErrIndex2(0), ConvErrIndex1(0), ConvErrIndex2(0), ConvErrIndex3(0), plantLoc{}, TsrcConstCoef(0.0), TsrcVarCoef(0.0),
     160            0 :               QbtmConstCoef(0.0), QbtmVarCoef(0.0), QtopConstCoef(0.0), QtopVarCoef(0.0), NumCTFTerms(0), QSrc(0.0), QSrcAvg(0.0), LastQSrc(0.0),
     161            0 :               LastSysTimeElapsed(0.0), LastTimeStepSys(0.0),
     162              : 
     163            0 :               InletTemp(0.0), OutletTemp(0.0), MassFlowRate(0.0), TopSurfaceTemp(0.0), BtmSurfaceTemp(0.0), TopSurfaceFlux(0.0), BtmSurfaceFlux(0.0),
     164            0 :               HeatTransferRate(0.0), SurfHeatTransferRate(0.0), Energy(0.0), SurfEnergy(0.0), SourceTemp(0.0),
     165              : 
     166            0 :               MyFlag(true), InitQTF(true), MyEnvrnFlag(true), SurfaceArea(0.0), firstTimeThrough(true)
     167              :         {
     168            0 :         }
     169              : 
     170              :         void simulate([[maybe_unused]] EnergyPlusData &state,
     171              :                       const PlantLocation &calledFromLocation,
     172              :                       bool FirstHVACIteration,
     173              :                       Real64 &CurLoad,
     174              :                       bool RunFlag) override;
     175              : 
     176              :         static PlantComponent *factory(EnergyPlusData &state, DataPlant::PlantEquipmentType objectType, std::string objectName);
     177              : 
     178              :         void InitSurfaceGroundHeatExchanger(EnergyPlusData &state);
     179              : 
     180              :         //==============================================================================
     181              : 
     182              :         void CalcSurfaceGroundHeatExchanger(EnergyPlusData &state, bool FirstHVACIteration // TRUE if 1st HVAC simulation of system timestep
     183              :         );
     184              : 
     185              :         //==============================================================================
     186              : 
     187              :         void CalcBottomFluxCoefficents(Real64 Tbottom, // current bottom (lower) surface temperature
     188              :                                        Real64 Ttop     // current top (upper) surface temperature
     189              :         );
     190              : 
     191              :         //==============================================================================
     192              : 
     193              :         void CalcTopFluxCoefficents(Real64 Tbottom, // current bottom (lower) surface temperature
     194              :                                     Real64 Ttop     // current top (upper) surface temperature
     195              :         );
     196              : 
     197              :         //==============================================================================
     198              : 
     199              :         void CalcSourceTempCoefficents(Real64 Tbottom, // current bottom (lower) surface temperature
     200              :                                        Real64 Ttop     // current top (upper) surface temperature
     201              :         );
     202              : 
     203              :         //==============================================================================
     204              : 
     205              :         Real64 CalcSourceFlux(EnergyPlusData &state); // component number
     206              : 
     207              :         //==============================================================================
     208              : 
     209              :         void UpdateHistories(Real64 TopFlux,    // current top (top) surface flux
     210              :                              Real64 BottomFlux, // current bottom (bottom) surface flux
     211              :                              Real64 SourceFlux, // current source surface flux
     212              :                              Real64 SourceTemp  // current source temperature
     213              :         );
     214              : 
     215              :         //==============================================================================
     216              : 
     217              :         Real64 CalcHXEffectTerm(EnergyPlusData &state,
     218              :                                 Real64 Temperature,  // Temperature of water entering the surface, in C
     219              :                                 Real64 WaterMassFlow // Mass flow rate, in kg/s
     220              :         );
     221              : 
     222              :         //==============================================================================
     223              : 
     224              :         void CalcTopSurfTemp(Real64 FluxTop,             // top surface flux
     225              :                              Real64 &TempTop,            // top surface temperature
     226              :                              Real64 ThisDryBulb,         // dry bulb temperature
     227              :                              Real64 ThisWetBulb,         // wet bulb temperature
     228              :                              Real64 ThisSkyTemp,         // sky temperature
     229              :                              Real64 ThisBeamSolarRad,    // beam solar radiation
     230              :                              Real64 ThisDifSolarRad,     // diffuse solar radiation
     231              :                              Real64 ThisSolarDirCosVert, // vertical component of solar normal
     232              :                              Real64 ThisWindSpeed,       // wind speed
     233              :                              bool ThisIsRain,            // rain flag
     234              :                              bool ThisIsSnow             // snow flag
     235              :         );
     236              : 
     237              :         //==============================================================================
     238              : 
     239              :         void CalcBottomSurfTemp(Real64 FluxBtm,       // bottom surface flux
     240              :                                 Real64 &TempBtm,      // bottom surface temperature
     241              :                                 Real64 ThisDryBulb,   // dry bulb temperature
     242              :                                 Real64 ThisWindSpeed, // wind speed
     243              :                                 Real64 ThisGroundTemp // ground temperature
     244              :         );
     245              : 
     246              :         //==============================================================================
     247              : 
     248              :         void UpdateSurfaceGroundHeatExchngr(EnergyPlusData &state); // Index for the surface
     249              : 
     250              :         //==============================================================================
     251              : 
     252              :         void ReportSurfaceGroundHeatExchngr(EnergyPlusData &state); // Index for the surface under consideration
     253              : 
     254              :         //==============================================================================
     255              : 
     256              :         void oneTimeInit(EnergyPlusData &state) override; // Empty function for pure virtual oneTimeInitFlag function
     257              : 
     258              :         void oneTimeInit_new(EnergyPlusData &state) override; // Empty function for pure virtual oneTimeInitFlag function
     259              :     };
     260              : 
     261              :     void GetSurfaceGroundHeatExchanger(EnergyPlusData &state);
     262              : 
     263              :     inline std::array<Real64, Construction::MaxCTFTerms>
     264            2 :     eoshiftArray(std::array<Real64, Construction::MaxCTFTerms> const &a, int const shift, Real64 const initialValue)
     265              :     {
     266            2 :         std::array<Real64, Construction::MaxCTFTerms> o = {initialValue};
     267            4 :         int const b(0 + std::max(shift, 0)), e(a.size() - 1 + std::min(shift, 0));
     268           37 :         for (int i = b, j = std::max(0 - shift, 0); i <= e; ++i, ++j) {
     269           35 :             o[j] = a[i];
     270              :         }
     271            2 :         return o;
     272              :     }
     273              :     //==============================================================================
     274              : 
     275              : } // namespace SurfaceGroundHeatExchanger
     276              : 
     277              : struct SurfaceGroundHeatExchangersData : BaseGlobalStruct
     278              : {
     279              : 
     280              :     // utility variables initialized once
     281              :     bool NoSurfaceGroundTempObjWarning = true; // This will cause a warning to be issued if no "surface" ground
     282              :     Real64 FlowRate = 0.0;                     // water mass flow rate
     283              :     Real64 TopSurfTemp = 0.0;                  // Top  surface temperature
     284              :     Real64 BtmSurfTemp = 0.0;                  // Bottom  surface temperature
     285              :     Real64 TopSurfFlux = 0.0;                  // Top  surface heat flux
     286              :     Real64 BtmSurfFlux = 0.0;                  // Bottom  surface heat flux
     287              :     Real64 SourceFlux = 0.0;                   // total heat transfer rate, Watts
     288              :     Array1D_bool CheckEquipName;
     289              : 
     290              :     // weather data records updated every zone time step
     291              :     Real64 PastBeamSolarRad = 0.0;    // Previous beam normal solar irradiance
     292              :     Real64 PastSolarDirCosVert = 0.0; // Previous vertical component of solar normal
     293              :     Real64 PastDifSolarRad = 0.0;     // Previous sky diffuse solar horizontal irradiance
     294              :     Real64 PastGroundTemp = 0.0;      // Previous ground temperature
     295              :     bool PastIsRain = false;          // Previous Surfaces are wet for this time interval
     296              :     bool PastIsSnow = false;          // Previous Snow on the ground for this time interval
     297              :     Real64 PastOutDryBulbTemp = 0.0;  // Previous outdoor air dry bulb temperature
     298              :     Real64 PastOutWetBulbTemp = 0.0;  // Previous outdoor air wet bulb temperature
     299              :     Real64 PastSkyTemp = 0.0;         // Previous sky temperature
     300              :     Real64 PastWindSpeed = 0.0;       // Previous outdoor air wind speed
     301              : 
     302              :     bool GetInputFlag = true;
     303              : 
     304              :     // time keeping variables used for keeping track of average flux over each time step
     305              :     Array1D<Real64> QRadSysSrcAvg;      // Average source over the time step
     306              :     Array1D<Real64> LastSysTimeElapsed; // record of system time
     307              :     Array1D<Real64> LastTimeStepSys;    // previous time step size
     308              :     bool InitializeTempTop = false;
     309              : 
     310              :     Array1D<SurfaceGroundHeatExchanger::SurfaceGroundHeatExchangerData> SurfaceGHE;
     311              :     Real64 FluxTop; // top surface flux
     312              :     Real64 FluxBtm; // bottom surface flux
     313              :     Real64 TempBtm; // bottom surface temp
     314              :     Real64 TempTop; // top surface temp
     315              : 
     316         2126 :     void init_constant_state([[maybe_unused]] EnergyPlusData &state) override
     317              :     {
     318         2126 :     }
     319              : 
     320         1152 :     void init_state([[maybe_unused]] EnergyPlusData &state) override
     321              :     {
     322         1152 :     }
     323              : 
     324         2100 :     void clear_state() override
     325              :     {
     326         2100 :         NoSurfaceGroundTempObjWarning = true;
     327         2100 :         FlowRate = 0.0;
     328         2100 :         TopSurfTemp = 0.0;
     329         2100 :         BtmSurfTemp = 0.0;
     330         2100 :         TopSurfFlux = 0.0;
     331         2100 :         BtmSurfFlux = 0.0;
     332         2100 :         SourceFlux = 0.0;
     333         2100 :         CheckEquipName.clear();
     334         2100 :         PastBeamSolarRad = 0.0;
     335         2100 :         PastSolarDirCosVert = 0.0;
     336         2100 :         PastDifSolarRad = 0.0;
     337         2100 :         PastGroundTemp = 0.0;
     338         2100 :         PastIsRain = false;
     339         2100 :         PastIsSnow = false;
     340         2100 :         PastOutDryBulbTemp = 0.0;
     341         2100 :         PastOutWetBulbTemp = 0.0;
     342         2100 :         PastSkyTemp = 0.0;
     343         2100 :         PastWindSpeed = 0.0;
     344         2100 :         GetInputFlag = true;
     345         2100 :         QRadSysSrcAvg.clear();
     346         2100 :         LastSysTimeElapsed.clear();
     347         2100 :         LastTimeStepSys.clear();
     348         2100 :         InitializeTempTop = false;
     349         2100 :         SurfaceGHE.clear();
     350         2100 :     }
     351              : 
     352              :     // Default Constructor
     353         2129 :     SurfaceGroundHeatExchangersData() = default;
     354              : };
     355              : } // namespace EnergyPlus
     356              : 
     357              : #endif
        

Generated by: LCOV version 2.0-1