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 : // C++ Headers
49 : #include <cmath>
50 : #include <memory>
51 :
52 : // ObjexxFCL Headers
53 : #include <ObjexxFCL/Array.functions.hh>
54 : #include <ObjexxFCL/Array3D.hh>
55 : #include <ObjexxFCL/Fmath.hh>
56 :
57 : // EnergyPlus Headers
58 : #include <EnergyPlus/BranchNodeConnections.hh>
59 : #include <EnergyPlus/Construction.hh>
60 : #include <EnergyPlus/ConvectionCoefficients.hh>
61 : #include <EnergyPlus/Data/EnergyPlusData.hh>
62 : #include <EnergyPlus/DataEnvironment.hh>
63 : #include <EnergyPlus/DataHVACGlobals.hh>
64 : #include <EnergyPlus/DataHeatBalance.hh>
65 : #include <EnergyPlus/DataIPShortCuts.hh>
66 : #include <EnergyPlus/DataLoopNode.hh>
67 : #include <EnergyPlus/FluidProperties.hh>
68 : #include <EnergyPlus/General.hh>
69 : #include <EnergyPlus/GlobalNames.hh>
70 : #include <EnergyPlus/GroundTemperatureModeling/GroundTemperatureModelManager.hh>
71 : #include <EnergyPlus/HeatBalanceInternalHeatGains.hh>
72 : #include <EnergyPlus/InputProcessing/InputProcessor.hh>
73 : #include <EnergyPlus/Material.hh>
74 : #include <EnergyPlus/NodeInputManager.hh>
75 : #include <EnergyPlus/OutAirNodeManager.hh>
76 : #include <EnergyPlus/OutputProcessor.hh>
77 : #include <EnergyPlus/PipeHeatTransfer.hh>
78 : #include <EnergyPlus/Plant/DataPlant.hh>
79 : #include <EnergyPlus/PlantUtilities.hh>
80 : #include <EnergyPlus/ScheduleManager.hh>
81 : #include <EnergyPlus/UtilityRoutines.hh>
82 : #include <EnergyPlus/ZoneTempPredictorCorrector.hh>
83 :
84 : namespace EnergyPlus::PipeHeatTransfer {
85 :
86 : // Module containing the routines dealing with pipes with transport delay
87 : // and heat transfer.
88 :
89 : // MODULE INFORMATION:
90 : // AUTHOR Simon Rees
91 : // DATE WRITTEN July 2007
92 : // MODIFIED May 2008
93 : // RE-ENGINEERED na
94 :
95 : // PURPOSE OF THIS MODULE:
96 : // The purpose of this module is to simulate a pipe with heat transfer
97 :
98 : // METHODOLOGY EMPLOYED:
99 : // An implicit finite difference method is used to solve the temperature distribution of the
100 : // fluid in the pipe as a result of the transport delay and heat transfer to the environment.
101 : // For buried pipes, the simulation involves an implicit finite difference model of the soil,
102 : // which was originally based on Piechowski's thesis (below). Equation numbers for
103 : // pipe:underground calculations are from Piechowski's thesis. In Piechowski, the near-pipe
104 : // region is solved with a detailed finite difference grid, this current model makes use of
105 : // the Hanby model to simulate the actual pipe.
106 :
107 : // Kusuda, T. & Achenbach, P. (1965), 'Earth temperature and thermal diffusivity at
108 : // selected stations in the united states', ASHRAE Transactions 71(1), 61-75.
109 : // Piechowski, M. (1996), A Ground Coupled Heat Pump System with Energy Storage,
110 : // PhD thesis, University of Melbourne.
111 :
112 : // OTHER NOTES: Equation Numbers listed in buried pipe routines are from Piechowski's thesis
113 :
114 : enum class PipeIndoorBoundaryType
115 : {
116 : Invalid = -1,
117 : Zone,
118 : Schedule,
119 : Num
120 : };
121 : constexpr std::array<std::string_view, static_cast<int>(PipeIndoorBoundaryType::Num)> pipeIndoorBoundaryTypeNamesUC = {"ZONE", "SCHEDULE"};
122 :
123 : // Using/Aliasing
124 : using namespace GroundTemperatureManager;
125 :
126 : // Functions
127 :
128 4 : PlantComponent *PipeHTData::factory(EnergyPlusData &state, DataPlant::PlantEquipmentType objectType, std::string const &objectName)
129 : {
130 : // Process the input data for pipes if it hasn't been done already
131 4 : if (state.dataPipeHT->GetPipeInputFlag) {
132 4 : GetPipesHeatTransfer(state);
133 4 : state.dataPipeHT->GetPipeInputFlag = false;
134 : }
135 : // Now look for this particular pipe in the list
136 4 : for (auto &pipe : state.dataPipeHT->PipeHT) {
137 4 : if (pipe.Type == objectType && pipe.Name == objectName) {
138 4 : return &pipe;
139 : }
140 : }
141 : // If we didn't find it, fatal
142 0 : ShowFatalError(state, format("PipeHTFactory: Error getting inputs for pipe named: {}", objectName));
143 : // Shut up the compiler
144 0 : return nullptr;
145 : }
146 :
147 58100 : void PipeHTData::simulate(EnergyPlusData &state,
148 : [[maybe_unused]] const PlantLocation &calledFromLocation,
149 : bool const FirstHVACIteration,
150 : [[maybe_unused]] Real64 &CurLoad,
151 : [[maybe_unused]] bool const RunFlag)
152 : {
153 58100 : this->InitPipesHeatTransfer(state, FirstHVACIteration);
154 : // make the calculations
155 802816 : for (int InnerTimeStepCtr = 1; InnerTimeStepCtr <= state.dataPipeHT->nsvNumInnerTimeSteps; ++InnerTimeStepCtr) {
156 744716 : switch (this->EnvironmentPtr) {
157 186179 : case EnvrnPtr::GroundEnv: {
158 186179 : this->CalcBuriedPipeSoil(state);
159 186179 : } break;
160 558537 : default: {
161 558537 : this->CalcPipesHeatTransfer(state);
162 558537 : } break;
163 : }
164 744716 : this->PushInnerTimeStepArrays();
165 : }
166 : // update variables
167 58100 : this->UpdatePipesHeatTransfer(state);
168 : // update report variables
169 58100 : this->ReportPipesHeatTransfer(state);
170 58100 : }
171 :
172 744716 : void PipeHTData::PushInnerTimeStepArrays()
173 : {
174 744716 : if (this->EnvironmentPtr == EnvrnPtr::GroundEnv) {
175 3723580 : for (int LengthIndex = 2; LengthIndex <= this->NumSections; ++LengthIndex) {
176 31836609 : for (int DepthIndex = 1; DepthIndex <= this->NumDepthNodes; ++DepthIndex) {
177 113196832 : for (int WidthIndex = 2; WidthIndex <= this->PipeNodeWidth; ++WidthIndex) {
178 : // This will store the old 'current' values as the new 'previous values' This allows
179 : // us to use the previous time array as history terms in the equations
180 84897624 : this->T(WidthIndex, DepthIndex, LengthIndex, TimeIndex::Previous) =
181 84897624 : this->T(WidthIndex, DepthIndex, LengthIndex, TimeIndex::Current);
182 : }
183 : }
184 : }
185 : }
186 : // Then update the Hanby near pipe model temperatures
187 744716 : this->PreviousFluidTemp = this->FluidTemp;
188 744716 : this->PreviousPipeTemp = this->PipeTemp;
189 744716 : }
190 :
191 4 : void GetPipesHeatTransfer(EnergyPlusData &state)
192 : {
193 :
194 : // SUBROUTINE INFORMATION:
195 : // AUTHOR Simon Rees
196 : // DATE WRITTEN July 2007
197 : // MODIFIED na
198 : // RE-ENGINEERED na
199 : // PURPOSE OF THIS SUBROUTINE:
200 : // This subroutine reads the input for hydronic Pipe Heat Transfers
201 : // from the user input file. This will contain all of the information
202 : // needed to define and simulate the surface.
203 :
204 : // Using/Aliasing
205 : using BranchNodeConnections::TestCompSet;
206 :
207 : using NodeInputManager::GetOnlySingleNode;
208 : using namespace DataLoopNode;
209 : using OutAirNodeManager::CheckOutAirNodeNumber;
210 : using ScheduleManager::GetScheduleIndex;
211 :
212 : // SUBROUTINE PARAMETER DEFINITIONS:
213 4 : int constexpr NumPipeSections(20);
214 4 : int constexpr NumberOfDepthNodes(8); // Number of nodes in the cartesian grid-Should be an even # for now
215 4 : Real64 const SecondsInHour(Constant::SecInHour);
216 :
217 : // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
218 4 : bool ErrorsFound(false); // Set to true if errors in input,
219 :
220 : // fatal at end of routine
221 : int IOStatus; // Used in GetObjectItem
222 : int Item; // Item to be "gotten"
223 : int PipeItem;
224 : int NumAlphas; // Number of Alphas for each GetObjectItem call
225 : int NumNumbers; // Number of Numbers for each GetObjectItem call
226 : int NumOfPipeHTInt; // Number of Pipe Heat Transfer objects
227 : int NumOfPipeHTExt; // Number of Pipe Heat Transfer objects
228 : int NumOfPipeHTUG; // Number of Pipe Heat Transfer objects
229 : int NumSections; // total number of sections in pipe
230 4 : auto &cCurrentModuleObject = state.dataIPShortCut->cCurrentModuleObject;
231 : // Initializations and allocations
232 4 : cCurrentModuleObject = "Pipe:Indoor";
233 4 : NumOfPipeHTInt = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject);
234 4 : cCurrentModuleObject = "Pipe:Outdoor";
235 4 : NumOfPipeHTExt = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject);
236 4 : cCurrentModuleObject = "Pipe:Underground";
237 4 : NumOfPipeHTUG = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject);
238 :
239 4 : state.dataPipeHT->nsvNumOfPipeHT = NumOfPipeHTInt + NumOfPipeHTExt + NumOfPipeHTUG;
240 : // allocate data structures
241 4 : if (allocated(state.dataPipeHT->PipeHT)) state.dataPipeHT->PipeHT.deallocate();
242 :
243 4 : state.dataPipeHT->PipeHT.allocate(state.dataPipeHT->nsvNumOfPipeHT);
244 4 : state.dataPipeHT->PipeHTUniqueNames.reserve(static_cast<unsigned>(state.dataPipeHT->nsvNumOfPipeHT));
245 4 : Item = 0;
246 :
247 4 : cCurrentModuleObject = "Pipe:Indoor";
248 6 : for (PipeItem = 1; PipeItem <= NumOfPipeHTInt; ++PipeItem) {
249 2 : ++Item;
250 : // get the object name
251 4 : state.dataInputProcessing->inputProcessor->getObjectItem(state,
252 : cCurrentModuleObject,
253 : PipeItem,
254 2 : state.dataIPShortCut->cAlphaArgs,
255 : NumAlphas,
256 2 : state.dataIPShortCut->rNumericArgs,
257 : NumNumbers,
258 : IOStatus,
259 2 : state.dataIPShortCut->lNumericFieldBlanks,
260 2 : state.dataIPShortCut->lAlphaFieldBlanks,
261 2 : state.dataIPShortCut->cAlphaFieldNames,
262 2 : state.dataIPShortCut->cNumericFieldNames);
263 :
264 2 : GlobalNames::VerifyUniqueInterObjectName(state,
265 2 : state.dataPipeHT->PipeHTUniqueNames,
266 2 : state.dataIPShortCut->cAlphaArgs(1),
267 : cCurrentModuleObject,
268 2 : state.dataIPShortCut->cAlphaFieldNames(1),
269 : ErrorsFound);
270 2 : state.dataPipeHT->PipeHT(Item).Name = state.dataIPShortCut->cAlphaArgs(1);
271 2 : state.dataPipeHT->PipeHT(Item).Type = DataPlant::PlantEquipmentType::PipeInterior;
272 :
273 : // General user input data
274 2 : state.dataPipeHT->PipeHT(Item).Construction = state.dataIPShortCut->cAlphaArgs(2);
275 2 : state.dataPipeHT->PipeHT(Item).ConstructionNum = Util::FindItemInList(state.dataIPShortCut->cAlphaArgs(2), state.dataConstruction->Construct);
276 :
277 2 : if (state.dataPipeHT->PipeHT(Item).ConstructionNum == 0) {
278 0 : ShowSevereError(state, format("Invalid {}={}", state.dataIPShortCut->cAlphaFieldNames(2), state.dataIPShortCut->cAlphaArgs(2)));
279 0 : ShowContinueError(state, format("Entered in {}={}", cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)));
280 0 : ErrorsFound = true;
281 : }
282 :
283 : // get inlet node data
284 2 : state.dataPipeHT->PipeHT(Item).InletNode = state.dataIPShortCut->cAlphaArgs(3);
285 4 : state.dataPipeHT->PipeHT(Item).InletNodeNum = GetOnlySingleNode(state,
286 2 : state.dataIPShortCut->cAlphaArgs(3),
287 : ErrorsFound,
288 : DataLoopNode::ConnectionObjectType::PipeIndoor,
289 2 : state.dataIPShortCut->cAlphaArgs(1),
290 : DataLoopNode::NodeFluidType::Water,
291 : DataLoopNode::ConnectionType::Inlet,
292 : NodeInputManager::CompFluidStream::Primary,
293 : ObjectIsNotParent);
294 2 : if (state.dataPipeHT->PipeHT(Item).InletNodeNum == 0) {
295 0 : ShowSevereError(state, format("Invalid {}={}", state.dataIPShortCut->cAlphaFieldNames(3), state.dataIPShortCut->cAlphaArgs(3)));
296 0 : ShowContinueError(state, format("Entered in {}={}", cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)));
297 0 : ErrorsFound = true;
298 : }
299 :
300 : // get outlet node data
301 2 : state.dataPipeHT->PipeHT(Item).OutletNode = state.dataIPShortCut->cAlphaArgs(4);
302 4 : state.dataPipeHT->PipeHT(Item).OutletNodeNum = GetOnlySingleNode(state,
303 2 : state.dataIPShortCut->cAlphaArgs(4),
304 : ErrorsFound,
305 : DataLoopNode::ConnectionObjectType::PipeIndoor,
306 2 : state.dataIPShortCut->cAlphaArgs(1),
307 : DataLoopNode::NodeFluidType::Water,
308 : DataLoopNode::ConnectionType::Outlet,
309 : NodeInputManager::CompFluidStream::Primary,
310 : ObjectIsNotParent);
311 2 : if (state.dataPipeHT->PipeHT(Item).OutletNodeNum == 0) {
312 0 : ShowSevereError(state, format("Invalid {}={}", state.dataIPShortCut->cAlphaFieldNames(4), state.dataIPShortCut->cAlphaArgs(4)));
313 0 : ShowContinueError(state, format("Entered in {}={}", cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)));
314 0 : ErrorsFound = true;
315 : }
316 :
317 4 : TestCompSet(state,
318 : cCurrentModuleObject,
319 2 : state.dataIPShortCut->cAlphaArgs(1),
320 2 : state.dataIPShortCut->cAlphaArgs(3),
321 2 : state.dataIPShortCut->cAlphaArgs(4),
322 : "Pipe Nodes");
323 :
324 : // get environmental boundary condition type
325 :
326 2 : if (state.dataIPShortCut->lAlphaFieldBlanks(5)) state.dataIPShortCut->cAlphaArgs(5) = "ZONE";
327 :
328 : PipeIndoorBoundaryType indoorType =
329 2 : static_cast<PipeIndoorBoundaryType>(getEnumValue(pipeIndoorBoundaryTypeNamesUC, state.dataIPShortCut->cAlphaArgs(5)));
330 2 : switch (indoorType) {
331 1 : case PipeIndoorBoundaryType::Zone:
332 1 : state.dataPipeHT->PipeHT(Item).EnvironmentPtr = EnvrnPtr::ZoneEnv;
333 1 : state.dataPipeHT->PipeHT(Item).EnvrZonePtr = Util::FindItemInList(state.dataIPShortCut->cAlphaArgs(6), state.dataHeatBal->Zone);
334 1 : if (state.dataPipeHT->PipeHT(Item).EnvrZonePtr == 0) {
335 0 : ShowSevereError(state, format("Invalid {}={}", state.dataIPShortCut->cAlphaFieldNames(6), state.dataIPShortCut->cAlphaArgs(6)));
336 0 : ShowContinueError(state, format("Entered in {}={}", cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)));
337 0 : ErrorsFound = true;
338 : }
339 1 : break;
340 :
341 1 : case PipeIndoorBoundaryType::Schedule:
342 1 : state.dataPipeHT->PipeHT(Item).EnvironmentPtr = EnvrnPtr::ScheduleEnv;
343 1 : state.dataPipeHT->PipeHT(Item).EnvrSchedule = state.dataIPShortCut->cAlphaArgs(7);
344 1 : state.dataPipeHT->PipeHT(Item).EnvrSchedPtr = GetScheduleIndex(state, state.dataPipeHT->PipeHT(Item).EnvrSchedule);
345 1 : state.dataPipeHT->PipeHT(Item).EnvrVelSchedule = state.dataIPShortCut->cAlphaArgs(8);
346 1 : state.dataPipeHT->PipeHT(Item).EnvrVelSchedPtr = GetScheduleIndex(state, state.dataPipeHT->PipeHT(Item).EnvrVelSchedule);
347 1 : if (state.dataPipeHT->PipeHT(Item).EnvrSchedPtr == 0) {
348 0 : ShowSevereError(state, format("Invalid {}={}", state.dataIPShortCut->cAlphaFieldNames(7), state.dataIPShortCut->cAlphaArgs(7)));
349 0 : ShowContinueError(state, format("Entered in {}={}", cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)));
350 0 : ErrorsFound = true;
351 : }
352 1 : if (state.dataPipeHT->PipeHT(Item).EnvrVelSchedPtr == 0) {
353 0 : ShowSevereError(state, format("Invalid {}={}", state.dataIPShortCut->cAlphaFieldNames(8), state.dataIPShortCut->cAlphaArgs(8)));
354 0 : ShowContinueError(state, format("Entered in {}={}", cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)));
355 0 : ErrorsFound = true;
356 : }
357 1 : break;
358 :
359 0 : default:
360 0 : ShowSevereError(state, format("Invalid {}={}", state.dataIPShortCut->cAlphaFieldNames(5), state.dataIPShortCut->cAlphaArgs(5)));
361 0 : ShowContinueError(state, format("Entered in {}={}", cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)));
362 0 : ShowContinueError(state, R"(Should be "ZONE" or "SCHEDULE")"); // TODO rename point
363 0 : ErrorsFound = true;
364 : }
365 :
366 : // dimensions
367 2 : state.dataPipeHT->PipeHT(Item).PipeID = state.dataIPShortCut->rNumericArgs(1);
368 2 : if (state.dataIPShortCut->rNumericArgs(1) <= 0.0) { // not really necessary because idd field has "minimum> 0"
369 0 : ShowSevereError(state,
370 0 : format("GetPipesHeatTransfer: invalid {} of {:.4R}",
371 0 : state.dataIPShortCut->cNumericFieldNames(1),
372 0 : state.dataIPShortCut->rNumericArgs(1)));
373 0 : ShowContinueError(state, format("{} must be > 0.0", state.dataIPShortCut->cNumericFieldNames(1)));
374 0 : ShowContinueError(state, format("Entered in {}={}", cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)));
375 :
376 0 : ErrorsFound = true;
377 : }
378 :
379 2 : state.dataPipeHT->PipeHT(Item).Length = state.dataIPShortCut->rNumericArgs(2);
380 2 : if (state.dataIPShortCut->rNumericArgs(2) <= 0.0) { // not really necessary because idd field has "minimum> 0"
381 0 : ShowSevereError(state,
382 0 : format("GetPipesHeatTransfer: invalid {} of {:.4R}",
383 0 : state.dataIPShortCut->cNumericFieldNames(2),
384 0 : state.dataIPShortCut->rNumericArgs(2)));
385 0 : ShowContinueError(state, format("{} must be > 0.0", state.dataIPShortCut->cNumericFieldNames(2)));
386 0 : ShowContinueError(state, format("Entered in {}={}", cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)));
387 0 : ErrorsFound = true;
388 : }
389 :
390 2 : if (state.dataPipeHT->PipeHT(Item).ConstructionNum != 0) {
391 2 : state.dataPipeHT->PipeHT(Item).ValidatePipeConstruction(state,
392 : cCurrentModuleObject,
393 2 : state.dataIPShortCut->cAlphaArgs(2),
394 2 : state.dataIPShortCut->cAlphaFieldNames(2),
395 2 : state.dataPipeHT->PipeHT(Item).ConstructionNum,
396 : ErrorsFound);
397 : }
398 :
399 : } // end of input loop
400 :
401 4 : cCurrentModuleObject = "Pipe:Outdoor";
402 5 : for (PipeItem = 1; PipeItem <= NumOfPipeHTExt; ++PipeItem) {
403 1 : ++Item;
404 : // get the object name
405 2 : state.dataInputProcessing->inputProcessor->getObjectItem(state,
406 : cCurrentModuleObject,
407 : PipeItem,
408 1 : state.dataIPShortCut->cAlphaArgs,
409 : NumAlphas,
410 1 : state.dataIPShortCut->rNumericArgs,
411 : NumNumbers,
412 : IOStatus,
413 1 : state.dataIPShortCut->lNumericFieldBlanks,
414 1 : state.dataIPShortCut->lAlphaFieldBlanks,
415 1 : state.dataIPShortCut->cAlphaFieldNames,
416 1 : state.dataIPShortCut->cNumericFieldNames);
417 :
418 1 : GlobalNames::VerifyUniqueInterObjectName(state,
419 1 : state.dataPipeHT->PipeHTUniqueNames,
420 1 : state.dataIPShortCut->cAlphaArgs(1),
421 : cCurrentModuleObject,
422 1 : state.dataIPShortCut->cAlphaFieldNames(1),
423 : ErrorsFound);
424 1 : state.dataPipeHT->PipeHT(Item).Name = state.dataIPShortCut->cAlphaArgs(1);
425 1 : state.dataPipeHT->PipeHT(Item).Type = DataPlant::PlantEquipmentType::PipeExterior;
426 :
427 : // General user input data
428 1 : state.dataPipeHT->PipeHT(Item).Construction = state.dataIPShortCut->cAlphaArgs(2);
429 1 : state.dataPipeHT->PipeHT(Item).ConstructionNum = Util::FindItemInList(state.dataIPShortCut->cAlphaArgs(2), state.dataConstruction->Construct);
430 :
431 1 : if (state.dataPipeHT->PipeHT(Item).ConstructionNum == 0) {
432 0 : ShowSevereError(state, format("Invalid {}={}", state.dataIPShortCut->cAlphaFieldNames(2), state.dataIPShortCut->cAlphaArgs(2)));
433 0 : ShowContinueError(state, format("Entered in {}={}", cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)));
434 0 : ErrorsFound = true;
435 : }
436 :
437 : // get inlet node data
438 1 : state.dataPipeHT->PipeHT(Item).InletNode = state.dataIPShortCut->cAlphaArgs(3);
439 2 : state.dataPipeHT->PipeHT(Item).InletNodeNum = GetOnlySingleNode(state,
440 1 : state.dataIPShortCut->cAlphaArgs(3),
441 : ErrorsFound,
442 : DataLoopNode::ConnectionObjectType::PipeOutdoor,
443 1 : state.dataIPShortCut->cAlphaArgs(1),
444 : DataLoopNode::NodeFluidType::Water,
445 : DataLoopNode::ConnectionType::Inlet,
446 : NodeInputManager::CompFluidStream::Primary,
447 : ObjectIsNotParent);
448 1 : if (state.dataPipeHT->PipeHT(Item).InletNodeNum == 0) {
449 0 : ShowSevereError(state, format("Invalid {}={}", state.dataIPShortCut->cAlphaFieldNames(3), state.dataIPShortCut->cAlphaArgs(3)));
450 0 : ShowContinueError(state, format("Entered in {}={}", cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)));
451 0 : ErrorsFound = true;
452 : }
453 :
454 : // get outlet node data
455 1 : state.dataPipeHT->PipeHT(Item).OutletNode = state.dataIPShortCut->cAlphaArgs(4);
456 2 : state.dataPipeHT->PipeHT(Item).OutletNodeNum = GetOnlySingleNode(state,
457 1 : state.dataIPShortCut->cAlphaArgs(4),
458 : ErrorsFound,
459 : DataLoopNode::ConnectionObjectType::PipeOutdoor,
460 1 : state.dataIPShortCut->cAlphaArgs(1),
461 : DataLoopNode::NodeFluidType::Water,
462 : DataLoopNode::ConnectionType::Outlet,
463 : NodeInputManager::CompFluidStream::Primary,
464 : ObjectIsNotParent);
465 1 : if (state.dataPipeHT->PipeHT(Item).OutletNodeNum == 0) {
466 0 : ShowSevereError(state, format("Invalid {}={}", state.dataIPShortCut->cAlphaFieldNames(4), state.dataIPShortCut->cAlphaArgs(4)));
467 0 : ShowContinueError(state, format("Entered in {}={}", cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)));
468 0 : ErrorsFound = true;
469 : }
470 :
471 2 : TestCompSet(state,
472 : cCurrentModuleObject,
473 1 : state.dataIPShortCut->cAlphaArgs(1),
474 1 : state.dataIPShortCut->cAlphaArgs(3),
475 1 : state.dataIPShortCut->cAlphaArgs(4),
476 : "Pipe Nodes");
477 :
478 : // get environmental boundary condition type
479 : // PipeHT(Item)%Environment = 'OutdoorAir'
480 1 : state.dataPipeHT->PipeHT(Item).EnvironmentPtr = EnvrnPtr::OutsideAirEnv;
481 :
482 1 : state.dataPipeHT->PipeHT(Item).EnvrAirNode = state.dataIPShortCut->cAlphaArgs(5);
483 2 : state.dataPipeHT->PipeHT(Item).EnvrAirNodeNum = GetOnlySingleNode(state,
484 1 : state.dataIPShortCut->cAlphaArgs(5),
485 : ErrorsFound,
486 : DataLoopNode::ConnectionObjectType::PipeOutdoor,
487 1 : state.dataIPShortCut->cAlphaArgs(1),
488 : DataLoopNode::NodeFluidType::Air,
489 : DataLoopNode::ConnectionType::OutsideAirReference,
490 : NodeInputManager::CompFluidStream::Primary,
491 : ObjectIsNotParent);
492 1 : if (!state.dataIPShortCut->lAlphaFieldBlanks(5)) {
493 1 : if (!CheckOutAirNodeNumber(state, state.dataPipeHT->PipeHT(Item).EnvrAirNodeNum)) {
494 0 : ShowSevereError(state, format("Invalid {}={}", state.dataIPShortCut->cAlphaFieldNames(5), state.dataIPShortCut->cAlphaArgs(5)));
495 0 : ShowContinueError(state, format("Entered in {}={}", cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)));
496 0 : ShowContinueError(state, "Outdoor Air Node not on OutdoorAir:NodeList or OutdoorAir:Node");
497 0 : ErrorsFound = true;
498 : }
499 : } else {
500 0 : ShowSevereError(state, format("Invalid {}={}", state.dataIPShortCut->cAlphaFieldNames(5), state.dataIPShortCut->cAlphaArgs(5)));
501 0 : ShowContinueError(state, format("Entered in {}={}", cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)));
502 0 : ShowContinueError(state, format("An {} must be used ", state.dataIPShortCut->cAlphaFieldNames(5)));
503 0 : ErrorsFound = true;
504 : }
505 :
506 : // dimensions
507 1 : state.dataPipeHT->PipeHT(Item).PipeID = state.dataIPShortCut->rNumericArgs(1);
508 1 : if (state.dataIPShortCut->rNumericArgs(1) <= 0.0) { // not really necessary because idd field has "minimum> 0"
509 0 : ShowSevereError(state,
510 0 : format("Invalid {} of {:.4R}", state.dataIPShortCut->cNumericFieldNames(1), state.dataIPShortCut->rNumericArgs(1)));
511 0 : ShowContinueError(state, format("{} must be > 0.0", state.dataIPShortCut->cNumericFieldNames(1)));
512 0 : ShowContinueError(state, format("Entered in {}={}", cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)));
513 0 : ErrorsFound = true;
514 : }
515 :
516 1 : state.dataPipeHT->PipeHT(Item).Length = state.dataIPShortCut->rNumericArgs(2);
517 1 : if (state.dataIPShortCut->rNumericArgs(2) <= 0.0) { // not really necessary because idd field has "minimum> 0"
518 0 : ShowSevereError(state,
519 0 : format("Invalid {} of {:.4R}", state.dataIPShortCut->cNumericFieldNames(2), state.dataIPShortCut->rNumericArgs(2)));
520 0 : ShowContinueError(state, format("{} must be > 0.0", state.dataIPShortCut->cNumericFieldNames(2)));
521 0 : ShowContinueError(state, format("Entered in {}={}", cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)));
522 0 : ErrorsFound = true;
523 : }
524 :
525 1 : if (state.dataPipeHT->PipeHT(Item).ConstructionNum != 0) {
526 1 : state.dataPipeHT->PipeHT(Item).ValidatePipeConstruction(state,
527 : cCurrentModuleObject,
528 1 : state.dataIPShortCut->cAlphaArgs(2),
529 1 : state.dataIPShortCut->cAlphaFieldNames(2),
530 1 : state.dataPipeHT->PipeHT(Item).ConstructionNum,
531 : ErrorsFound);
532 : }
533 :
534 : } // end of input loop
535 :
536 4 : cCurrentModuleObject = "Pipe:Underground";
537 5 : for (PipeItem = 1; PipeItem <= NumOfPipeHTUG; ++PipeItem) {
538 :
539 1 : ++Item;
540 : // get the object name
541 2 : state.dataInputProcessing->inputProcessor->getObjectItem(state,
542 : cCurrentModuleObject,
543 : PipeItem,
544 1 : state.dataIPShortCut->cAlphaArgs,
545 : NumAlphas,
546 1 : state.dataIPShortCut->rNumericArgs,
547 : NumNumbers,
548 : IOStatus,
549 1 : state.dataIPShortCut->lNumericFieldBlanks,
550 1 : state.dataIPShortCut->lAlphaFieldBlanks,
551 1 : state.dataIPShortCut->cAlphaFieldNames,
552 1 : state.dataIPShortCut->cNumericFieldNames);
553 :
554 1 : GlobalNames::VerifyUniqueInterObjectName(state,
555 1 : state.dataPipeHT->PipeHTUniqueNames,
556 1 : state.dataIPShortCut->cAlphaArgs(1),
557 : cCurrentModuleObject,
558 1 : state.dataIPShortCut->cAlphaFieldNames(1),
559 : ErrorsFound);
560 1 : state.dataPipeHT->PipeHT(Item).Name = state.dataIPShortCut->cAlphaArgs(1);
561 1 : state.dataPipeHT->PipeHT(Item).Type = DataPlant::PlantEquipmentType::PipeUnderground;
562 :
563 : // General user input data
564 1 : state.dataPipeHT->PipeHT(Item).Construction = state.dataIPShortCut->cAlphaArgs(2);
565 1 : state.dataPipeHT->PipeHT(Item).ConstructionNum = Util::FindItemInList(state.dataIPShortCut->cAlphaArgs(2), state.dataConstruction->Construct);
566 :
567 1 : if (state.dataPipeHT->PipeHT(Item).ConstructionNum == 0) {
568 0 : ShowSevereError(state, format("Invalid {}={}", state.dataIPShortCut->cAlphaFieldNames(2), state.dataIPShortCut->cAlphaArgs(2)));
569 0 : ShowContinueError(state, format("Entered in {}={}", cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)));
570 0 : ErrorsFound = true;
571 : }
572 :
573 : // get inlet node data
574 1 : state.dataPipeHT->PipeHT(Item).InletNode = state.dataIPShortCut->cAlphaArgs(3);
575 2 : state.dataPipeHT->PipeHT(Item).InletNodeNum = GetOnlySingleNode(state,
576 1 : state.dataIPShortCut->cAlphaArgs(3),
577 : ErrorsFound,
578 : DataLoopNode::ConnectionObjectType::PipeUnderground,
579 1 : state.dataIPShortCut->cAlphaArgs(1),
580 : DataLoopNode::NodeFluidType::Water,
581 : DataLoopNode::ConnectionType::Inlet,
582 : NodeInputManager::CompFluidStream::Primary,
583 : ObjectIsNotParent);
584 1 : if (state.dataPipeHT->PipeHT(Item).InletNodeNum == 0) {
585 0 : ShowSevereError(state, format("Invalid {}={}", state.dataIPShortCut->cAlphaFieldNames(3), state.dataIPShortCut->cAlphaArgs(3)));
586 0 : ShowContinueError(state, format("Entered in {}={}", cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)));
587 0 : ErrorsFound = true;
588 : }
589 :
590 : // get outlet node data
591 1 : state.dataPipeHT->PipeHT(Item).OutletNode = state.dataIPShortCut->cAlphaArgs(4);
592 2 : state.dataPipeHT->PipeHT(Item).OutletNodeNum = GetOnlySingleNode(state,
593 1 : state.dataIPShortCut->cAlphaArgs(4),
594 : ErrorsFound,
595 : DataLoopNode::ConnectionObjectType::PipeUnderground,
596 1 : state.dataIPShortCut->cAlphaArgs(1),
597 : DataLoopNode::NodeFluidType::Water,
598 : DataLoopNode::ConnectionType::Outlet,
599 : NodeInputManager::CompFluidStream::Primary,
600 : ObjectIsNotParent);
601 1 : if (state.dataPipeHT->PipeHT(Item).OutletNodeNum == 0) {
602 0 : ShowSevereError(state, format("Invalid {}={}", state.dataIPShortCut->cAlphaFieldNames(4), state.dataIPShortCut->cAlphaArgs(4)));
603 0 : ShowContinueError(state, format("Entered in {}={}", cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)));
604 0 : ErrorsFound = true;
605 : }
606 :
607 2 : TestCompSet(state,
608 : cCurrentModuleObject,
609 1 : state.dataIPShortCut->cAlphaArgs(1),
610 1 : state.dataIPShortCut->cAlphaArgs(3),
611 1 : state.dataIPShortCut->cAlphaArgs(4),
612 : "Pipe Nodes");
613 :
614 1 : state.dataPipeHT->PipeHT(Item).EnvironmentPtr = EnvrnPtr::GroundEnv;
615 :
616 : // Solar inclusion flag
617 : // A6, \field Sun Exposure
618 1 : if (Util::SameString(state.dataIPShortCut->cAlphaArgs(5), "SUNEXPOSED")) {
619 1 : state.dataPipeHT->PipeHT(Item).SolarExposed = true;
620 0 : } else if (Util::SameString(state.dataIPShortCut->cAlphaArgs(5), "NOSUN")) {
621 0 : state.dataPipeHT->PipeHT(Item).SolarExposed = false;
622 : } else {
623 0 : ShowSevereError(state, format("GetPipesHeatTransfer: invalid key for sun exposure flag for {}", state.dataIPShortCut->cAlphaArgs(1)));
624 0 : ShowContinueError(state, format("Key should be either SunExposed or NoSun. Entered Key: {}", state.dataIPShortCut->cAlphaArgs(5)));
625 0 : ErrorsFound = true;
626 : }
627 :
628 : // dimensions
629 1 : state.dataPipeHT->PipeHT(Item).PipeID = state.dataIPShortCut->rNumericArgs(1);
630 1 : if (state.dataIPShortCut->rNumericArgs(1) <= 0.0) { // not really necessary because idd field has "minimum> 0"
631 0 : ShowSevereError(state,
632 0 : format("Invalid {} of {:.4R}", state.dataIPShortCut->cNumericFieldNames(1), state.dataIPShortCut->rNumericArgs(1)));
633 0 : ShowContinueError(state, format("{} must be > 0.0", state.dataIPShortCut->cNumericFieldNames(1)));
634 0 : ShowContinueError(state, format("Entered in {}={}", cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)));
635 0 : ErrorsFound = true;
636 : }
637 :
638 1 : state.dataPipeHT->PipeHT(Item).Length = state.dataIPShortCut->rNumericArgs(2);
639 1 : if (state.dataIPShortCut->rNumericArgs(2) <= 0.0) { // not really necessary because idd field has "minimum> 0"
640 0 : ShowSevereError(state,
641 0 : format("Invalid {} of {:.4R}", state.dataIPShortCut->cNumericFieldNames(2), state.dataIPShortCut->rNumericArgs(2)));
642 0 : ShowContinueError(state, format("{} must be > 0.0", state.dataIPShortCut->cNumericFieldNames(2)));
643 0 : ShowContinueError(state, format("Entered in {}={}", cCurrentModuleObject, state.dataIPShortCut->cAlphaArgs(1)));
644 0 : ErrorsFound = true;
645 : }
646 :
647 : // Also get the soil material name
648 : // A7, \field Soil Material
649 1 : state.dataPipeHT->PipeHT(Item).SoilMaterial = state.dataIPShortCut->cAlphaArgs(6);
650 1 : state.dataPipeHT->PipeHT(Item).SoilMaterialNum = Util::FindItemInPtrList(state.dataIPShortCut->cAlphaArgs(6), state.dataMaterial->Material);
651 1 : if (state.dataPipeHT->PipeHT(Item).SoilMaterialNum == 0) {
652 0 : ShowSevereError(state, format("Invalid {}={}", state.dataIPShortCut->cAlphaFieldNames(6), state.dataPipeHT->PipeHT(Item).SoilMaterial));
653 0 : ShowContinueError(state, format("Found in {}={}", cCurrentModuleObject, state.dataPipeHT->PipeHT(Item).Name));
654 0 : ErrorsFound = true;
655 : } else {
656 : auto const *thisMaterialSoil =
657 1 : dynamic_cast<const Material::MaterialChild *>(state.dataMaterial->Material(state.dataPipeHT->PipeHT(Item).SoilMaterialNum));
658 1 : assert(thisMaterialSoil != nullptr);
659 1 : state.dataPipeHT->PipeHT(Item).SoilDensity = thisMaterialSoil->Density;
660 1 : state.dataPipeHT->PipeHT(Item).SoilDepth = thisMaterialSoil->Thickness;
661 1 : state.dataPipeHT->PipeHT(Item).SoilCp = thisMaterialSoil->SpecHeat;
662 1 : state.dataPipeHT->PipeHT(Item).SoilConductivity = thisMaterialSoil->Conductivity;
663 1 : state.dataPipeHT->PipeHT(Item).SoilThermAbs = thisMaterialSoil->AbsorpThermal;
664 1 : state.dataPipeHT->PipeHT(Item).SoilSolarAbs = thisMaterialSoil->AbsorpSolar;
665 1 : state.dataPipeHT->PipeHT(Item).SoilRoughness = thisMaterialSoil->Roughness;
666 1 : state.dataPipeHT->PipeHT(Item).PipeDepth = state.dataPipeHT->PipeHT(Item).SoilDepth + state.dataPipeHT->PipeHT(Item).PipeID / 2.0;
667 1 : state.dataPipeHT->PipeHT(Item).DomainDepth = state.dataPipeHT->PipeHT(Item).PipeDepth * 2.0;
668 2 : state.dataPipeHT->PipeHT(Item).SoilDiffusivity = state.dataPipeHT->PipeHT(Item).SoilConductivity /
669 1 : (state.dataPipeHT->PipeHT(Item).SoilDensity * state.dataPipeHT->PipeHT(Item).SoilCp);
670 1 : state.dataPipeHT->PipeHT(Item).SoilDiffusivityPerDay =
671 1 : state.dataPipeHT->PipeHT(Item).SoilDiffusivity * SecondsInHour * Constant::HoursInDay;
672 :
673 : // Mesh the cartesian domain
674 1 : state.dataPipeHT->PipeHT(Item).NumDepthNodes = NumberOfDepthNodes;
675 1 : state.dataPipeHT->PipeHT(Item).PipeNodeDepth = state.dataPipeHT->PipeHT(Item).NumDepthNodes / 2;
676 1 : state.dataPipeHT->PipeHT(Item).PipeNodeWidth = state.dataPipeHT->PipeHT(Item).NumDepthNodes / 2;
677 1 : state.dataPipeHT->PipeHT(Item).DomainDepth = state.dataPipeHT->PipeHT(Item).PipeDepth * 2.0;
678 1 : state.dataPipeHT->PipeHT(Item).dSregular =
679 1 : state.dataPipeHT->PipeHT(Item).DomainDepth / (state.dataPipeHT->PipeHT(Item).NumDepthNodes - 1);
680 : }
681 :
682 1 : if (state.dataPipeHT->PipeHT(Item).ConstructionNum != 0) {
683 1 : state.dataPipeHT->PipeHT(Item).ValidatePipeConstruction(state,
684 : cCurrentModuleObject,
685 1 : state.dataIPShortCut->cAlphaArgs(2),
686 1 : state.dataIPShortCut->cAlphaFieldNames(2),
687 1 : state.dataPipeHT->PipeHT(Item).ConstructionNum,
688 : ErrorsFound);
689 : }
690 :
691 : // Get ground temperature model
692 1 : state.dataPipeHT->PipeHT(Item).groundTempModel =
693 2 : GetGroundTempModelAndInit(state, state.dataIPShortCut->cAlphaArgs(7), state.dataIPShortCut->cAlphaArgs(8));
694 :
695 : // Select number of pipe sections. Hanby's optimal number of 20 section is selected.
696 1 : NumSections = NumPipeSections;
697 1 : state.dataPipeHT->PipeHT(Item).NumSections = NumPipeSections;
698 :
699 : // For buried pipes, we need to allocate the cartesian finite difference array
700 2 : state.dataPipeHT->PipeHT(Item).T.allocate(state.dataPipeHT->PipeHT(Item).PipeNodeWidth,
701 1 : state.dataPipeHT->PipeHT(Item).NumDepthNodes,
702 1 : state.dataPipeHT->PipeHT(Item).NumSections,
703 : TimeIndex::Tentative);
704 1 : state.dataPipeHT->PipeHT(Item).T = 0.0;
705 :
706 : } // PipeUG input loop
707 :
708 8 : for (Item = 1; Item <= state.dataPipeHT->nsvNumOfPipeHT; ++Item) {
709 : // Select number of pipe sections. Hanby's optimal number of 20 section is selected.
710 4 : NumSections = NumPipeSections;
711 4 : state.dataPipeHT->PipeHT(Item).NumSections = NumPipeSections;
712 :
713 : // We need to allocate the Hanby model arrays for all pipes, including buried
714 4 : state.dataPipeHT->PipeHT(Item).TentativeFluidTemp.allocate({0, NumSections});
715 4 : state.dataPipeHT->PipeHT(Item).TentativePipeTemp.allocate({0, NumSections});
716 4 : state.dataPipeHT->PipeHT(Item).FluidTemp.allocate({0, NumSections});
717 4 : state.dataPipeHT->PipeHT(Item).PreviousFluidTemp.allocate({0, NumSections});
718 4 : state.dataPipeHT->PipeHT(Item).PipeTemp.allocate({0, NumSections});
719 4 : state.dataPipeHT->PipeHT(Item).PreviousPipeTemp.allocate({0, NumSections});
720 :
721 4 : state.dataPipeHT->PipeHT(Item).TentativeFluidTemp = 0.0;
722 4 : state.dataPipeHT->PipeHT(Item).FluidTemp = 0.0;
723 4 : state.dataPipeHT->PipeHT(Item).PreviousFluidTemp = 0.0;
724 4 : state.dataPipeHT->PipeHT(Item).TentativePipeTemp = 0.0;
725 4 : state.dataPipeHT->PipeHT(Item).PipeTemp = 0.0;
726 4 : state.dataPipeHT->PipeHT(Item).PreviousPipeTemp = 0.0;
727 :
728 : // work out heat transfer areas (area per section)
729 4 : state.dataPipeHT->PipeHT(Item).InsideArea =
730 4 : Constant::Pi * state.dataPipeHT->PipeHT(Item).PipeID * state.dataPipeHT->PipeHT(Item).Length / NumSections;
731 4 : state.dataPipeHT->PipeHT(Item).OutsideArea =
732 4 : Constant::Pi * (state.dataPipeHT->PipeHT(Item).PipeOD + 2 * state.dataPipeHT->PipeHT(Item).InsulationThickness) *
733 4 : state.dataPipeHT->PipeHT(Item).Length / NumSections;
734 :
735 : // cross sectional area
736 4 : state.dataPipeHT->PipeHT(Item).SectionArea = Constant::Pi * 0.25 * pow_2(state.dataPipeHT->PipeHT(Item).PipeID);
737 :
738 : // pipe & insulation mass
739 4 : state.dataPipeHT->PipeHT(Item).PipeHeatCapacity =
740 4 : state.dataPipeHT->PipeHT(Item).PipeCp * state.dataPipeHT->PipeHT(Item).PipeDensity *
741 4 : (Constant::Pi * 0.25 * pow_2(state.dataPipeHT->PipeHT(Item).PipeOD) - state.dataPipeHT->PipeHT(Item).SectionArea); // the metal component
742 : }
743 :
744 : // final error check
745 4 : if (ErrorsFound) {
746 0 : ShowFatalError(state, "GetPipesHeatTransfer: Errors found in input. Preceding conditions cause termination.");
747 : }
748 :
749 : // Set up the output variables CurrentModuleObject='Pipe:Indoor/Outdoor/Underground'
750 8 : for (Item = 1; Item <= state.dataPipeHT->nsvNumOfPipeHT; ++Item) {
751 :
752 8 : SetupOutputVariable(state,
753 : "Pipe Fluid Heat Transfer Rate",
754 : Constant::Units::W,
755 4 : state.dataPipeHT->PipeHT(Item).FluidHeatLossRate,
756 : OutputProcessor::TimeStepType::System,
757 : OutputProcessor::StoreType::Average,
758 4 : state.dataPipeHT->PipeHT(Item).Name);
759 8 : SetupOutputVariable(state,
760 : "Pipe Fluid Heat Transfer Energy",
761 : Constant::Units::J,
762 4 : state.dataPipeHT->PipeHT(Item).FluidHeatLossEnergy,
763 : OutputProcessor::TimeStepType::System,
764 : OutputProcessor::StoreType::Sum,
765 4 : state.dataPipeHT->PipeHT(Item).Name);
766 :
767 4 : if (state.dataPipeHT->PipeHT(Item).EnvironmentPtr == EnvrnPtr::ZoneEnv) {
768 2 : SetupOutputVariable(state,
769 : "Pipe Ambient Heat Transfer Rate",
770 : Constant::Units::W,
771 1 : state.dataPipeHT->PipeHT(Item).EnvironmentHeatLossRate,
772 : OutputProcessor::TimeStepType::System,
773 : OutputProcessor::StoreType::Average,
774 1 : state.dataPipeHT->PipeHT(Item).Name);
775 2 : SetupOutputVariable(state,
776 : "Pipe Ambient Heat Transfer Energy",
777 : Constant::Units::J,
778 1 : state.dataPipeHT->PipeHT(Item).EnvHeatLossEnergy,
779 : OutputProcessor::TimeStepType::System,
780 : OutputProcessor::StoreType::Sum,
781 1 : state.dataPipeHT->PipeHT(Item).Name);
782 :
783 3 : SetupZoneInternalGain(state,
784 1 : state.dataPipeHT->PipeHT(Item).EnvrZonePtr,
785 1 : state.dataPipeHT->PipeHT(Item).Name,
786 : DataHeatBalance::IntGainType::PipeIndoor,
787 1 : &state.dataPipeHT->PipeHT(Item).ZoneHeatGainRate);
788 : }
789 :
790 8 : SetupOutputVariable(state,
791 : "Pipe Mass Flow Rate",
792 : Constant::Units::kg_s,
793 4 : state.dataPipeHT->PipeHT(Item).MassFlowRate,
794 : OutputProcessor::TimeStepType::System,
795 : OutputProcessor::StoreType::Average,
796 4 : state.dataPipeHT->PipeHT(Item).Name);
797 8 : SetupOutputVariable(state,
798 : "Pipe Volume Flow Rate",
799 : Constant::Units::m3_s,
800 4 : state.dataPipeHT->PipeHT(Item).VolumeFlowRate,
801 : OutputProcessor::TimeStepType::System,
802 : OutputProcessor::StoreType::Average,
803 4 : state.dataPipeHT->PipeHT(Item).Name);
804 8 : SetupOutputVariable(state,
805 : "Pipe Inlet Temperature",
806 : Constant::Units::C,
807 4 : state.dataPipeHT->PipeHT(Item).FluidInletTemp,
808 : OutputProcessor::TimeStepType::System,
809 : OutputProcessor::StoreType::Average,
810 4 : state.dataPipeHT->PipeHT(Item).Name);
811 8 : SetupOutputVariable(state,
812 : "Pipe Outlet Temperature",
813 : Constant::Units::C,
814 4 : state.dataPipeHT->PipeHT(Item).FluidOutletTemp,
815 : OutputProcessor::TimeStepType::System,
816 : OutputProcessor::StoreType::Average,
817 4 : state.dataPipeHT->PipeHT(Item).Name);
818 : }
819 4 : }
820 :
821 4 : void PipeHTData::ValidatePipeConstruction(EnergyPlusData &state,
822 : std::string const &PipeType, // module object of pipe (error messages)
823 : std::string const &ConstructionName, // construction name of pipe (error messages)
824 : std::string_view FieldName, // fieldname of pipe (error messages)
825 : int const ConstructionNum, // pointer into construction data
826 : bool &ErrorsFound // set to true if errors found here
827 : )
828 : {
829 :
830 : // SUBROUTINE INFORMATION:
831 : // AUTHOR Linda Lawrie
832 : // DATE WRITTEN August 2008
833 : // MODIFIED na
834 : // RE-ENGINEERED na
835 :
836 : // PURPOSE OF THIS SUBROUTINE:
837 : // This routine, called from GetInput, validates the pipe construction usage.
838 :
839 : // METHODOLOGY EMPLOYED:
840 : // na
841 :
842 : // REFERENCES:
843 : // na
844 :
845 : // Using/Aliasing
846 :
847 : // Locals
848 : // SUBROUTINE ARGUMENT DEFINITIONS:
849 :
850 : // SUBROUTINE PARAMETER DEFINITIONS:
851 : // na
852 :
853 : // INTERFACE BLOCK SPECIFICATIONS:
854 : // na
855 :
856 : // DERIVED TYPE DEFINITIONS:
857 : // na
858 :
859 : // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
860 : Real64 Density; // average density [kg/m^3]
861 : Real64 SpHeat; // average specific heat [J/kg.K]
862 4 : Real64 Resistance = 0.0;
863 4 : Real64 TotThickness = 0.0;
864 :
865 : // CTF stuff
866 4 : int TotalLayers = state.dataConstruction->Construct(ConstructionNum).TotLayers;
867 : // get pipe properties
868 4 : if (TotalLayers == 1) { // no insulation layer
869 :
870 0 : this->PipeConductivity = state.dataMaterial->Material(state.dataConstruction->Construct(ConstructionNum).LayerPoint(1))->Conductivity;
871 0 : this->PipeDensity = state.dataMaterial->Material(state.dataConstruction->Construct(ConstructionNum).LayerPoint(1))->Density;
872 0 : this->PipeCp = state.dataMaterial->Material(state.dataConstruction->Construct(ConstructionNum).LayerPoint(1))->SpecHeat;
873 0 : this->PipeOD = this->PipeID + 2.0 * state.dataMaterial->Material(state.dataConstruction->Construct(ConstructionNum).LayerPoint(1))->Thickness;
874 0 : this->InsulationOD = this->PipeOD;
875 0 : this->SumTK = state.dataMaterial->Material(state.dataConstruction->Construct(ConstructionNum).LayerPoint(1))->Thickness /
876 0 : state.dataMaterial->Material(state.dataConstruction->Construct(ConstructionNum).LayerPoint(1))->Conductivity;
877 :
878 4 : } else if (TotalLayers >= 2) { // first layers are insulation, last layer is pipe
879 :
880 8 : for (int LayerNum = 1; LayerNum <= TotalLayers - 1; ++LayerNum) {
881 4 : Resistance += state.dataMaterial->Material(state.dataConstruction->Construct(ConstructionNum).LayerPoint(LayerNum))->Thickness /
882 4 : state.dataMaterial->Material(state.dataConstruction->Construct(ConstructionNum).LayerPoint(LayerNum))->Conductivity;
883 4 : Density = state.dataMaterial->Material(state.dataConstruction->Construct(ConstructionNum).LayerPoint(LayerNum))->Density *
884 4 : state.dataMaterial->Material(state.dataConstruction->Construct(ConstructionNum).LayerPoint(LayerNum))->Thickness;
885 4 : TotThickness += state.dataMaterial->Material(state.dataConstruction->Construct(ConstructionNum).LayerPoint(LayerNum))->Thickness;
886 4 : SpHeat = state.dataMaterial->Material(state.dataConstruction->Construct(ConstructionNum).LayerPoint(LayerNum))->SpecHeat *
887 4 : state.dataMaterial->Material(state.dataConstruction->Construct(ConstructionNum).LayerPoint(LayerNum))->Thickness;
888 4 : this->InsulationThickness =
889 4 : state.dataMaterial->Material(state.dataConstruction->Construct(ConstructionNum).LayerPoint(LayerNum))->Thickness;
890 4 : this->SumTK += state.dataMaterial->Material(state.dataConstruction->Construct(ConstructionNum).LayerPoint(LayerNum))->Thickness /
891 4 : state.dataMaterial->Material(state.dataConstruction->Construct(ConstructionNum).LayerPoint(LayerNum))->Conductivity;
892 : }
893 :
894 4 : this->InsulationResistance = Resistance;
895 4 : this->InsulationConductivity = TotThickness / Resistance;
896 4 : this->InsulationDensity = Density / TotThickness;
897 4 : this->InsulationCp = SpHeat / TotThickness;
898 4 : this->InsulationThickness = TotThickness;
899 :
900 4 : this->PipeConductivity =
901 4 : state.dataMaterial->Material(state.dataConstruction->Construct(ConstructionNum).LayerPoint(TotalLayers))->Conductivity;
902 4 : this->PipeDensity = state.dataMaterial->Material(state.dataConstruction->Construct(ConstructionNum).LayerPoint(TotalLayers))->Density;
903 4 : this->PipeCp = state.dataMaterial->Material(state.dataConstruction->Construct(ConstructionNum).LayerPoint(TotalLayers))->SpecHeat;
904 :
905 4 : this->PipeOD =
906 4 : this->PipeID + 2.0 * state.dataMaterial->Material(state.dataConstruction->Construct(ConstructionNum).LayerPoint(TotalLayers))->Thickness;
907 4 : this->InsulationOD = this->PipeOD + 2.0 * this->InsulationThickness;
908 :
909 : } else {
910 0 : ShowSevereError(
911 0 : state, format("{}: invalid {}=\"{}\", too many layers=[{}], only 1 or 2 allowed.", PipeType, FieldName, ConstructionName, TotalLayers));
912 0 : ErrorsFound = true;
913 : }
914 4 : }
915 :
916 4 : void PipeHTData::oneTimeInit_new(EnergyPlusData &state)
917 : {
918 4 : bool errFlag = false;
919 4 : PlantUtilities::ScanPlantLoopsForObject(state, this->Name, this->Type, this->plantLoc, errFlag, _, _, _, _, _);
920 4 : if (errFlag) {
921 0 : ShowFatalError(state, "InitPipesHeatTransfer: Program terminated due to previous condition(s).");
922 : }
923 4 : }
924 :
925 58100 : void PipeHTData::InitPipesHeatTransfer(EnergyPlusData &state, bool const FirstHVACIteration // component number
926 : )
927 : {
928 :
929 : // SUBROUTINE INFORMATION:
930 : // AUTHOR Simon Rees
931 : // DATE WRITTEN July 2007
932 : // MODIFIED L. Gu, 6/19/08, pipe wall heat capacity has metal layer only
933 : // RE-ENGINEERED na
934 :
935 : // PURPOSE OF THIS SUBROUTINE:
936 : // This subroutine Resets the elements of the data structure as necessary
937 : // at the first step, and start of each call to simulated
938 :
939 : // METHODOLOGY EMPLOYED:
940 : // Check flags and update data structure
941 :
942 : // Using/Aliasing
943 58100 : Real64 SysTimeElapsed = state.dataHVACGlobal->SysTimeElapsed;
944 58100 : Real64 TimeStepSysSec = state.dataHVACGlobal->TimeStepSysSec;
945 : using FluidProperties::GetDensityGlycol;
946 : using FluidProperties::GetSpecificHeatGlycol;
947 : using ScheduleManager::GetCurrentScheduleValue;
948 :
949 : // SUBROUTINE PARAMETER DEFINITIONS:
950 : static constexpr std::string_view RoutineName("InitPipesHeatTransfer");
951 :
952 : // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
953 :
954 : Real64 FirstTemperatures; // initial temperature of every node in pipe (set to inlet temp) [C]
955 : int TimeIndex;
956 : int LengthIndex;
957 : int DepthIndex;
958 : int WidthIndex;
959 : Real64 CurrentDepth;
960 : Real64 CurTemp;
961 : Real64 CurSimDay;
962 : bool PushArrays;
963 :
964 : // Assign variable
965 58100 : CurSimDay = double(state.dataGlobal->DayOfSim);
966 :
967 : // some useful module variables
968 58100 : state.dataPipeHT->nsvInletNodeNum = this->InletNodeNum;
969 58100 : state.dataPipeHT->nsvOutletNodeNum = this->OutletNodeNum;
970 58100 : state.dataPipeHT->nsvMassFlowRate = state.dataLoopNodes->Node(state.dataPipeHT->nsvInletNodeNum).MassFlowRate;
971 58100 : state.dataPipeHT->nsvInletTemp = state.dataLoopNodes->Node(state.dataPipeHT->nsvInletNodeNum).Temp;
972 :
973 : // initialize temperatures by inlet node temp
974 58100 : if ((state.dataGlobal->BeginSimFlag && this->BeginSimInit) || (state.dataGlobal->BeginEnvrnFlag && this->BeginSimEnvrn)) {
975 :
976 20 : if (this->EnvironmentPtr == EnvrnPtr::GroundEnv) {
977 20 : for (TimeIndex = TimeIndex::Previous; TimeIndex <= TimeIndex::Tentative; ++TimeIndex) {
978 : // Loop through all length, depth, and width of pipe to init soil temperature
979 315 : for (LengthIndex = 1; LengthIndex <= this->NumSections; ++LengthIndex) {
980 2700 : for (DepthIndex = 1; DepthIndex <= this->NumDepthNodes; ++DepthIndex) {
981 12000 : for (WidthIndex = 1; WidthIndex <= this->PipeNodeWidth; ++WidthIndex) {
982 9600 : CurrentDepth = (DepthIndex - 1) * this->dSregular;
983 9600 : this->T(WidthIndex, DepthIndex, LengthIndex, TimeIndex) = this->TBND(state, CurrentDepth);
984 : }
985 : }
986 : }
987 : }
988 : }
989 :
990 : // We also need to re-init the Hanby arrays for all pipes, including buried
991 20 : FirstTemperatures = 21.0; // Node(InletNodeNum)%Temp
992 20 : this->TentativeFluidTemp = FirstTemperatures;
993 20 : this->FluidTemp = FirstTemperatures;
994 20 : this->PreviousFluidTemp = FirstTemperatures;
995 20 : this->TentativePipeTemp = FirstTemperatures;
996 20 : this->PipeTemp = FirstTemperatures;
997 20 : this->PreviousPipeTemp = FirstTemperatures;
998 20 : this->PreviousSimTime = 0.0;
999 20 : state.dataPipeHT->nsvDeltaTime = 0.0;
1000 20 : state.dataPipeHT->nsvOutletTemp = 0.0;
1001 20 : state.dataPipeHT->nsvEnvironmentTemp = 0.0;
1002 20 : state.dataPipeHT->nsvEnvHeatLossRate = 0.0;
1003 20 : state.dataPipeHT->nsvFluidHeatLossRate = 0.0;
1004 :
1005 20 : this->BeginSimInit = false;
1006 20 : this->BeginSimEnvrn = false;
1007 : }
1008 :
1009 58100 : if (!state.dataGlobal->BeginSimFlag) this->BeginSimInit = true;
1010 58100 : if (!state.dataGlobal->BeginEnvrnFlag) this->BeginSimEnvrn = true;
1011 :
1012 : // time step in seconds
1013 58100 : state.dataPipeHT->nsvDeltaTime = TimeStepSysSec;
1014 58100 : state.dataPipeHT->nsvNumInnerTimeSteps = int(state.dataPipeHT->nsvDeltaTime / InnerDeltaTime);
1015 :
1016 : // previous temps are updated if necessary at start of timestep rather than end
1017 58100 : if ((FirstHVACIteration && this->FirstHVACupdateFlag) || (state.dataGlobal->BeginEnvrnFlag && this->BeginEnvrnupdateFlag)) {
1018 :
1019 : // We need to update boundary conditions here, as well as updating the arrays
1020 7260 : if (this->EnvironmentPtr == EnvrnPtr::GroundEnv) {
1021 :
1022 : // And then update Ground Boundary Conditions
1023 7260 : for (TimeIndex = 1; TimeIndex <= TimeIndex::Tentative; ++TimeIndex) {
1024 114345 : for (LengthIndex = 1; LengthIndex <= this->NumSections; ++LengthIndex) {
1025 980100 : for (DepthIndex = 1; DepthIndex <= this->NumDepthNodes; ++DepthIndex) {
1026 : // Farfield boundary
1027 871200 : CurrentDepth = (DepthIndex - 1) * this->dSregular;
1028 871200 : CurTemp = this->TBND(state, CurrentDepth);
1029 871200 : this->T(1, DepthIndex, LengthIndex, TimeIndex) = CurTemp;
1030 : }
1031 544500 : for (WidthIndex = 1; WidthIndex <= this->PipeNodeWidth; ++WidthIndex) {
1032 : // Bottom side of boundary
1033 435600 : CurrentDepth = this->DomainDepth;
1034 435600 : CurTemp = this->TBND(state, CurrentDepth);
1035 435600 : this->T(WidthIndex, this->NumDepthNodes, LengthIndex, TimeIndex) = CurTemp;
1036 : }
1037 : }
1038 : }
1039 : }
1040 :
1041 : // should next choose environment temperature according to coupled with air or ground
1042 7260 : switch (this->EnvironmentPtr) {
1043 1815 : case EnvrnPtr::GroundEnv: {
1044 : // EnvironmentTemp = GroundTemp
1045 1815 : } break;
1046 1815 : case EnvrnPtr::OutsideAirEnv: {
1047 1815 : state.dataPipeHT->nsvEnvironmentTemp = state.dataEnvrn->OutDryBulbTemp;
1048 1815 : } break;
1049 1815 : case EnvrnPtr::ZoneEnv: {
1050 1815 : state.dataPipeHT->nsvEnvironmentTemp = state.dataZoneTempPredictorCorrector->zoneHeatBalance(this->EnvrZonePtr).MAT;
1051 1815 : } break;
1052 1815 : case EnvrnPtr::ScheduleEnv: {
1053 1815 : state.dataPipeHT->nsvEnvironmentTemp = GetCurrentScheduleValue(state, this->EnvrSchedPtr);
1054 1815 : } break;
1055 0 : case EnvrnPtr::None: { // default to outside temp
1056 0 : state.dataPipeHT->nsvEnvironmentTemp = state.dataEnvrn->OutDryBulbTemp;
1057 0 : } break;
1058 0 : default:
1059 0 : break;
1060 : }
1061 :
1062 7260 : this->BeginEnvrnupdateFlag = false;
1063 7260 : this->FirstHVACupdateFlag = false;
1064 : }
1065 :
1066 58100 : if (!state.dataGlobal->BeginEnvrnFlag) this->BeginEnvrnupdateFlag = true;
1067 58100 : if (!FirstHVACIteration) this->FirstHVACupdateFlag = true;
1068 :
1069 : // Calculate the current sim time for this pipe (not necessarily structure variable, but it is ok for consistency)
1070 58100 : this->CurrentSimTime = (state.dataGlobal->DayOfSim - 1) * 24 + state.dataGlobal->HourOfDay - 1 +
1071 58100 : (state.dataGlobal->TimeStep - 1) * state.dataGlobal->TimeStepZone + SysTimeElapsed;
1072 58100 : if (std::abs(this->CurrentSimTime - this->PreviousSimTime) > 1.0e-6) {
1073 6372 : PushArrays = true;
1074 6372 : this->PreviousSimTime = this->CurrentSimTime;
1075 : } else {
1076 51728 : PushArrays = false; // Time hasn't passed, don't accept the tentative values yet!
1077 : }
1078 :
1079 58100 : if (PushArrays) {
1080 :
1081 : // If sim time has changed all values from previous runs should have been acceptable.
1082 : // Thus we will now shift the arrays from 2>1 and 3>2 so we can then begin
1083 : // to update 2 and 3 again.
1084 6372 : if (this->EnvironmentPtr == EnvrnPtr::GroundEnv) {
1085 31860 : for (LengthIndex = 2; LengthIndex <= this->NumSections; ++LengthIndex) {
1086 272403 : for (DepthIndex = 1; DepthIndex <= this->NumDepthNodes; ++DepthIndex) {
1087 968544 : for (WidthIndex = 2; WidthIndex <= this->PipeNodeWidth; ++WidthIndex) {
1088 : // This will essentially 'accept' the tentative values that were calculated last iteration
1089 : // as the new officially 'current' values
1090 726408 : this->T(WidthIndex, DepthIndex, LengthIndex, TimeIndex::Current) =
1091 726408 : this->T(WidthIndex, DepthIndex, LengthIndex, TimeIndex::Tentative);
1092 : }
1093 : }
1094 : }
1095 : }
1096 :
1097 : // Then update the Hanby near pipe model temperatures
1098 6372 : this->FluidTemp = this->TentativeFluidTemp;
1099 6372 : this->PipeTemp = this->TentativePipeTemp;
1100 :
1101 : } else { // IF(.NOT. FirstHVACIteration)THEN
1102 :
1103 : // If we don't have FirstHVAC, the last iteration values were not accepted, and we should
1104 : // not step through time. Thus we will revert our T(3,:,:,:) array back to T(2,:,:,:) to
1105 : // start over with the same values as last time.
1106 1034560 : for (LengthIndex = 2; LengthIndex <= this->NumSections; ++LengthIndex) {
1107 2948496 : for (DepthIndex = 1; DepthIndex <= this->NumDepthNodes; ++DepthIndex) {
1108 7862656 : for (WidthIndex = 2; WidthIndex <= this->PipeNodeWidth; ++WidthIndex) {
1109 : // This will essentially erase the past iterations and revert back to the correct values
1110 5896992 : this->T(WidthIndex, DepthIndex, LengthIndex, TimeIndex::Tentative) =
1111 5896992 : this->T(WidthIndex, DepthIndex, LengthIndex, TimeIndex::Current);
1112 : }
1113 : }
1114 : }
1115 :
1116 : // Similarly for Hanby model arrays
1117 51728 : this->TentativeFluidTemp = this->FluidTemp;
1118 51728 : this->TentativePipeTemp = this->PipeTemp;
1119 : }
1120 :
1121 : // This still catches even in winter design day
1122 : // Even though the loop eventually has no flow rate, it appears it initializes to a value, then converges to OFF
1123 : // Thus, this is called at the beginning of every time step once.
1124 :
1125 58100 : this->FluidSpecHeat = GetSpecificHeatGlycol(state,
1126 58100 : state.dataPlnt->PlantLoop(this->plantLoc.loopNum).FluidName,
1127 58100 : state.dataPipeHT->nsvInletTemp,
1128 58100 : state.dataPlnt->PlantLoop(this->plantLoc.loopNum).FluidIndex,
1129 : RoutineName);
1130 58100 : this->FluidDensity = GetDensityGlycol(state,
1131 58100 : state.dataPlnt->PlantLoop(this->plantLoc.loopNum).FluidName,
1132 58100 : state.dataPipeHT->nsvInletTemp,
1133 58100 : state.dataPlnt->PlantLoop(this->plantLoc.loopNum).FluidIndex,
1134 : RoutineName);
1135 :
1136 : // At this point, for all Pipe:Interior objects we should zero out the energy and rate arrays
1137 58100 : this->FluidHeatLossRate = 0.0;
1138 58100 : this->FluidHeatLossEnergy = 0.0;
1139 58100 : this->EnvironmentHeatLossRate = 0.0;
1140 58100 : this->EnvHeatLossEnergy = 0.0;
1141 58100 : this->ZoneHeatGainRate = 0.0;
1142 58100 : state.dataPipeHT->nsvFluidHeatLossRate = 0.0;
1143 58100 : state.dataPipeHT->nsvEnvHeatLossRate = 0.0;
1144 58100 : state.dataPipeHT->nsvOutletTemp = 0.0;
1145 :
1146 58100 : if (this->FluidDensity > 0.0) {
1147 : // The density will only be zero the first time through, which will be a warmup day, and not reported
1148 58100 : state.dataPipeHT->nsvVolumeFlowRate = state.dataPipeHT->nsvMassFlowRate / this->FluidDensity;
1149 : }
1150 58100 : }
1151 :
1152 : //==============================================================================
1153 :
1154 4467317 : void PipeHTData::CalcPipesHeatTransfer(EnergyPlusData &state, ObjexxFCL::Optional_int_const LengthIndex)
1155 : {
1156 :
1157 : // AUTHOR Simon Rees
1158 : // DATE WRITTEN July 2007
1159 : // MODIFIED na
1160 : // RE-ENGINEERED na
1161 :
1162 : // PURPOSE OF THIS SUBROUTINE:
1163 : // This subroutine does all of the stuff that is necessary to simulate
1164 : // a Pipe Heat Transfer. Calls are made to appropriate routines
1165 : // for heat transfer coefficients
1166 :
1167 : // METHODOLOGY EMPLOYED:
1168 : // Differential equations for pipe and fluid nodes along the pipe are solved
1169 : // taking backward differences in time.
1170 : // The heat loss/gain calculations are run continuously, even when the loop is off.
1171 : // Fluid temps will drift according to environmental conditions when there is zero flow.
1172 :
1173 : // REFERENCES:
1174 :
1175 : // Using/Aliasing
1176 : using namespace DataEnvironment;
1177 :
1178 : // fluid node heat balance (see engineering doc).
1179 4467317 : Real64 A1(0.0); // sum of the heat balance terms
1180 4467317 : Real64 A2(0.0); // mass flow term
1181 4467317 : Real64 A3(0.0); // inside pipe wall convection term
1182 4467317 : Real64 A4(0.0); // fluid node heat capacity term
1183 : // pipe wall node heat balance (see engineering doc).
1184 4467317 : Real64 B1(0.0); // sum of the heat balance terms
1185 4467317 : Real64 B2(0.0); // inside pipe wall convection term
1186 4467317 : Real64 B3(0.0); // outside pipe wall convection term
1187 4467317 : Real64 B4(0.0); // fluid node heat capacity term
1188 :
1189 4467317 : Real64 AirConvCoef(0.0); // air-pipe convection coefficient
1190 4467317 : Real64 FluidConvCoef(0.0); // fluid-pipe convection coefficient
1191 4467317 : Real64 EnvHeatTransCoef(0.0); // external convection coefficient (outside pipe)
1192 4467317 : Real64 FluidNodeHeatCapacity(0.0); // local var for MCp for single node of pipe
1193 :
1194 4467317 : int PipeDepth(0);
1195 4467317 : int PipeWidth(0);
1196 : int curnode;
1197 : Real64 TempBelow;
1198 : Real64 TempBeside;
1199 : Real64 TempAbove;
1200 : Real64 Numerator;
1201 : Real64 Denominator;
1202 : Real64 SurfaceTemp;
1203 :
1204 : // traps fluid properties problems such as freezing conditions
1205 4467317 : if (this->FluidSpecHeat <= 0.0 || this->FluidDensity <= 0.0) {
1206 : // leave the state of the pipe as it was
1207 0 : state.dataPipeHT->nsvOutletTemp = this->TentativeFluidTemp(this->NumSections);
1208 : // set heat transfer rates to zero for consistency
1209 0 : state.dataPipeHT->nsvEnvHeatLossRate = 0.0;
1210 0 : state.dataPipeHT->nsvFluidHeatLossRate = 0.0;
1211 0 : return;
1212 : }
1213 :
1214 : // AirConvCoef = OutsidePipeHeatTransCoef(PipeHTNum)
1215 : // Revised by L. Gu by including insulation conductance 6/19/08
1216 :
1217 4467317 : if (this->EnvironmentPtr != EnvrnPtr::GroundEnv) {
1218 558537 : AirConvCoef = 1.0 / (1.0 / this->OutsidePipeHeatTransCoef(state) + this->InsulationResistance);
1219 : }
1220 :
1221 4467317 : FluidConvCoef = this->CalcPipeHeatTransCoef(state, state.dataPipeHT->nsvInletTemp, state.dataPipeHT->nsvMassFlowRate, this->PipeID);
1222 :
1223 : // heat transfer to air or ground
1224 4467317 : switch (this->EnvironmentPtr) {
1225 3908780 : case EnvrnPtr::GroundEnv: {
1226 : // Approximate conductance using ground conductivity, (h=k/L), where L is grid spacing
1227 : // between pipe wall and next closest node.
1228 3908780 : EnvHeatTransCoef = this->SoilConductivity / (this->dSregular - (this->PipeID / 2.0));
1229 3908780 : } break;
1230 186179 : case EnvrnPtr::OutsideAirEnv: {
1231 186179 : EnvHeatTransCoef = AirConvCoef;
1232 186179 : } break;
1233 186179 : case EnvrnPtr::ZoneEnv: {
1234 186179 : EnvHeatTransCoef = AirConvCoef;
1235 186179 : } break;
1236 186179 : case EnvrnPtr::ScheduleEnv: {
1237 186179 : EnvHeatTransCoef = AirConvCoef;
1238 186179 : } break;
1239 0 : case EnvrnPtr::None: {
1240 0 : EnvHeatTransCoef = 0.0;
1241 0 : } break;
1242 0 : default: {
1243 0 : EnvHeatTransCoef = 0.0;
1244 0 : } break;
1245 : }
1246 :
1247 : // work out the coefficients
1248 4467317 : FluidNodeHeatCapacity =
1249 4467317 : this->SectionArea * this->Length / this->NumSections * this->FluidSpecHeat * this->FluidDensity; // Mass of Node x Specific heat
1250 :
1251 : // coef of fluid heat balance
1252 4467317 : A1 = FluidNodeHeatCapacity + state.dataPipeHT->nsvMassFlowRate * this->FluidSpecHeat * state.dataPipeHT->nsvDeltaTime +
1253 4467317 : FluidConvCoef * this->InsideArea * state.dataPipeHT->nsvDeltaTime;
1254 :
1255 4467317 : A2 = state.dataPipeHT->nsvMassFlowRate * this->FluidSpecHeat * state.dataPipeHT->nsvDeltaTime;
1256 :
1257 4467317 : A3 = FluidConvCoef * this->InsideArea * state.dataPipeHT->nsvDeltaTime;
1258 :
1259 4467317 : A4 = FluidNodeHeatCapacity;
1260 :
1261 : // coef of pipe heat balance
1262 4467317 : B1 = this->PipeHeatCapacity + FluidConvCoef * this->InsideArea * state.dataPipeHT->nsvDeltaTime +
1263 4467317 : EnvHeatTransCoef * this->OutsideArea * state.dataPipeHT->nsvDeltaTime;
1264 :
1265 4467317 : B2 = A3;
1266 :
1267 4467317 : B3 = EnvHeatTransCoef * this->OutsideArea * state.dataPipeHT->nsvDeltaTime;
1268 :
1269 4467317 : B4 = this->PipeHeatCapacity;
1270 :
1271 4467317 : this->TentativeFluidTemp(0) = state.dataPipeHT->nsvInletTemp;
1272 :
1273 4467317 : this->TentativePipeTemp(0) = this->PipeTemp(1); // for convenience
1274 :
1275 4467317 : if (present(LengthIndex)) { // Just simulate the single section if being called from Pipe:Underground
1276 :
1277 3908780 : PipeDepth = this->PipeNodeDepth;
1278 3908780 : PipeWidth = this->PipeNodeWidth;
1279 3908780 : TempBelow = this->T(PipeWidth, PipeDepth + 1, LengthIndex, TimeIndex::Current);
1280 3908780 : TempBeside = this->T(PipeWidth - 1, PipeDepth, LengthIndex, TimeIndex::Current);
1281 3908780 : TempAbove = this->T(PipeWidth, PipeDepth - 1, LengthIndex, TimeIndex::Current);
1282 3908780 : state.dataPipeHT->nsvEnvironmentTemp = (TempBelow + TempBeside + TempAbove) / 3.0;
1283 :
1284 7817560 : this->TentativeFluidTemp(LengthIndex) = (A2 * this->TentativeFluidTemp(LengthIndex - 1) +
1285 3908780 : A3 / B1 * (B3 * state.dataPipeHT->nsvEnvironmentTemp + B4 * this->PreviousPipeTemp(LengthIndex)) +
1286 3908780 : A4 * this->PreviousFluidTemp(LengthIndex)) /
1287 3908780 : (A1 - A3 * B2 / B1);
1288 :
1289 3908780 : this->TentativePipeTemp(LengthIndex) =
1290 3908780 : (B2 * this->TentativeFluidTemp(LengthIndex) + B3 * state.dataPipeHT->nsvEnvironmentTemp + B4 * this->PreviousPipeTemp(LengthIndex)) / B1;
1291 :
1292 : // Get exterior surface temperature from energy balance at the surface
1293 3908780 : Numerator = state.dataPipeHT->nsvEnvironmentTemp - this->TentativeFluidTemp(LengthIndex);
1294 3908780 : Denominator = EnvHeatTransCoef * ((1 / EnvHeatTransCoef) + this->SumTK);
1295 3908780 : SurfaceTemp = state.dataPipeHT->nsvEnvironmentTemp - Numerator / Denominator;
1296 :
1297 : // keep track of environmental heat loss rate - not same as fluid loss at same time
1298 3908780 : state.dataPipeHT->nsvEnvHeatLossRate += EnvHeatTransCoef * this->OutsideArea * (SurfaceTemp - state.dataPipeHT->nsvEnvironmentTemp);
1299 :
1300 : } else { // Simulate all sections at once if not pipe:underground
1301 :
1302 : // start loop along pipe
1303 : // b1 must not be zero but this should have been checked on input
1304 11729277 : for (curnode = 1; curnode <= this->NumSections; ++curnode) {
1305 11170740 : this->TentativeFluidTemp(curnode) = (A2 * this->TentativeFluidTemp(curnode - 1) +
1306 11170740 : A3 / B1 * (B3 * state.dataPipeHT->nsvEnvironmentTemp + B4 * this->PreviousPipeTemp(curnode)) +
1307 11170740 : A4 * this->PreviousFluidTemp(curnode)) /
1308 11170740 : (A1 - A3 * B2 / B1);
1309 :
1310 22341480 : this->TentativePipeTemp(curnode) =
1311 11170740 : (B2 * this->TentativeFluidTemp(curnode) + B3 * state.dataPipeHT->nsvEnvironmentTemp + B4 * this->PreviousPipeTemp(curnode)) / B1;
1312 :
1313 : // Get exterior surface temperature from energy balance at the surface
1314 11170740 : Numerator = state.dataPipeHT->nsvEnvironmentTemp - this->TentativeFluidTemp(curnode);
1315 11170740 : Denominator = EnvHeatTransCoef * ((1 / EnvHeatTransCoef) + this->SumTK);
1316 11170740 : SurfaceTemp = state.dataPipeHT->nsvEnvironmentTemp - Numerator / Denominator;
1317 :
1318 : // Keep track of environmental heat loss
1319 11170740 : state.dataPipeHT->nsvEnvHeatLossRate += EnvHeatTransCoef * this->OutsideArea * (SurfaceTemp - state.dataPipeHT->nsvEnvironmentTemp);
1320 : }
1321 : }
1322 :
1323 8934634 : state.dataPipeHT->nsvFluidHeatLossRate =
1324 4467317 : state.dataPipeHT->nsvMassFlowRate * this->FluidSpecHeat * (this->TentativeFluidTemp(0) - this->TentativeFluidTemp(this->NumSections));
1325 :
1326 4467317 : state.dataPipeHT->nsvOutletTemp = this->TentativeFluidTemp(this->NumSections);
1327 : }
1328 :
1329 : //==============================================================================
1330 :
1331 186179 : void PipeHTData::CalcBuriedPipeSoil(EnergyPlusData &state) // Current Simulation Pipe Number
1332 : {
1333 :
1334 : // AUTHOR Edwin Lee
1335 : // DATE WRITTEN May 2008
1336 : // MODIFIED na
1337 : // RE-ENGINEERED na
1338 :
1339 : // PURPOSE OF THIS SUBROUTINE:
1340 : // This subroutine does all of the stuff that is necessary to simulate
1341 : // soil heat transfer with a Buried Pipe.
1342 :
1343 : // METHODOLOGY EMPLOYED:
1344 : // An implicit pseudo 3D finite difference grid
1345 : // is set up, which simulates transient behavior in the soil.
1346 : // This then interfaces with the Hanby model for near-pipe region
1347 :
1348 : // Using/Aliasing
1349 : using Convect::CalcASHRAESimpExtConvCoeff;
1350 :
1351 : // SUBROUTINE PARAMETER DEFINITIONS:
1352 186179 : int constexpr NumSections(20);
1353 186179 : Real64 constexpr ConvCrit(0.05);
1354 186179 : int constexpr MaxIterations(200);
1355 186179 : Real64 constexpr StefBoltzmann(5.6697e-08); // Stefan-Boltzmann constant
1356 :
1357 : // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
1358 186179 : int IterationIndex(0); // Index when stepping through equations
1359 186179 : int LengthIndex(0); // Index for nodes along length of pipe
1360 186179 : int DepthIndex(0); // Index for nodes in the depth direction
1361 186179 : int WidthIndex(0); // Index for nodes in the width direction
1362 186179 : Real64 ConvCoef(0.0); // Current convection coefficient = f(Wind Speed,Roughness)
1363 186179 : Real64 RadCoef(0.0); // Current radiation coefficient
1364 186179 : Real64 QSolAbsorbed(0.0); // Current total solar energy absorbed
1365 372358 : Array3D<Real64> T_O(this->PipeNodeWidth, this->NumDepthNodes, NumSections);
1366 :
1367 : // Local variable placeholders for code readability
1368 186179 : Real64 A1(0.0); // Placeholder for CoefA1
1369 186179 : Real64 A2(0.0); // Placeholder for CoefA2
1370 186179 : Real64 NodeBelow(0.0); // Placeholder for Node temp below current node
1371 186179 : Real64 NodeAbove(0.0); // Placeholder for Node temp above current node
1372 186179 : Real64 NodeRight(0.0); // Placeholder for Node temp to the right of current node
1373 186179 : Real64 NodeLeft(0.0); // Placeholder for Node temp to the left of current node
1374 186179 : Real64 NodePast(0.0); // Placeholder for Node temp at current node but previous time step
1375 186179 : Real64 PastNodeTempAbs(0.0); // Placeholder for absolute temperature (K) version of NodePast
1376 186179 : Real64 Ttemp(0.0); // Placeholder for a current temperature node in convergence check
1377 186179 : Real64 SkyTempAbs(0.0); // Placeholder for current sky temperature in Kelvin
1378 186179 : Material::SurfaceRoughness TopRoughness(Material::SurfaceRoughness::Invalid); // Placeholder for soil surface roughness
1379 186179 : Real64 TopThermAbs(0.0); // Placeholder for soil thermal radiation absorptivity
1380 186179 : Real64 TopSolarAbs(0.0); // Placeholder for soil solar radiation absorptivity
1381 186179 : Real64 kSoil(0.0); // Placeholder for soil conductivity
1382 186179 : Real64 dS(0.0); // Placeholder for soil grid spacing
1383 186179 : Real64 rho(0.0); // Placeholder for soil density
1384 186179 : Real64 Cp(0.0); // Placeholder for soil specific heat
1385 :
1386 : // There are a number of coefficients which change through the simulation, and they are updated here
1387 186179 : this->FourierDS = this->SoilDiffusivity * state.dataPipeHT->nsvDeltaTime / pow_2(this->dSregular); // Eq. D4
1388 186179 : this->CoefA1 = this->FourierDS / (1 + 4 * this->FourierDS); // Eq. D2
1389 186179 : this->CoefA2 = 1 / (1 + 4 * this->FourierDS); // Eq. D3
1390 :
1391 195439 : for (IterationIndex = 1; IterationIndex <= MaxIterations; ++IterationIndex) {
1392 195439 : if (IterationIndex == MaxIterations) {
1393 0 : ShowWarningError(state, format("BuriedPipeHeatTransfer: Large number of iterations detected in object: {}", this->Name));
1394 : }
1395 :
1396 : // Store computed values in T_O array
1397 3908780 : for (LengthIndex = 2; LengthIndex <= this->NumSections; ++LengthIndex) {
1398 29706728 : for (DepthIndex = 1; DepthIndex <= this->NumDepthNodes - 1; ++DepthIndex) {
1399 103973548 : for (WidthIndex = 2; WidthIndex <= this->PipeNodeWidth; ++WidthIndex) {
1400 77980161 : T_O(WidthIndex, DepthIndex, LengthIndex) = this->T(WidthIndex, DepthIndex, LengthIndex, TimeIndex::Tentative);
1401 : }
1402 : }
1403 : }
1404 :
1405 : // Loop along entire length of pipe, analyzing cross sects
1406 4104219 : for (LengthIndex = 1; LengthIndex <= this->NumSections; ++LengthIndex) {
1407 31270240 : for (DepthIndex = 1; DepthIndex <= this->NumDepthNodes - 1; ++DepthIndex) {
1408 109445840 : for (WidthIndex = 2; WidthIndex <= this->PipeNodeWidth; ++WidthIndex) {
1409 :
1410 82084380 : if (DepthIndex == 1) { // Soil Surface Boundary
1411 :
1412 : // If on soil boundary, load up local variables and perform calculations
1413 11726340 : NodePast = this->T(WidthIndex, DepthIndex, LengthIndex, TimeIndex::Previous);
1414 11726340 : PastNodeTempAbs = NodePast + Constant::Kelvin;
1415 11726340 : SkyTempAbs = state.dataEnvrn->SkyTemp + Constant::Kelvin;
1416 11726340 : TopRoughness = this->SoilRoughness;
1417 11726340 : TopThermAbs = this->SoilThermAbs;
1418 11726340 : TopSolarAbs = this->SoilSolarAbs;
1419 11726340 : kSoil = this->SoilConductivity;
1420 11726340 : dS = this->dSregular;
1421 11726340 : rho = this->SoilDensity;
1422 11726340 : Cp = this->SoilCp;
1423 :
1424 : // ASHRAE simple convection coefficient model for external surfaces.
1425 11726340 : this->OutdoorConvCoef = CalcASHRAESimpExtConvCoeff(TopRoughness, state.dataEnvrn->WindSpeed);
1426 11726340 : ConvCoef = this->OutdoorConvCoef;
1427 :
1428 : // thermal radiation coefficient using surf temp from past time step
1429 11726340 : if (std::abs(PastNodeTempAbs - SkyTempAbs) > Constant::rTinyValue) {
1430 11726340 : RadCoef = StefBoltzmann * TopThermAbs * (pow_4(PastNodeTempAbs) - pow_4(SkyTempAbs)) / (PastNodeTempAbs - SkyTempAbs);
1431 : } else {
1432 0 : RadCoef = 0.0;
1433 : }
1434 :
1435 : // total absorbed solar - no ground solar
1436 11726340 : QSolAbsorbed =
1437 11726340 : TopSolarAbs * (max(state.dataEnvrn->SOLCOS(3), 0.0) * state.dataEnvrn->BeamSolarRad + state.dataEnvrn->DifSolarRad);
1438 :
1439 : // If sun is not exposed, then turn off both solar and thermal radiation
1440 11726340 : if (!this->SolarExposed) {
1441 0 : RadCoef = 0.0;
1442 0 : QSolAbsorbed = 0.0;
1443 : }
1444 :
1445 11726340 : if (WidthIndex == this->PipeNodeWidth) { // Symmetric centerline boundary
1446 :
1447 : //-Coefficients and Temperatures
1448 3908780 : NodeBelow = this->T(WidthIndex, DepthIndex + 1, LengthIndex, TimeIndex::Current);
1449 3908780 : NodeLeft = this->T(WidthIndex - 1, DepthIndex, LengthIndex, TimeIndex::Current);
1450 :
1451 : //-Update Equation, basically a detailed energy balance at the surface
1452 3908780 : this->T(WidthIndex, DepthIndex, LengthIndex, TimeIndex::Tentative) =
1453 3908780 : (QSolAbsorbed + RadCoef * state.dataEnvrn->SkyTemp + ConvCoef * state.dataEnvrn->OutDryBulbTemp +
1454 3908780 : (kSoil / dS) * (NodeBelow + 2 * NodeLeft) + (rho * Cp / state.dataPipeHT->nsvDeltaTime) * NodePast) /
1455 3908780 : (RadCoef + ConvCoef + 3 * (kSoil / dS) + (rho * Cp / state.dataPipeHT->nsvDeltaTime));
1456 :
1457 : } else { // Soil surface, but not on centerline
1458 :
1459 : //-Coefficients and Temperatures
1460 7817560 : NodeBelow = this->T(WidthIndex, DepthIndex + 1, LengthIndex, TimeIndex::Current);
1461 7817560 : NodeLeft = this->T(WidthIndex - 1, DepthIndex, LengthIndex, TimeIndex::Current);
1462 7817560 : NodeRight = this->T(WidthIndex + 1, DepthIndex, LengthIndex, TimeIndex::Current);
1463 :
1464 : //-Update Equation
1465 7817560 : this->T(WidthIndex, DepthIndex, LengthIndex, TimeIndex::Tentative) =
1466 7817560 : (QSolAbsorbed + RadCoef * state.dataEnvrn->SkyTemp + ConvCoef * state.dataEnvrn->OutDryBulbTemp +
1467 7817560 : (kSoil / dS) * (NodeBelow + NodeLeft + NodeRight) + (rho * Cp / state.dataPipeHT->nsvDeltaTime) * NodePast) /
1468 7817560 : (RadCoef + ConvCoef + 3 * (kSoil / dS) + (rho * Cp / state.dataPipeHT->nsvDeltaTime));
1469 :
1470 : } // Soil-to-air surface node structure
1471 :
1472 70358040 : } else if (WidthIndex == this->PipeNodeWidth) { // On Symmetric centerline boundary
1473 :
1474 23452680 : if (DepthIndex == this->PipeNodeDepth) { // On the node containing the pipe
1475 :
1476 : //-Call to simulate a single pipe segment (by passing OPTIONAL LengthIndex argument)
1477 3908780 : this->CalcPipesHeatTransfer(state, LengthIndex);
1478 :
1479 : //-Update node for cartesian system
1480 3908780 : this->T(WidthIndex, DepthIndex, LengthIndex, TimeIndex::Tentative) = this->PipeTemp(LengthIndex);
1481 :
1482 19543900 : } else if (DepthIndex != 1) { // Not surface node
1483 :
1484 : //-Coefficients and Temperatures
1485 19543900 : NodeLeft = this->T(WidthIndex - 1, DepthIndex, LengthIndex, TimeIndex::Current);
1486 19543900 : NodeAbove = this->T(WidthIndex, DepthIndex - 1, LengthIndex, TimeIndex::Current);
1487 19543900 : NodeBelow = this->T(WidthIndex, DepthIndex + 1, LengthIndex, TimeIndex::Current);
1488 19543900 : NodePast = this->T(WidthIndex, DepthIndex, LengthIndex, TimeIndex::Current - 1);
1489 19543900 : A1 = this->CoefA1;
1490 19543900 : A2 = this->CoefA2;
1491 :
1492 : //-Update Equation
1493 19543900 : this->T(WidthIndex, DepthIndex, LengthIndex, TimeIndex::Tentative) =
1494 19543900 : A1 * (NodeBelow + NodeAbove + 2 * NodeLeft) + A2 * NodePast;
1495 :
1496 : } // Symmetric centerline node structure
1497 :
1498 : } else { // All Normal Interior Nodes
1499 :
1500 : //-Coefficients and Temperatures
1501 46905360 : A1 = this->CoefA1;
1502 46905360 : A2 = this->CoefA2;
1503 46905360 : NodeBelow = this->T(WidthIndex, DepthIndex + 1, LengthIndex, TimeIndex::Current);
1504 46905360 : NodeAbove = this->T(WidthIndex, DepthIndex - 1, LengthIndex, TimeIndex::Current);
1505 46905360 : NodeRight = this->T(WidthIndex + 1, DepthIndex, LengthIndex, TimeIndex::Current);
1506 46905360 : NodeLeft = this->T(WidthIndex - 1, DepthIndex, LengthIndex, TimeIndex::Current);
1507 46905360 : NodePast = this->T(WidthIndex, DepthIndex, LengthIndex, TimeIndex::Current - 1);
1508 :
1509 : //-Update Equation
1510 46905360 : this->T(WidthIndex, DepthIndex, LengthIndex, TimeIndex::Tentative) =
1511 46905360 : A1 * (NodeBelow + NodeAbove + NodeRight + NodeLeft) + A2 * NodePast; // Eq. D1
1512 : }
1513 : }
1514 : }
1515 : }
1516 :
1517 : // Check for convergence
1518 3739744 : for (LengthIndex = 2; LengthIndex <= this->NumSections; ++LengthIndex) {
1519 28372256 : for (DepthIndex = 1; DepthIndex <= this->NumDepthNodes - 1; ++DepthIndex) {
1520 99289775 : for (WidthIndex = 2; WidthIndex <= this->PipeNodeWidth; ++WidthIndex) {
1521 74471084 : Ttemp = this->T(WidthIndex, DepthIndex, LengthIndex, TimeIndex::Tentative);
1522 74471084 : if (std::abs(T_O(WidthIndex, DepthIndex, LengthIndex) - Ttemp) > ConvCrit) goto IterationLoop_loop;
1523 : }
1524 : }
1525 : }
1526 :
1527 : // If we didn't cycle back, then the system is converged
1528 : // PipeHT(PipeHTNum)%PipeUGIters=IterationIndex
1529 186179 : goto IterationLoop_exit;
1530 :
1531 9260 : IterationLoop_loop:;
1532 : }
1533 0 : IterationLoop_exit:;
1534 186179 : }
1535 :
1536 : //==============================================================================
1537 :
1538 58100 : void PipeHTData::UpdatePipesHeatTransfer(EnergyPlusData &state)
1539 : {
1540 :
1541 : // SUBROUTINE INFORMATION:
1542 : // AUTHOR Simon Rees
1543 : // DATE WRITTEN July 2007
1544 : // MODIFIED na
1545 : // RE-ENGINEERED na
1546 :
1547 : // PURPOSE OF THIS SUBROUTINE:
1548 : // This subroutine does any updating that needs to be done for
1549 : // Pipe Heat Transfers. This routine must also set the outlet water conditions.
1550 :
1551 : // METHODOLOGY EMPLOYED:
1552 :
1553 : // REFERENCES:
1554 : // na
1555 :
1556 : // SUBROUTINE ARGUMENT DEFINITIONS:
1557 : // INTEGER, INTENT(IN) :: PipeHTNum ! Index for the surface
1558 :
1559 : // SUBROUTINE PARAMETER DEFINITIONS:
1560 :
1561 : // INTERFACE BLOCK SPECIFICATIONS
1562 : // na
1563 :
1564 : // DERIVED TYPE DEFINITIONS
1565 : // na
1566 :
1567 : // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
1568 :
1569 : // only outlet node temp should need updating
1570 58100 : state.dataLoopNodes->Node(state.dataPipeHT->nsvOutletNodeNum).Temp = state.dataPipeHT->nsvOutletTemp;
1571 :
1572 : // pass everything else through
1573 58100 : state.dataLoopNodes->Node(state.dataPipeHT->nsvOutletNodeNum).TempMin = state.dataLoopNodes->Node(state.dataPipeHT->nsvInletNodeNum).TempMin;
1574 58100 : state.dataLoopNodes->Node(state.dataPipeHT->nsvOutletNodeNum).TempMax = state.dataLoopNodes->Node(state.dataPipeHT->nsvInletNodeNum).TempMax;
1575 58100 : state.dataLoopNodes->Node(state.dataPipeHT->nsvOutletNodeNum).MassFlowRate =
1576 58100 : state.dataLoopNodes->Node(state.dataPipeHT->nsvInletNodeNum).MassFlowRate;
1577 58100 : state.dataLoopNodes->Node(state.dataPipeHT->nsvOutletNodeNum).MassFlowRateMin =
1578 58100 : state.dataLoopNodes->Node(state.dataPipeHT->nsvInletNodeNum).MassFlowRateMin;
1579 58100 : state.dataLoopNodes->Node(state.dataPipeHT->nsvOutletNodeNum).MassFlowRateMax =
1580 58100 : state.dataLoopNodes->Node(state.dataPipeHT->nsvInletNodeNum).MassFlowRateMax;
1581 58100 : state.dataLoopNodes->Node(state.dataPipeHT->nsvOutletNodeNum).MassFlowRateMinAvail =
1582 58100 : state.dataLoopNodes->Node(state.dataPipeHT->nsvInletNodeNum).MassFlowRateMinAvail;
1583 58100 : state.dataLoopNodes->Node(state.dataPipeHT->nsvOutletNodeNum).MassFlowRateMaxAvail =
1584 58100 : state.dataLoopNodes->Node(state.dataPipeHT->nsvInletNodeNum).MassFlowRateMaxAvail;
1585 58100 : state.dataLoopNodes->Node(state.dataPipeHT->nsvOutletNodeNum).Quality = state.dataLoopNodes->Node(state.dataPipeHT->nsvInletNodeNum).Quality;
1586 : // Only pass pressure if we aren't doing a pressure simulation
1587 58100 : switch (state.dataPlnt->PlantLoop(this->plantLoc.loopNum).PressureSimType) {
1588 58100 : case DataPlant::PressSimType::NoPressure:
1589 58100 : state.dataLoopNodes->Node(state.dataPipeHT->nsvOutletNodeNum).Press = state.dataLoopNodes->Node(state.dataPipeHT->nsvInletNodeNum).Press;
1590 58100 : break;
1591 0 : default:
1592 : // Don't do anything
1593 0 : break;
1594 : }
1595 58100 : state.dataLoopNodes->Node(state.dataPipeHT->nsvOutletNodeNum).Enthalpy = state.dataLoopNodes->Node(state.dataPipeHT->nsvInletNodeNum).Enthalpy;
1596 58100 : state.dataLoopNodes->Node(state.dataPipeHT->nsvOutletNodeNum).HumRat = state.dataLoopNodes->Node(state.dataPipeHT->nsvInletNodeNum).HumRat;
1597 58100 : }
1598 :
1599 : //==============================================================================
1600 :
1601 58100 : void PipeHTData::ReportPipesHeatTransfer(EnergyPlusData &state)
1602 : {
1603 :
1604 : // SUBROUTINE INFORMATION:
1605 : // AUTHOR Simon Rees
1606 : // DATE WRITTEN July 2007
1607 : // MODIFIED na
1608 : // RE-ENGINEERED na
1609 :
1610 : // PURPOSE OF THIS SUBROUTINE:
1611 : // This subroutine simply updates the report data
1612 :
1613 : // METHODOLOGY EMPLOYED:
1614 : // Standard EnergyPlus methodology.
1615 :
1616 : // REFERENCES:
1617 : // na
1618 :
1619 : // USE STATEMENTS:
1620 :
1621 : // Locals
1622 : // SUBROUTINE ARGUMENT DEFINITIONS:
1623 :
1624 : // SUBROUTINE PARAMETER DEFINITIONS:
1625 : // na
1626 :
1627 : // INTERFACE BLOCK SPECIFICATIONS
1628 : // na
1629 :
1630 : // DERIVED TYPE DEFINITIONS
1631 : // na
1632 :
1633 : // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
1634 :
1635 : // update flows and temps from module variables
1636 58100 : this->FluidInletTemp = state.dataPipeHT->nsvInletTemp;
1637 58100 : this->FluidOutletTemp = state.dataPipeHT->nsvOutletTemp;
1638 58100 : this->MassFlowRate = state.dataPipeHT->nsvMassFlowRate;
1639 58100 : this->VolumeFlowRate = state.dataPipeHT->nsvVolumeFlowRate;
1640 :
1641 : // update other variables from module variables
1642 58100 : this->FluidHeatLossRate = state.dataPipeHT->nsvFluidHeatLossRate;
1643 58100 : this->FluidHeatLossEnergy = state.dataPipeHT->nsvFluidHeatLossRate * state.dataPipeHT->nsvDeltaTime; // DeltaTime is in seconds
1644 58100 : this->PipeInletTemp = this->PipeTemp(1);
1645 58100 : this->PipeOutletTemp = this->PipeTemp(this->NumSections);
1646 :
1647 : // need to average the heat rate because it is now summing over multiple inner time steps
1648 58100 : this->EnvironmentHeatLossRate = state.dataPipeHT->nsvEnvHeatLossRate / state.dataPipeHT->nsvNumInnerTimeSteps;
1649 58100 : this->EnvHeatLossEnergy = this->EnvironmentHeatLossRate * state.dataPipeHT->nsvDeltaTime;
1650 :
1651 : // for zone heat gains, we assign the averaged heat rate over all inner time steps
1652 58100 : if (this->EnvironmentPtr == EnvrnPtr::ZoneEnv) {
1653 14525 : this->ZoneHeatGainRate = this->EnvironmentHeatLossRate;
1654 : }
1655 58100 : }
1656 :
1657 : //==============================================================================
1658 :
1659 2804678 : void PipeHTData::CalcZonePipesHeatGain(EnergyPlusData &state)
1660 : {
1661 :
1662 : // SUBROUTINE INFORMATION:
1663 : // AUTHOR Edwin Lee
1664 : // DATE WRITTEN September 2008
1665 : // MODIFIED
1666 : // RE-ENGINEERED na
1667 :
1668 : // PURPOSE OF THIS SUBROUTINE:
1669 : // Calculates the zone internal gains due to pipe heat transfer objects.
1670 :
1671 : // METHODOLOGY EMPLOYED:
1672 : // Sums the heat losses from all of the water heaters in the zone to add as a gain to the zone.
1673 :
1674 : // Using/Aliasing
1675 2804678 : if (state.dataPipeHT->nsvNumOfPipeHT == 0) return;
1676 :
1677 10808 : if (state.dataGlobal->BeginEnvrnFlag && state.dataPipeHT->MyEnvrnFlag) {
1678 64 : for (auto &e : state.dataPipeHT->PipeHT)
1679 32 : e.ZoneHeatGainRate = 0.0;
1680 32 : state.dataPipeHT->MyEnvrnFlag = false;
1681 : }
1682 :
1683 10808 : if (!state.dataGlobal->BeginEnvrnFlag) state.dataPipeHT->MyEnvrnFlag = true;
1684 : }
1685 :
1686 : //==============================================================================
1687 :
1688 4467317 : Real64 PipeHTData::CalcPipeHeatTransCoef(EnergyPlusData &state,
1689 : Real64 const Temperature, // Temperature of water entering the surface, in C
1690 : Real64 const MassFlowRate, // Mass flow rate, in kg/s
1691 : Real64 const Diameter // Pipe diameter, m
1692 : )
1693 : {
1694 :
1695 : // FUNCTION INFORMATION:
1696 : // AUTHOR Simon Rees
1697 : // DATE WRITTEN July 2007
1698 : // MODIFIED na
1699 : // RE-ENGINEERED na
1700 :
1701 : // PURPOSE OF THIS SUBROUTINE:
1702 : // This subroutine calculates pipe/fluid heat transfer coefficients.
1703 : // This routine is adapted from that in the low temp radiant surface model.
1704 :
1705 : // METHODOLOGY EMPLOYED:
1706 : // Currently assumes water data when calculating Pr and Re
1707 :
1708 : // REFERENCES:
1709 : // See RadiantSystemLowTemp module.
1710 : // Property data for water shown below as parameters taken from
1711 : // Incropera and DeWitt, Introduction to Heat Transfer, Table A.6.
1712 : // Heat exchanger information also from Incropera and DeWitt.
1713 : // Code based loosely on code from IBLAST program (research version)
1714 :
1715 : // Using/Aliasing
1716 : using FluidProperties::GetConductivityGlycol;
1717 : using FluidProperties::GetViscosityGlycol;
1718 :
1719 : // Return value
1720 : Real64 CalcPipeHeatTransCoef;
1721 :
1722 : // Locals
1723 : // SUBROUTINE ARGUMENT DEFINITIONS:
1724 :
1725 : // SUBROUTINE PARAMETER DEFINITIONS:
1726 : static constexpr std::string_view RoutineName("PipeHeatTransfer::CalcPipeHeatTransCoef: ");
1727 4467317 : Real64 constexpr MaxLaminarRe(2300.0); // Maximum Reynolds number for laminar flow
1728 4467317 : int constexpr NumOfPropDivisions(13); // intervals in property correlation
1729 : static constexpr std::array<Real64, NumOfPropDivisions> Temps = {
1730 : 1.85, 6.85, 11.85, 16.85, 21.85, 26.85, 31.85, 36.85, 41.85, 46.85, 51.85, 56.85, 61.85}; // Temperature, in C
1731 : static constexpr std::array<Real64, NumOfPropDivisions> Pr = {
1732 : 12.22, 10.26, 8.81, 7.56, 6.62, 5.83, 5.20, 4.62, 4.16, 3.77, 3.42, 3.15, 2.88}; // Prandtl number (dimensionless)
1733 :
1734 : // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
1735 : Real64 InterpFrac;
1736 : Real64 NuD;
1737 : Real64 ReD;
1738 : Real64 Kactual;
1739 : Real64 MUactual;
1740 : Real64 PRactual;
1741 : int LoopNum;
1742 :
1743 : // retrieve loop index for this component so we can look up fluid properties
1744 4467317 : LoopNum = this->plantLoc.loopNum;
1745 :
1746 : // since the fluid properties routine doesn't have Prandtl, we'll just use water values
1747 4467317 : int idx = 0;
1748 20129911 : while (idx < NumOfPropDivisions) {
1749 20129911 : if (Temperature < Temps[idx]) {
1750 4467317 : break;
1751 : }
1752 15662594 : ++idx;
1753 : }
1754 :
1755 4467317 : if (idx == 0) {
1756 0 : PRactual = Pr[idx];
1757 4467317 : } else if (idx >= NumOfPropDivisions) {
1758 0 : PRactual = Pr[NumOfPropDivisions - 1];
1759 : } else {
1760 4467317 : InterpFrac = (Temperature - Temps[idx - 1]) / (Temps[idx] - Temps[idx - 1]);
1761 4467317 : PRactual = Pr[idx - 1] + InterpFrac * (Pr[idx] - Pr[idx - 1]);
1762 : }
1763 :
1764 : // look up conductivity and viscosity
1765 4467317 : Kactual = GetConductivityGlycol(
1766 4467317 : state, state.dataPlnt->PlantLoop(LoopNum).FluidName, this->FluidTemp(0), state.dataPlnt->PlantLoop(LoopNum).FluidIndex, RoutineName); // W/m-K
1767 4467317 : MUactual =
1768 4467317 : GetViscosityGlycol(
1769 4467317 : state, state.dataPlnt->PlantLoop(LoopNum).FluidName, this->FluidTemp(0), state.dataPlnt->PlantLoop(LoopNum).FluidIndex, RoutineName) /
1770 : 1000.0; // Note fluid properties routine returns mPa-s, we need Pa-s
1771 :
1772 : // Calculate the Reynold's number from RE=(4*Mdot)/(Pi*Mu*Diameter) - as RadiantSysLowTemp
1773 4467317 : ReD = 4.0 * MassFlowRate / (Constant::Pi * MUactual * Diameter);
1774 :
1775 4467317 : if (ReD == 0.0) { // No flow
1776 :
1777 : // For now just leave it how it was doing it before
1778 1938541 : NuD = 3.66;
1779 : // Although later it would be nice to have a natural convection correlation
1780 :
1781 : } else { // Calculate the Nusselt number based on what flow regime one is in
1782 :
1783 2528776 : if (ReD >= MaxLaminarRe) { // Turbulent flow --> use Colburn equation
1784 2528776 : NuD = 0.023 * std::pow(ReD, 0.8) * std::pow(PRactual, 1.0 / 3.0);
1785 : } else { // Laminar flow --> use constant surface temperature relation
1786 0 : NuD = 3.66;
1787 : }
1788 : }
1789 :
1790 4467317 : CalcPipeHeatTransCoef = Kactual * NuD / Diameter;
1791 :
1792 4467317 : return CalcPipeHeatTransCoef;
1793 : }
1794 :
1795 : //==============================================================================
1796 :
1797 558537 : Real64 PipeHTData::OutsidePipeHeatTransCoef(EnergyPlusData &state)
1798 : {
1799 :
1800 : // FUNCTION INFORMATION:
1801 : // AUTHOR Dan Fisher
1802 : // DATE WRITTEN July 2007
1803 : // MODIFIED na
1804 : // RE-ENGINEERED na
1805 :
1806 : // PURPOSE OF THIS SUBROUTINE:
1807 : // This subroutine calculates the convection heat transfer
1808 : // coefficient for a cylinder in cross flow.
1809 :
1810 : // REFERENCES:
1811 : // Fundamentals of Heat and Mass Transfer: Incropera and DeWitt, 4th ed.
1812 : // p. 369-370 (Eq. 7:55b)
1813 :
1814 : // Using/Aliasing
1815 : using ScheduleManager::GetCurrentScheduleValue;
1816 :
1817 : // Return value
1818 : Real64 OutsidePipeHeatTransCoef;
1819 :
1820 : // SUBROUTINE PARAMETER DEFINITIONS:
1821 558537 : Real64 constexpr Pr(0.7); // Prandl number for air (assume constant)
1822 558537 : Real64 constexpr CondAir(0.025); // thermal conductivity of air (assume constant) [W/m.K]
1823 558537 : Real64 constexpr RoomAirVel(0.381); // room air velocity of 75 ft./min [m/s]
1824 558537 : Real64 constexpr NaturalConvNusselt(0.36);
1825 : // Nusselt for natural convection for horizontal cylinder
1826 : // from: Correlations for Convective Heat Transfer
1827 : // Dr. Bernhard Spang
1828 : // Chemical Engineers' Resource Page: http://www.cheresources.com/convection.pdf
1829 558537 : int constexpr NumOfParamDivisions(5); // intervals in property correlation
1830 558537 : int constexpr NumOfPropDivisions(12); // intervals in property correlation
1831 :
1832 : static constexpr std::array<Real64, NumOfParamDivisions> CCoef = {0.989, 0.911, 0.683, 0.193, 0.027}; // correlation coefficient
1833 : static constexpr std::array<Real64, NumOfParamDivisions> mExp = {0.33, 0.385, 0.466, 0.618, 0.805}; // exponent
1834 : static constexpr std::array<Real64, NumOfParamDivisions> UpperBound = {4.0, 40.0, 4000.0, 40000.0, 400000.0}; // upper bound of correlation range
1835 : static constexpr std::array<Real64, NumOfPropDivisions> Temperature = {
1836 : -73.0, -23.0, -10.0, 0.0, 10.0, 20.0, 27.0, 30.0, 40.0, 50.0, 76.85, 126.85}; // temperature [C]
1837 : static constexpr std::array<Real64, NumOfPropDivisions> DynVisc = {
1838 : 75.52e-7, 11.37e-6, 12.44e-6, 13.3e-6, 14.18e-6, 15.08e-6, 15.75e-6, 16e-6, 16.95e-6, 17.91e-6, 20.92e-6, 26.41e-6}; // dynamic
1839 : // viscosity
1840 : // [m^2/s]
1841 :
1842 : // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
1843 : int idx;
1844 : Real64 NuD;
1845 : Real64 ReD;
1846 : Real64 Coef;
1847 : Real64 rExp;
1848 : Real64 AirVisc;
1849 : Real64 AirVel;
1850 : Real64 AirTemp;
1851 : Real64 PipeOD;
1852 : bool ViscositySet;
1853 : bool CoefSet;
1854 :
1855 : // Set environmental variables
1856 558537 : switch (this->Type) {
1857 372358 : case DataPlant::PlantEquipmentType::PipeInterior: {
1858 372358 : switch (this->EnvironmentPtr) {
1859 186179 : case EnvrnPtr::ScheduleEnv: {
1860 186179 : AirTemp = GetCurrentScheduleValue(state, this->EnvrSchedPtr);
1861 186179 : AirVel = GetCurrentScheduleValue(state, this->EnvrVelSchedPtr);
1862 186179 : } break;
1863 186179 : case EnvrnPtr::ZoneEnv: {
1864 186179 : AirTemp = state.dataZoneTempPredictorCorrector->zoneHeatBalance(this->EnvrZonePtr).MAT;
1865 186179 : AirVel = RoomAirVel;
1866 186179 : } break;
1867 0 : default:
1868 0 : break;
1869 : }
1870 372358 : } break;
1871 186179 : case DataPlant::PlantEquipmentType::PipeExterior: {
1872 186179 : switch (this->EnvironmentPtr) {
1873 186179 : case EnvrnPtr::OutsideAirEnv: {
1874 186179 : AirTemp = state.dataLoopNodes->Node(this->EnvrAirNodeNum).Temp;
1875 186179 : AirVel = state.dataEnvrn->WindSpeed;
1876 186179 : } break;
1877 0 : default:
1878 0 : break;
1879 : }
1880 186179 : } break;
1881 0 : default:
1882 0 : break;
1883 : }
1884 :
1885 558537 : PipeOD = this->InsulationOD;
1886 :
1887 558537 : ViscositySet = false;
1888 3702653 : for (idx = 0; idx < NumOfPropDivisions; ++idx) {
1889 3702653 : if (AirTemp <= Temperature[idx]) {
1890 558537 : AirVisc = DynVisc[idx];
1891 558537 : ViscositySet = true;
1892 558537 : break;
1893 : }
1894 : }
1895 :
1896 558537 : if (!ViscositySet) {
1897 0 : AirVisc = DynVisc[NumOfPropDivisions - 1];
1898 0 : if (AirTemp > Temperature[NumOfPropDivisions - 1]) {
1899 0 : ShowWarningError(state,
1900 0 : format("Heat Transfer Pipe = {}Viscosity out of range, air temperature too high, setting to upper limit.", this->Name));
1901 : }
1902 : }
1903 :
1904 : // Calculate the Reynold's number
1905 558537 : CoefSet = false;
1906 558537 : if (AirVisc > 0.0) {
1907 558537 : ReD = AirVel * PipeOD / (AirVisc);
1908 : }
1909 :
1910 2212153 : for (idx = 0; idx < NumOfParamDivisions; ++idx) {
1911 2212153 : if (ReD <= UpperBound[idx]) {
1912 558537 : Coef = CCoef[idx];
1913 558537 : rExp = mExp[idx];
1914 558537 : CoefSet = true;
1915 558537 : break;
1916 : }
1917 : }
1918 :
1919 558537 : if (!CoefSet) {
1920 0 : Coef = CCoef[NumOfParamDivisions - 1];
1921 0 : rExp = mExp[NumOfParamDivisions - 1];
1922 0 : if (ReD > UpperBound[NumOfParamDivisions - 1]) {
1923 0 : ShowWarningError(state, format("Heat Transfer Pipe = {}Reynolds Number out of range, setting coefficients to upper limit.", this->Name));
1924 : }
1925 : }
1926 :
1927 : // Calculate the Nusselt number
1928 558537 : NuD = Coef * std::pow(ReD, rExp) * std::pow(Pr, 1.0 / 3.0);
1929 :
1930 : // If the wind speed is too small, we need to use natural convection behavior:
1931 558537 : NuD = max(NuD, NaturalConvNusselt);
1932 :
1933 : // h = (k)(Nu)/D
1934 558537 : OutsidePipeHeatTransCoef = CondAir * NuD / PipeOD;
1935 :
1936 558537 : return OutsidePipeHeatTransCoef;
1937 : }
1938 :
1939 : //==============================================================================
1940 :
1941 1316400 : Real64 PipeHTData::TBND(EnergyPlusData &state,
1942 : Real64 const z // Current Depth
1943 : )
1944 : {
1945 :
1946 : // AUTHOR Edwin Lee
1947 : // DATE WRITTEN December 2007
1948 : // MODIFIED na
1949 : // RE-ENGINEERED na
1950 :
1951 : // PURPOSE OF THIS FUNCTION:
1952 : // Returns a temperature to be used on the boundary of the buried pipe model domain
1953 :
1954 : // METHODOLOGY EMPLOYED:
1955 :
1956 : // REFERENCES: See Module Level Description
1957 :
1958 : // Using/Aliasing
1959 1316400 : Real64 curSimTime = state.dataGlobal->DayOfSim * Constant::SecsInDay;
1960 : Real64 TBND;
1961 :
1962 1316400 : TBND = this->groundTempModel->getGroundTempAtTimeInSeconds(state, z, curSimTime);
1963 :
1964 1316400 : return TBND;
1965 : }
1966 :
1967 0 : void PipeHTData::oneTimeInit([[maybe_unused]] EnergyPlusData &state)
1968 : {
1969 0 : }
1970 :
1971 : //===============================================================================
1972 :
1973 : //===============================================================================
1974 :
1975 : } // namespace EnergyPlus::PipeHeatTransfer
|