LCOV - code coverage report
Current view: top level - EnergyPlus - PipeHeatTransfer.hh (source / functions) Hit Total Coverage
Test: lcov.output.filtered Lines: 17 35 48.6 %
Date: 2024-08-24 18:31:18 Functions: 3 5 60.0 %

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

Generated by: LCOV version 1.14