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