LCOV - code coverage report
Current view: top level - EnergyPlus - PipeHeatTransfer.hh (source / functions) Hit Total Coverage
Test: lcov.output.filtered Lines: 7 25 28.0 %
Date: 2023-01-17 19:17:23 Functions: 5 8 62.5 %

          Line data    Source code
       1             : // EnergyPlus, Copyright (c) 1996-2023, 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 PipeHeatTransfer_hh_INCLUDED
      49             : #define PipeHeatTransfer_hh_INCLUDED
      50             : 
      51             : // C++ Headers
      52             : #include <memory>
      53             : 
      54             : // ObjexxFCL Headers
      55             : #include <ObjexxFCL/Array1D.hh>
      56             : #include <ObjexxFCL/Array4D.hh>
      57             : #include <ObjexxFCL/Optional.hh>
      58             : 
      59             : // EnergyPlus Headers
      60             : #include <EnergyPlus/Data/BaseData.hh>
      61             : #include <EnergyPlus/DataGlobals.hh>
      62             : #include <EnergyPlus/EnergyPlus.hh>
      63             : #include <EnergyPlus/GroundTemperatureModeling/GroundTemperatureModelManager.hh>
      64             : #include <EnergyPlus/Plant/Enums.hh>
      65             : #include <EnergyPlus/Plant/PlantLocation.hh>
      66             : #include <EnergyPlus/PlantComponent.hh>
      67             : 
      68             : namespace EnergyPlus {
      69             : 
      70             : // Forward declarations
      71             : struct EnergyPlusData;
      72             : 
      73             : namespace PipeHeatTransfer {
      74             : 
      75             :     // Using/Aliasing
      76             :     using namespace GroundTemperatureManager;
      77             : 
      78             :     enum class EnvrnPtr
      79             :     {
      80             :         Invalid = -1,
      81             :         None,
      82             :         ZoneEnv,
      83             :         ScheduleEnv,
      84             :         OutsideAirEnv,
      85             :         GroundEnv,
      86             :         Num
      87             :     };
      88             : 
      89             :     enum TimeIndex
      90             :     {
      91             :         Invalid = -1,
      92             :         Previous = 1,
      93             :         Current,
      94             :         Tentative
      95             :     };
      96             : 
      97             :     constexpr Real64 InnerDeltaTime(60.0); // one minute time step in seconds
      98             : 
      99           4 :     struct PipeHTData : public PlantComponent
     100             :     {
     101             : 
     102           8 :         virtual ~PipeHTData() = default;
     103             : 
     104             :         // Members
     105             :         // Input data
     106             :         std::string Name;
     107             :         std::string Construction;           // construction object name
     108             :         std::string Environment;            // keyword:  'Schedule', 'OutdoorAir', 'Zone'
     109             :         std::string EnvrSchedule;           // temperature schedule for environmental temp
     110             :         std::string EnvrVelSchedule;        // temperature schedule for environmental temp
     111             :         std::string EnvrAirNode;            // outside air node providing environmental temp
     112             :         Real64 Length;                      // total pipe length [m]
     113             :         Real64 PipeID;                      // pipe inside diameter [m]
     114             :         std::string InletNode;              // inlet node name
     115             :         std::string OutletNode;             // outlet node name
     116             :         int InletNodeNum;                   // inlet node number
     117             :         int OutletNodeNum;                  // outlet node number
     118             :         DataPlant::PlantEquipmentType Type; // Type of pipe
     119             :         // derived data
     120             :         int ConstructionNum; // construction ref number
     121             :         EnvrnPtr EnvironmentPtr;
     122             :         int EnvrSchedPtr;              // pointer to schedule used to set environmental temp
     123             :         int EnvrVelSchedPtr;           // pointer to schedule used to set environmental temp
     124             :         int EnvrZonePtr;               // pointer to zone number used to set environmental temp
     125             :         int EnvrAirNodeNum;            // pointer to outside air node used to set environmental temp
     126             :         int NumSections;               // total number of nodes along pipe length
     127             :         Real64 FluidSpecHeat;          // fluid Cp [J/kg.K]
     128             :         Real64 FluidDensity;           // density [kg/m3]
     129             :         Real64 MaxFlowRate;            // max flow rate (from loop/node data)
     130             :         Real64 InsideArea;             // pipe section inside surface area [m^2]
     131             :         Real64 OutsideArea;            // pipe section outside surface area [m^2]
     132             :         Real64 SectionArea;            // cross sectional area [m^2]
     133             :         Real64 PipeHeatCapacity;       // heat capacity of pipe section [J/m.K]
     134             :         Real64 PipeOD;                 // pipe outside diameter [m]
     135             :         Real64 PipeCp;                 // pipe materail Cp [J/kg.K]
     136             :         Real64 PipeDensity;            // pipe material density [kg/m3]
     137             :         Real64 PipeConductivity;       // pipe material thermal conductivity [W/m.K]
     138             :         Real64 InsulationOD;           // insulation outside diameter [m]
     139             :         Real64 InsulationCp;           // insulation  specific heat [J/kg.K]
     140             :         Real64 InsulationDensity;      // insulation density [kg/m3]
     141             :         Real64 InsulationConductivity; // insulation conductivity [W/m.K]
     142             :         Real64 InsulationThickness;    // insulation thickness [m]
     143             :         Real64 InsulationResistance;   // Insulation thermal resistance [m2.K/W]
     144             :         Real64 CurrentSimTime;         // Current simulation time [hr]
     145             :         Real64 PreviousSimTime;        // simulation time the report data was last updated
     146             :         Array1D<Real64> TentativeFluidTemp;
     147             :         Array1D<Real64> FluidTemp; // arrays for fluid and pipe temperatures at each node
     148             :         Array1D<Real64> PreviousFluidTemp;
     149             :         Array1D<Real64> TentativePipeTemp;
     150             :         Array1D<Real64> PipeTemp;
     151             :         Array1D<Real64> PreviousPipeTemp;
     152             :         int NumDepthNodes;                            // number of soil grid points in the depth direction
     153             :         int PipeNodeDepth;                            // soil depth grid point where pipe is located
     154             :         int PipeNodeWidth;                            // soil width grid point where pipe is located
     155             :         Real64 PipeDepth;                             // pipe burial depth [m]
     156             :         Real64 DomainDepth;                           // soil grid depth [m]
     157             :         Real64 dSregular;                             // grid spacing in cartesian domain [m]
     158             :         Real64 OutdoorConvCoef;                       // soil to air convection coefficient [W/m2.K]
     159             :         std::string SoilMaterial;                     // name of soil material:regular object
     160             :         int SoilMaterialNum;                          // soil material index in material data structure
     161             :         int MonthOfMinSurfTemp;                       // month of minimum ground surface temperature
     162             :         Real64 MinSurfTemp;                           // minimum annual surface temperature [C]
     163             :         Real64 SoilDensity;                           // density of soil [kg/m3]
     164             :         Real64 SoilDepth;                             // thickness of soil [m]
     165             :         Real64 SoilCp;                                // specific heat of soil [J/kg.K]
     166             :         Real64 SoilConductivity;                      // thermal conductivity of soil [W/m.K]
     167             :         DataSurfaces::SurfaceRoughness SoilRoughness; // ground surface roughness
     168             :         Real64 SoilThermAbs;                          // ground surface thermal absorptivity
     169             :         Real64 SoilSolarAbs;                          // ground surface solar absorptivity
     170             :         Real64 CoefA1;                                // soil finite difference coefficient
     171             :         Real64 CoefA2;                                // soil finite difference coefficient
     172             :         Real64 FourierDS;                             // soil Fourier number based on grid spacing
     173             :         Real64 SoilDiffusivity;                       // soil thermal diffusivity [m2/s]
     174             :         Real64 SoilDiffusivityPerDay;                 // soil thermal diffusivity [m2/day]
     175             :         Array4D<Real64> T;                            // soil temperature array
     176             :         bool BeginSimInit;                            // begin sim and begin environment flag
     177             :         bool BeginSimEnvrn;                           // begin sim and begin environment flag
     178             :         bool FirstHVACupdateFlag;
     179             :         bool BeginEnvrnupdateFlag;
     180             :         bool SolarExposed;       // Flag to determine if solar is included at ground surface
     181             :         Real64 SumTK;            // Sum of thickness/conductivity over all material layers
     182             :         Real64 ZoneHeatGainRate; // Lagged energy summation for zone heat gain {W}
     183             :         PlantLocation plantLoc;
     184             :         bool CheckEquipName;
     185             :         std::shared_ptr<BaseGroundTempsModel> groundTempModel;
     186             : 
     187             :         // Report data
     188             :         Real64 FluidInletTemp;          // inlet temperature [C]
     189             :         Real64 FluidOutletTemp;         // outlet temperature [C]
     190             :         Real64 MassFlowRate;            // mass flow rate [kg/s]
     191             :         Real64 FluidHeatLossRate;       // overall heat transfer rate from fluid to pipe [W]
     192             :         Real64 FluidHeatLossEnergy;     // energy transferred from fluid to pipe [J]
     193             :         Real64 PipeInletTemp;           // pipe temperature at inlet [C]
     194             :         Real64 PipeOutletTemp;          // pipe temperature at Oulet [C]
     195             :         Real64 EnvironmentHeatLossRate; // overall heat transfer rate from pipe to environment [W]
     196             :         Real64 EnvHeatLossEnergy;       // energy transferred from pipe to environment [J]
     197             :         Real64 VolumeFlowRate;
     198             : 
     199             :         // Default Constructor
     200           4 :         PipeHTData()
     201           4 :             : Length(0.0), PipeID(0.0), InletNodeNum(0), OutletNodeNum(0), Type(DataPlant::PlantEquipmentType::Invalid), ConstructionNum(0),
     202             :               EnvironmentPtr(EnvrnPtr::None), EnvrSchedPtr(0), EnvrVelSchedPtr(0), EnvrZonePtr(0), EnvrAirNodeNum(0), NumSections(0),
     203             :               FluidSpecHeat(0.0), FluidDensity(0.0), MaxFlowRate(0.0), InsideArea(0.0), OutsideArea(0.0), SectionArea(0.0), PipeHeatCapacity(0.0),
     204             :               PipeOD(0.0), PipeCp(0.0), PipeDensity(0.0), PipeConductivity(0.0), InsulationOD(0.0), InsulationCp(0.0), InsulationDensity(0.0),
     205             :               InsulationConductivity(0.0), InsulationThickness(0.0), InsulationResistance(0.0), CurrentSimTime(0.0), PreviousSimTime(0.0),
     206             :               NumDepthNodes(0), PipeNodeDepth(0), PipeNodeWidth(0), PipeDepth(0.0), DomainDepth(0.0), dSregular(0.0), OutdoorConvCoef(0.0),
     207             :               SoilMaterialNum(0), MonthOfMinSurfTemp(0), MinSurfTemp(0.0), SoilDensity(0.0), SoilDepth(0.0), SoilCp(0.0), SoilConductivity(0.0),
     208             :               SoilRoughness(DataSurfaces::SurfaceRoughness::Invalid), SoilThermAbs(0.0), SoilSolarAbs(0.0), CoefA1(0.0), CoefA2(0.0), FourierDS(0.0),
     209             :               SoilDiffusivity(0.0), SoilDiffusivityPerDay(0.0), BeginSimInit(true), BeginSimEnvrn(true), FirstHVACupdateFlag(true),
     210             :               BeginEnvrnupdateFlag(true), SolarExposed(true), SumTK(0.0), ZoneHeatGainRate(0.0), plantLoc{}, CheckEquipName(true),
     211             :               FluidInletTemp(0.0), FluidOutletTemp(0.0), MassFlowRate(0.0), FluidHeatLossRate(0.0), FluidHeatLossEnergy(0.0), PipeInletTemp(0.0),
     212           4 :               PipeOutletTemp(0.0), EnvironmentHeatLossRate(0.0), EnvHeatLossEnergy(0.0), VolumeFlowRate(0.0)
     213             : 
     214             :         {
     215           4 :         }
     216             : 
     217             :         static PlantComponent *factory(EnergyPlusData &state, DataPlant::PlantEquipmentType objectType, std::string const &objectName);
     218             : 
     219             :         void simulate([[maybe_unused]] EnergyPlusData &state,
     220             :                       const PlantLocation &calledFromLocation,
     221             :                       bool FirstHVACIteration,
     222             :                       Real64 &CurLoad,
     223             :                       bool RunFlag) override;
     224             : 
     225             :         void PushInnerTimeStepArrays();
     226             : 
     227             :         void oneTimeInit_new(EnergyPlusData &state) override;
     228             : 
     229             :         void oneTimeInit(EnergyPlusData &state) override;
     230             : 
     231             :         void InitPipesHeatTransfer(EnergyPlusData &state, bool FirstHVACIteration);
     232             : 
     233             :         Real64 TBND(EnergyPlusData &state,
     234             :                     Real64 z // Current Depth
     235             :         );
     236             : 
     237             :         void CalcBuriedPipeSoil(EnergyPlusData &state);
     238             : 
     239             :         void CalcPipesHeatTransfer(EnergyPlusData &state, Optional_int_const LengthIndex = _);
     240             : 
     241             :         Real64 OutsidePipeHeatTransCoef(EnergyPlusData &state);
     242             : 
     243             :         Real64 CalcPipeHeatTransCoef(EnergyPlusData &state,
     244             :                                      Real64 Temperature,  // Temperature of water entering the surface, in C
     245             :                                      Real64 MassFlowRate, // Mass flow rate, in kg/s
     246             :                                      Real64 Diameter      // Pipe diameter, m
     247             :         );
     248             : 
     249             :         void ReportPipesHeatTransfer(EnergyPlusData &state); // Index for the surface under consideration
     250             : 
     251             :         void UpdatePipesHeatTransfer(EnergyPlusData &state);
     252             : 
     253             :         void ValidatePipeConstruction(EnergyPlusData &state,
     254             :                                       std::string const &PipeType,         // module object of pipe (error messages)
     255             :                                       std::string const &ConstructionName, // construction name of pipe (error messages)
     256             :                                       std::string_view FieldName,          // fieldname of pipe (error messages)
     257             :                                       int ConstructionNum,                 // pointer into construction data
     258             :                                       bool &ErrorsFound                    // set to true if errors found here
     259             :         );
     260             : 
     261             :         static void CalcZonePipesHeatGain(EnergyPlusData &state);
     262             :     };
     263             : 
     264             :     void GetPipesHeatTransfer(EnergyPlusData &state);
     265             : 
     266             : } // namespace PipeHeatTransfer
     267             : 
     268        1542 : struct PipeHeatTransferData : BaseGlobalStruct
     269             : {
     270             : 
     271             :     int nsvNumOfPipeHT = 0;            // Number of Pipe Heat Transfer objects
     272             :     int nsvInletNodeNum = 0;           // module variable for inlet node number
     273             :     int nsvOutletNodeNum = 0;          // module variable for outlet node number
     274             :     Real64 nsvMassFlowRate = 0.0;      // pipe mass flow rate
     275             :     Real64 nsvVolumeFlowRate = 0.0;    // pipe volumetric flow rate
     276             :     Real64 nsvDeltaTime = 0.0;         // time change from last update
     277             :     Real64 nsvInletTemp = 0.0;         // pipe inlet temperature
     278             :     Real64 nsvOutletTemp = 0.0;        // pipe outlet temperature
     279             :     Real64 nsvEnvironmentTemp = 0.0;   // environmental temperature (surrounding pipe)
     280             :     Real64 nsvEnvHeatLossRate = 0.0;   // heat loss rate from pipe to the environment
     281             :     Real64 nsvFluidHeatLossRate = 0.0; // overall heat loss from fluid to pipe
     282             :     int nsvNumInnerTimeSteps = 0;      // the number of "inner" time steps for our model
     283             :     bool GetPipeInputFlag = true;      // First time, input is "gotten"
     284             :     bool MyEnvrnFlag = true;
     285             :     Array1D<PipeHeatTransfer::PipeHTData> PipeHT;
     286             :     std::unordered_map<std::string, std::string> PipeHTUniqueNames;
     287             : 
     288           0 :     void clear_state() override
     289             :     {
     290           0 :         this->nsvNumOfPipeHT = 0;
     291           0 :         this->nsvInletNodeNum = 0;
     292           0 :         this->nsvOutletNodeNum = 0;
     293           0 :         this->nsvMassFlowRate = 0.0;
     294           0 :         this->nsvVolumeFlowRate = 0.0;
     295           0 :         this->nsvDeltaTime = 0.0;
     296           0 :         this->nsvInletTemp = 0.0;
     297           0 :         this->nsvOutletTemp = 0.0;
     298           0 :         this->nsvEnvironmentTemp = 0.0;
     299           0 :         this->nsvEnvHeatLossRate = 0.0;
     300           0 :         this->nsvFluidHeatLossRate = 0.0;
     301           0 :         this->nsvNumInnerTimeSteps = 0;
     302           0 :         this->GetPipeInputFlag = true;
     303           0 :         this->MyEnvrnFlag = true;
     304           0 :         this->PipeHT.deallocate();
     305           0 :         this->PipeHTUniqueNames.clear();
     306           0 :     }
     307             : };
     308             : 
     309             : } // namespace EnergyPlus
     310             : 
     311             : #endif

Generated by: LCOV version 1.13