Line data Source code
1 : // EnergyPlus, Copyright (c) 1996-2024, The Board of Trustees of the University of Illinois,
2 : // The Regents of the University of California, through Lawrence Berkeley National Laboratory
3 : // (subject to receipt of any required approvals from the U.S. Dept. of Energy), Oak Ridge
4 : // National Laboratory, managed by UT-Battelle, Alliance for Sustainable Energy, LLC, and other
5 : // contributors. All rights reserved.
6 : //
7 : // NOTICE: This Software was developed under funding from the U.S. Department of Energy and the
8 : // U.S. Government consequently retains certain rights. As such, the U.S. Government has been
9 : // granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable,
10 : // worldwide license in the Software to reproduce, distribute copies to the public, prepare
11 : // derivative works, and perform publicly and display publicly, and to permit others to do so.
12 : //
13 : // Redistribution and use in source and binary forms, with or without modification, are permitted
14 : // provided that the following conditions are met:
15 : //
16 : // (1) Redistributions of source code must retain the above copyright notice, this list of
17 : // conditions and the following disclaimer.
18 : //
19 : // (2) Redistributions in binary form must reproduce the above copyright notice, this list of
20 : // conditions and the following disclaimer in the documentation and/or other materials
21 : // provided with the distribution.
22 : //
23 : // (3) Neither the name of the University of California, Lawrence Berkeley National Laboratory,
24 : // the University of Illinois, U.S. Dept. of Energy nor the names of its contributors may be
25 : // used to endorse or promote products derived from this software without specific prior
26 : // written permission.
27 : //
28 : // (4) Use of EnergyPlus(TM) Name. If Licensee (i) distributes the software in stand-alone form
29 : // without changes from the version obtained under this License, or (ii) Licensee makes a
30 : // reference solely to the software portion of its product, Licensee must refer to the
31 : // software as "EnergyPlus version X" software, where "X" is the version number Licensee
32 : // obtained under this License and may not use a different name for the software. Except as
33 : // specifically required in this Section (4), Licensee shall not use in a company name, a
34 : // product name, in advertising, publicity, or other promotional activities any name, trade
35 : // name, trademark, logo, or other designation of "EnergyPlus", "E+", "e+" or confusingly
36 : // similar designation, without the U.S. Department of Energy's prior written consent.
37 : //
38 : // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
39 : // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
40 : // AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
41 : // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
42 : // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
43 : // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
44 : // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
45 : // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
46 : // POSSIBILITY OF SUCH DAMAGE.
47 :
48 : #ifndef PlantPipingSystemsManager_hh_INCLUDED
49 : #define PlantPipingSystemsManager_hh_INCLUDED
50 :
51 : // C++ Headers
52 : #include <map>
53 : #include <memory>
54 : #include <unordered_map>
55 : #include <utility>
56 :
57 : // ObjexxFCL Headers
58 : #include <ObjexxFCL/Array2D.hh>
59 : #include <ObjexxFCL/Array3D.hh>
60 : #include <ObjexxFCL/Optional.hh>
61 :
62 : // EnergyPlus Headers
63 : #include <EnergyPlus/Data/BaseData.hh>
64 : #include <EnergyPlus/DataGlobals.hh>
65 : #include <EnergyPlus/EnergyPlus.hh>
66 : #include <EnergyPlus/GroundTemperatureModeling/GroundTemperatureModelManager.hh>
67 : #include <EnergyPlus/Plant/Enums.hh>
68 : #include <EnergyPlus/Plant/PlantLocation.hh>
69 : #include <EnergyPlus/PlantComponent.hh>
70 :
71 : namespace EnergyPlus {
72 :
73 : // Forward declarations
74 : struct EnergyPlusData;
75 :
76 : namespace PlantPipingSystemsManager {
77 :
78 : // MODULE PARAMETER DEFINITIONS:
79 : extern std::string const ObjName_ug_GeneralDomain;
80 : extern std::string const ObjName_Circuit;
81 : extern std::string const ObjName_Segment;
82 : extern std::string const ObjName_HorizTrench;
83 : extern std::string const ObjName_ZoneCoupled_Slab;
84 : extern std::string const ObjName_ZoneCoupled_Basement;
85 :
86 : // Using/Aliasing
87 : using namespace GroundTemperatureManager;
88 :
89 : enum class SegmentFlow
90 : {
91 : Invalid = -1,
92 : IncreasingZ,
93 : DecreasingZ,
94 : Num
95 : };
96 :
97 : enum class MeshDistribution
98 : {
99 : Invalid = -1,
100 : Uniform,
101 : SymmetricGeometric,
102 : Geometric,
103 : Num
104 : };
105 :
106 : enum class RegionType
107 : {
108 : Invalid = -1,
109 : Pipe,
110 : BasementWall,
111 : BasementFloor,
112 : XDirection,
113 : YDirection,
114 : ZDirection,
115 : XSide,
116 : XSideWall,
117 : ZSide,
118 : ZSideWall,
119 : FloorInside,
120 : UnderFloor,
121 : HorizInsXSide,
122 : HorizInsZSide,
123 : VertInsLowerEdge,
124 : Num
125 : };
126 :
127 : enum class Direction
128 : {
129 : Invalid = -1,
130 : PositiveY,
131 : NegativeY,
132 : PositiveX,
133 : NegativeX,
134 : PositiveZ,
135 : NegativeZ,
136 : Num
137 : };
138 :
139 : enum class PartitionType
140 : {
141 : Invalid = -1,
142 : BasementWall,
143 : BasementFloor,
144 : Pipe,
145 : Slab,
146 : XSide,
147 : XSideWall,
148 : ZSide,
149 : ZSideWall,
150 : FloorInside,
151 : UnderFloor,
152 : HorizInsXSide,
153 : VertInsLowerEdge,
154 : HorizInsZSide,
155 : Num
156 : };
157 :
158 : enum class CellType
159 : {
160 : Invalid = -1,
161 : Pipe,
162 : GeneralField,
163 : GroundSurface,
164 : FarfieldBoundary,
165 : BasementWall,
166 : BasementFloor,
167 : BasementCorner,
168 : BasementCutaway,
169 : Slab,
170 : HorizInsulation,
171 : VertInsulation,
172 : ZoneGroundInterface,
173 : Num
174 : };
175 :
176 : struct BaseThermalPropertySet
177 : {
178 : // Members
179 : Real64 Conductivity = 0.0; // W/mK
180 : Real64 Density = 0.0; // kg/m3
181 : Real64 SpecificHeat = 0.0; // J/kgK
182 :
183 : // Default Constructor
184 861 : BaseThermalPropertySet() = default;
185 :
186 : Real64 inline diffusivity() const
187 : {
188 : return this->Conductivity / (this->Density * this->SpecificHeat);
189 : }
190 : };
191 :
192 : struct ExtendedFluidProperties : BaseThermalPropertySet
193 : {
194 : // Members
195 : Real64 Viscosity = 0.0; // kg/m-s
196 : Real64 Prandtl = 0.0; // -
197 :
198 : // Default Constructor
199 176 : ExtendedFluidProperties() = default;
200 : };
201 :
202 : struct BaseCell
203 : {
204 : // Members
205 : Real64 Temperature = 0.0; // C
206 : Real64 Temperature_PrevIteration = 0.0; // C
207 : Real64 Temperature_PrevTimeStep = 0.0; // C
208 : Real64 Beta = 0.0; // K/W
209 : BaseThermalPropertySet Properties;
210 :
211 : // Default Constructor
212 620 : BaseCell() = default;
213 : };
214 :
215 : struct RadialSizing
216 : {
217 : // Members
218 : Real64 InnerDia = 0.0;
219 : Real64 OuterDia = 0.0;
220 :
221 : // Default Constructor
222 10 : RadialSizing() = default;
223 :
224 0 : Real64 inline thickness() const
225 : {
226 0 : return (this->OuterDia - this->InnerDia) / 2.0;
227 : }
228 : };
229 :
230 : struct RadialCellInformation : BaseCell
231 : {
232 : // Members
233 : Real64 RadialCentroid = 0.0;
234 : Real64 InnerRadius = 0.0;
235 : Real64 OuterRadius = 0.0;
236 :
237 : // Default Constructor
238 182 : RadialCellInformation() = default;
239 :
240 : // Member Constructor
241 256 : RadialCellInformation(Real64 const m_RadialCentroid, Real64 const m_MinRadius, Real64 const m_MaxRadius)
242 256 : {
243 256 : RadialCentroid = m_RadialCentroid;
244 256 : InnerRadius = m_MinRadius;
245 256 : OuterRadius = m_MaxRadius;
246 256 : }
247 :
248 : // Get the XY cross sectional area of the radial cell
249 1316220 : Real64 inline XY_CrossSectArea() const
250 : {
251 1316220 : return Constant::Pi * (pow_2(this->OuterRadius) - pow_2(this->InnerRadius));
252 : }
253 : };
254 :
255 : struct FluidCellInformation : BaseCell
256 : {
257 : // Members
258 : Real64 Volume = 0.0;
259 : ExtendedFluidProperties Properties;
260 :
261 : // Default Constructor
262 91 : FluidCellInformation() = default;
263 :
264 : // Member Constructor
265 80 : FluidCellInformation(Real64 const m_PipeInnerRadius, Real64 const m_CellDepth)
266 80 : {
267 80 : this->Volume = Constant::Pi * pow_2(m_PipeInnerRadius) * m_CellDepth;
268 80 : }
269 : };
270 :
271 : struct CartesianPipeCellInformation // Specialized cell information only used by cells which contain pipes
272 : {
273 : // Members
274 : std::vector<RadialCellInformation> Soil;
275 : RadialCellInformation Insulation;
276 : RadialCellInformation Pipe;
277 : FluidCellInformation Fluid;
278 : Real64 RadialSliceWidth = 0.0;
279 : Real64 InterfaceVolume = 0.0;
280 :
281 : // Default Constructor
282 11 : CartesianPipeCellInformation() = default;
283 :
284 : CartesianPipeCellInformation(Real64 GridCellWidth,
285 : EnergyPlus::PlantPipingSystemsManager::RadialSizing PipeSizes,
286 : int NumRadialNodes,
287 : Real64 CellDepth,
288 : Real64 InsulationThickness,
289 : Real64 RadialGridExtent,
290 : bool SimHasInsulation);
291 : };
292 :
293 : struct Point
294 : {
295 : // Members
296 : int X = 0;
297 : int Y = 0;
298 :
299 : // Default Constructor
300 25 : Point() = default;
301 :
302 : // Member Constructor
303 : Point(int const X, int const Y) : X(X), Y(Y)
304 : {
305 : }
306 : };
307 :
308 : struct PointF
309 : {
310 : // Members
311 : Real64 X = 0.0;
312 : Real64 Y = 0.0;
313 :
314 : // Default Constructor
315 25 : PointF() = default;
316 :
317 : // Member Constructor
318 14 : PointF(Real64 const X, Real64 const Y) : X(X), Y(Y)
319 : {
320 14 : }
321 : };
322 :
323 : struct Point3DInteger
324 : {
325 : // Members
326 : int X = 0;
327 : int Y = 0;
328 : int Z = 0;
329 :
330 : // Default Constructor
331 10 : Point3DInteger() = default;
332 :
333 : // Member Constructor
334 22060 : Point3DInteger(int const X, int const Y, int const Z) : X(X), Y(Y), Z(Z)
335 : {
336 22060 : }
337 : };
338 :
339 : struct Point3DReal
340 : {
341 : // Members
342 : Real64 X = 0.0;
343 : Real64 Y = 0.0;
344 : Real64 Z = 0.0;
345 :
346 : // Default Constructor
347 11 : Point3DReal() = default;
348 :
349 : // Member Constructor
350 22050 : Point3DReal(Real64 const X, Real64 const Y, Real64 const Z) : X(X), Y(Y), Z(Z)
351 : {
352 22050 : }
353 : };
354 :
355 : struct MeshPartition
356 : {
357 : // Members
358 : Real64 rDimension = 0.0;
359 : PartitionType partitionType = PartitionType::Pipe;
360 : Real64 TotalWidth = 0.0;
361 :
362 : // Default Constructor
363 : MeshPartition() = default;
364 :
365 : #pragma clang diagnostic push
366 : #pragma ide diagnostic ignored "OCUnusedGlobalDeclarationInspection"
367 : // Member Constructor -- shows unused but it's actually implied in emplace_back calls in createPartitionCenterList
368 50 : MeshPartition(Real64 const rDimension,
369 : PartitionType const partitionType, // From Enum: ParitionType
370 : Real64 const TotalWidth)
371 50 : : rDimension(rDimension), partitionType(partitionType), TotalWidth(TotalWidth)
372 : {
373 50 : }
374 : #pragma clang diagnostic pop
375 :
376 : // used to allow std::find to see if a MeshPartition matches a float (rDimension) value
377 38 : bool operator==(Real64 a)
378 : {
379 38 : return this->rDimension == a;
380 : }
381 : };
382 :
383 : struct GridRegion
384 : {
385 : // Members
386 : Real64 Min = 0.0;
387 : Real64 Max = 0.0;
388 : RegionType thisRegionType = RegionType::Pipe;
389 : std::vector<Real64> CellWidths;
390 :
391 : // Default Constructor
392 50 : GridRegion() = default;
393 :
394 : // Member Constructor
395 130 : GridRegion(Real64 Min, Real64 Max, RegionType thisRegionType, std::vector<Real64> CellWidths)
396 130 : : Min(Min), Max(Max), thisRegionType(thisRegionType), CellWidths(std::move(CellWidths))
397 : {
398 130 : }
399 : };
400 :
401 : struct RectangleF
402 : {
403 : // Members
404 : Real64 X_min = 0.0;
405 : Real64 Y_min = 0.0;
406 : Real64 Width = 0.0;
407 : Real64 Height = 0.0;
408 :
409 : // Default Constructor
410 : RectangleF() = default;
411 :
412 : // Member Constructor
413 22050 : RectangleF(Real64 const X_min, Real64 const Y_min, Real64 const Width, Real64 const Height)
414 22050 : : X_min(X_min), Y_min(Y_min), Width(Width), Height(Height)
415 : {
416 22050 : }
417 :
418 12740 : bool inline contains(EnergyPlus::PlantPipingSystemsManager::PointF p) const
419 : {
420 12740 : return ((this->X_min <= p.X) && (p.X < (this->X_min + this->Width)) && (this->Y_min <= p.Y) && (p.Y < (this->Y_min + this->Height)));
421 : }
422 : };
423 :
424 : struct NeighborInformation
425 : {
426 : // Members
427 : Real64 ThisCentroidToNeighborWall = 0.0;
428 : Real64 ThisWallToNeighborCentroid = 0.0;
429 : Real64 adiabaticMultiplier = 1.0;
430 : Direction direction = Direction::NegativeX;
431 :
432 : // Default Constructor
433 132300 : NeighborInformation() = default;
434 : };
435 :
436 : struct CartesianCell : BaseCell
437 : {
438 : // Members
439 : int X_index = 0;
440 : int Y_index = 0;
441 : int Z_index = 0;
442 : Real64 X_min = 0.0;
443 : Real64 X_max = 0.0;
444 : Real64 Y_min = 0.0;
445 : Real64 Y_max = 0.0;
446 : Real64 Z_min = 0.0;
447 : Real64 Z_max = 0.0;
448 : Point3DReal Centroid;
449 : CellType cellType = CellType::Invalid;
450 : std::map<Direction, NeighborInformation> NeighborInfo;
451 : CartesianPipeCellInformation PipeCellData;
452 :
453 : // Default Constructor
454 11 : CartesianCell() = default;
455 :
456 1216243433 : Real64 inline width() const
457 : {
458 1216243433 : return this->X_max - this->X_min;
459 : }
460 :
461 1200496015 : Real64 inline height() const
462 : {
463 1200496015 : return this->Y_max - this->Y_min;
464 : }
465 :
466 1353298659 : Real64 inline depth() const
467 : {
468 1353298659 : return this->Z_max - this->Z_min;
469 : }
470 :
471 568566921 : Real64 inline XNormalArea() const
472 : {
473 568566921 : return this->depth() * this->height();
474 : }
475 :
476 577553805 : Real64 inline YNormalArea() const
477 : {
478 577553805 : return this->depth() * this->width();
479 : }
480 :
481 549467643 : Real64 inline ZNormalArea() const
482 : {
483 549467643 : return this->width() * this->height();
484 : }
485 :
486 58947672 : Real64 inline volume() const
487 : {
488 58947672 : return this->width() * this->depth() * this->height();
489 : }
490 :
491 : Real64 normalArea(Direction direction) const;
492 :
493 : void EvaluateNeighborCoordinates(Direction CurDirection, int &NX, int &NY, int &NZ) const;
494 : };
495 :
496 : struct MeshExtents
497 : {
498 : // Members
499 : Real64 xMax = 0.0;
500 : Real64 yMax = 0.0;
501 : Real64 zMax = 0.0;
502 :
503 : // Default Constructor
504 11 : MeshExtents() = default;
505 :
506 : // Member Constructor
507 22050 : MeshExtents(Real64 const xMax, Real64 const yMax, Real64 const zMax) : xMax(xMax), yMax(yMax), zMax(zMax)
508 : {
509 22050 : }
510 : };
511 :
512 : struct CellExtents : MeshExtents
513 : {
514 : // Members
515 : Real64 Xmin;
516 : Real64 Ymin;
517 : Real64 Zmin;
518 :
519 : // Member Constructor
520 22050 : CellExtents(Real64 const Xmax, Real64 const Ymax, Real64 const Zmax, Real64 const Xmin, Real64 const Ymin, Real64 const Zmin)
521 22050 : : MeshExtents(Xmax, Ymax, Zmax), Xmin(Xmin), Ymin(Ymin), Zmin(Zmin)
522 : {
523 22050 : }
524 : };
525 :
526 : struct DistributionStructure
527 : {
528 : // Members
529 : MeshDistribution thisMeshDistribution = MeshDistribution::Uniform;
530 : int RegionMeshCount = 0;
531 : Real64 GeometricSeriesCoefficient = 0.0;
532 :
533 : // Default Constructor
534 33 : DistributionStructure() = default;
535 : };
536 :
537 : struct MeshProperties
538 : {
539 : // Members
540 : DistributionStructure X;
541 : DistributionStructure Y;
542 : DistributionStructure Z;
543 :
544 : // Default Constructor
545 11 : MeshProperties() = default;
546 : };
547 :
548 : struct SimulationControl
549 : {
550 : // Members
551 : Real64 MinimumTemperatureLimit = -1000;
552 : Real64 MaximumTemperatureLimit = 1000;
553 : Real64 Convergence_CurrentToPrevIteration = 0.0;
554 : int MaxIterationsPerTS = 0;
555 :
556 : // Default Constructor
557 11 : SimulationControl() = default;
558 : };
559 :
560 : struct BasementZoneInfo
561 : {
562 : // Members
563 : Real64 Depth = 0; // m
564 : Real64 Width = 0; // m
565 : Real64 Length = 0; // m
566 : bool ShiftPipesByWidth = false;
567 : std::string WallBoundaryOSCMName;
568 : int WallBoundaryOSCMIndex = 0;
569 : std::string FloorBoundaryOSCMName;
570 : int FloorBoundaryOSCMIndex = 0;
571 : std::vector<int> WallSurfacePointers;
572 : std::vector<int> FloorSurfacePointers;
573 : int BasementWallXIndex = -1;
574 : int BasementFloorYIndex = -1;
575 :
576 : // Default Constructor
577 11 : BasementZoneInfo() = default;
578 : };
579 :
580 : struct MeshPartitions
581 : {
582 : // Members
583 : std::vector<MeshPartition> X;
584 : std::vector<MeshPartition> Y;
585 : std::vector<MeshPartition> Z;
586 :
587 : // Default Constructor
588 11 : MeshPartitions() = default;
589 : };
590 :
591 : struct MoistureInfo
592 : {
593 : // Members
594 : Real64 Theta_liq = 0.3; // volumetric moisture content of the soil
595 : Real64 Theta_sat = 0.5; // volumetric moisture content of soil at saturation
596 : Real64 GroundCoverCoefficient = 0.408;
597 : Real64 rhoCP_soil_liq = 0.0;
598 : Real64 rhoCP_soil_transient = 0.0;
599 : Real64 rhoCP_soil_ice = 0.0;
600 : Real64 rhoCp_soil_liq_1 = 0.0;
601 :
602 : // Default Constructor
603 11 : MoistureInfo() = default;
604 : };
605 :
606 : struct CurSimConditionsInfo
607 : {
608 : // Members
609 : // Simulation conditions
610 : Real64 PrevSimTimeSeconds = -1.0;
611 : Real64 CurSimTimeSeconds = 0.0;
612 : Real64 CurSimTimeStepSize = 0.0;
613 : // Environmental conditions
614 : Real64 CurAirTemp = 10.0;
615 : Real64 CurWindSpeed = 2.6;
616 : Real64 CurIncidentSolar = 0.0;
617 : Real64 CurRelativeHumidity = 100.0;
618 :
619 : // Default Constructor
620 11 : CurSimConditionsInfo() = default;
621 : };
622 :
623 : struct Segment
624 : {
625 : // Members
626 : // ID
627 : std::string Name;
628 : // Misc inputs
629 : PointF PipeLocation;
630 : Point PipeCellCoordinates;
631 : SegmentFlow FlowDirection = SegmentFlow::IncreasingZ;
632 : // Reporting variables
633 : Real64 InletTemperature = 0.0;
634 : Real64 OutletTemperature = 0.0;
635 : Real64 FluidHeatLoss = 0.0;
636 : // Error handling flags
637 : bool PipeCellCoordinatesSet = false;
638 : // Other flags
639 : bool IsActuallyPartOfAHorizontalTrench = false;
640 :
641 : // Default Constructor
642 25 : Segment() = default;
643 :
644 : void initPipeCells(int x, int y);
645 :
646 : bool operator==(std::string const &a)
647 : {
648 : return this->Name == a;
649 : }
650 :
651 : static Segment *factory(EnergyPlusData &state, const std::string &segmentName);
652 : };
653 :
654 : struct Circuit : public PlantComponent
655 : {
656 :
657 : // Members
658 : // ID
659 : std::string Name;
660 : // Inlet and outlet information
661 : std::string InletNodeName;
662 : std::string OutletNodeName;
663 : int InletNodeNum = 0;
664 : int OutletNodeNum = 0;
665 : Point3DInteger CircuitInletCell;
666 : Point3DInteger CircuitOutletCell;
667 : // Names and pointers to pipe segments found in this pipe circuit
668 : std::vector<Segment *> pipeSegments;
669 : // Pointer to the domain which contains this pipe circuit
670 : int ParentDomainIndex = 0;
671 : // Misc inputs
672 : RadialSizing PipeSize;
673 : RadialSizing InsulationSize;
674 : Real64 RadialMeshThickness = 0.0;
675 : bool HasInsulation = false;
676 : Real64 DesignVolumeFlowRate = 0.0;
677 : Real64 DesignMassFlowRate = 0.0;
678 : Real64 Convergence_CurrentToPrevIteration = 0.0;
679 : int MaxIterationsPerTS = 0;
680 : int NumRadialCells = 0;
681 : BaseThermalPropertySet PipeProperties;
682 : BaseThermalPropertySet InsulationProperties;
683 : // Flags
684 : bool NeedToFindOnPlantLoop = true;
685 : bool IsActuallyPartOfAHorizontalTrench = false;
686 : // Location of this pipe circuit in the PlantLoop topology
687 : PlantLocation plantLoc{};
688 : ExtendedFluidProperties CurFluidPropertySet; // is_used
689 : // Variables used to pass information from INIT-type routines to CALC-type routines
690 : Real64 CurCircuitInletTemp = 23.0;
691 : Real64 CurCircuitFlowRate = 0.1321;
692 : Real64 CurCircuitConvectionCoefficient = 0.0;
693 : // Reporting variables
694 : Real64 InletTemperature = 0.0;
695 : Real64 OutletTemperature = 0.0;
696 : Real64 FluidHeatLoss = 0.0;
697 :
698 : // Default Constructor
699 5 : Circuit() = default;
700 :
701 10 : virtual ~Circuit() = default;
702 :
703 : void initInOutCells(CartesianCell const &in, CartesianCell const &out);
704 :
705 : static PlantComponent *factory(EnergyPlusData &state, DataPlant::PlantEquipmentType, const std::string &objectName);
706 :
707 : void simulate([[maybe_unused]] EnergyPlusData &state,
708 : const PlantLocation &calledFromLocation,
709 : bool FirstHVACIteration,
710 : Real64 &CurLoad,
711 : bool RunFlag) override;
712 :
713 : bool operator==(std::string const &a)
714 : {
715 : return this->Name == a;
716 : }
717 :
718 : static Circuit *factory(EnergyPlusData &state, const std::string &circuit, bool &errorsFound);
719 :
720 : void oneTimeInit(EnergyPlusData &state) override;
721 :
722 : void oneTimeInit_new(EnergyPlusData &state) override;
723 : };
724 :
725 : struct ZoneCoupledSurfaceData
726 : {
727 : // Members
728 : // ID
729 : std::string Name;
730 : // Surface data
731 : int IndexInSurfaceArray;
732 : Real64 SurfaceArea;
733 : Real64 Width;
734 : Real64 Length;
735 : Real64 Depth;
736 : Real64 Conductivity;
737 : Real64 Density;
738 : Real64 InsulationConductivity;
739 : Real64 InsulationDensity;
740 : int Zone;
741 :
742 : // Default Constructor
743 16 : ZoneCoupledSurfaceData()
744 32 : : IndexInSurfaceArray(0), SurfaceArea(0.0), Width(0.0), Length(0.0), Depth(0.0), Conductivity(0.0), Density(0.0),
745 16 : InsulationConductivity(0.0), InsulationDensity(0.0), Zone(0)
746 : {
747 16 : }
748 : };
749 :
750 : struct Domain
751 : {
752 : // Members
753 : // ID
754 : std::string Name;
755 : // Names and pointers to circuits found in this domain
756 : std::vector<Circuit *> circuits;
757 : int MaxIterationsPerTS;
758 : // Flag variables
759 : bool OneTimeInit;
760 : bool BeginSimInit;
761 : bool BeginSimEnvironment;
762 : bool DomainNeedsSimulation;
763 : bool DomainNeedsToBeMeshed;
764 : bool IsActuallyPartOfAHorizontalTrench;
765 : bool HasAPipeCircuit;
766 : bool HasZoneCoupledSlab;
767 : bool HasZoneCoupledBasement;
768 : // "Input" data structure variables
769 : MeshExtents Extents;
770 : MeshProperties Mesh;
771 : BaseThermalPropertySet GroundProperties;
772 : BaseThermalPropertySet SlabProperties;
773 : BaseThermalPropertySet BasementInterfaceProperties;
774 : BaseThermalPropertySet HorizInsProperties;
775 : BaseThermalPropertySet VertInsProperties;
776 : SimulationControl SimControls;
777 : std::shared_ptr<BaseGroundTempsModel> groundTempModel;
778 : BasementZoneInfo BasementZone;
779 : MoistureInfo Moisture;
780 : // "Internal" data structure variables
781 : MeshPartitions Partitions;
782 : CurSimConditionsInfo Cur;
783 : bool HasBasement;
784 : // Zone coupled variables
785 : std::vector<ZoneCoupledSurfaceData> ZoneCoupledSurfaces;
786 : int ZoneCoupledOSCMIndex;
787 : Real64 PerimeterOffset;
788 : bool SlabInGradeFlag;
789 : int SlabMaterialNum;
790 : Real64 SlabArea;
791 : Real64 SlabWidth;
792 : Real64 SlabLength;
793 : Real64 SlabThickness;
794 : int XIndex;
795 : int YIndex;
796 : int ZIndex;
797 : int x_max_index;
798 : int y_max_index;
799 : int z_max_index;
800 : bool HorizInsPresentFlag;
801 : int HorizInsMaterialNum;
802 : Real64 HorizInsThickness;
803 : Real64 HorizInsWidth;
804 : Real64 HeatFlux;
805 : Real64 WallHeatFlux;
806 : Real64 FloorHeatFlux;
807 : Real64 AggregateHeatFlux;
808 : Real64 AggregateWallHeatFlux;
809 : Real64 AggregateFloorHeatFlux;
810 : int NumHeatFlux;
811 : bool ResetHeatFluxFlag;
812 : Real64 ConvectionCoefficient;
813 : bool FullHorizInsPresent;
814 : bool VertInsPresentFlag;
815 : int VertInsMaterialNum;
816 : Real64 VertInsThickness;
817 : Real64 VertInsDepth;
818 : int XWallIndex;
819 : int YFloorIndex;
820 : int ZWallIndex;
821 : int InsulationXIndex;
822 : int InsulationYIndex;
823 : int InsulationZIndex;
824 : bool SimTimeStepFlag;
825 : bool SimHourlyFlag;
826 : bool SimDailyFlag;
827 : Real64 ZoneCoupledSurfaceTemp;
828 : Real64 BasementWallTemp;
829 : Real64 BasementFloorTemp;
830 : int NumDomainCells;
831 : int NumGroundSurfCells;
832 : int NumInsulationCells;
833 : int NumSlabCells;
834 : Array2D<Real64> WeightingFactor;
835 : Array2D<Real64> WeightedHeatFlux;
836 : Real64 TotalEnergyUniformHeatFlux = 0.0;
837 : Real64 TotalEnergyWeightedHeatFlux = 0.0;
838 : Real64 HeatFluxWeightingFactor = 0.0;
839 : std::vector<GridRegion> XRegions;
840 : std::vector<GridRegion> YRegions;
841 : std::vector<GridRegion> ZRegions;
842 :
843 : // Main 3D cells array
844 : Array3D<CartesianCell> Cells;
845 :
846 : // Dynamic indexes to available neighbor directions for a particular cell
847 : std::vector<Direction> NeighborFieldCells;
848 : std::vector<Direction> NeighborBoundaryCells;
849 :
850 : // Default Constructor
851 11 : Domain()
852 22 : : MaxIterationsPerTS(10), OneTimeInit(true), BeginSimInit(true), BeginSimEnvironment(true), DomainNeedsSimulation(true),
853 11 : DomainNeedsToBeMeshed(true), IsActuallyPartOfAHorizontalTrench(false), HasAPipeCircuit(true), HasZoneCoupledSlab(false),
854 33 : HasZoneCoupledBasement(false), HasBasement(false), ZoneCoupledOSCMIndex(0), PerimeterOffset(0.0), SlabInGradeFlag(false),
855 11 : SlabMaterialNum(0), SlabArea(0.0), SlabWidth(0.0), SlabLength(0.0), SlabThickness(0.0), XIndex(0), YIndex(0), ZIndex(0), x_max_index(0),
856 11 : y_max_index(0), z_max_index(0), HorizInsPresentFlag(false), HorizInsMaterialNum(0), HorizInsThickness(0.0254), HorizInsWidth(0.0),
857 11 : HeatFlux(0.0), WallHeatFlux(0.0), FloorHeatFlux(0.0), AggregateHeatFlux(0.0), AggregateWallHeatFlux(0.0), AggregateFloorHeatFlux(0.0),
858 11 : NumHeatFlux(0), ResetHeatFluxFlag(true), ConvectionCoefficient(0.0), FullHorizInsPresent(false), VertInsPresentFlag(false),
859 11 : VertInsMaterialNum(0), VertInsThickness(0.0254), VertInsDepth(0.0), XWallIndex(0), YFloorIndex(0), ZWallIndex(0), InsulationXIndex(0),
860 11 : InsulationYIndex(0), InsulationZIndex(0), SimTimeStepFlag(false), SimHourlyFlag(false), SimDailyFlag(false),
861 11 : ZoneCoupledSurfaceTemp(0.0), BasementWallTemp(0.0), BasementFloorTemp(0.0), NumDomainCells(0), NumGroundSurfCells(0),
862 11 : NumInsulationCells(0), NumSlabCells(0)
863 : {
864 11 : NeighborFieldCells.resize(6);
865 11 : NeighborBoundaryCells.resize(6);
866 11 : }
867 :
868 : void developMesh(EnergyPlusData &state);
869 :
870 : void createPartitionCenterList(EnergyPlusData &state);
871 :
872 : std::vector<GridRegion> createPartitionRegionList(EnergyPlusData &state,
873 : std::vector<MeshPartition> const &ThesePartitionCenters,
874 : bool PartitionsExist,
875 : Real64 DirExtentMax);
876 :
877 : void createRegionList(std::vector<GridRegion> &Regions,
878 : std::vector<GridRegion> const &ThesePartitionRegions,
879 : Real64 DirExtentMax,
880 : RegionType DirDirection,
881 : bool PartitionsExist,
882 : ObjexxFCL::Optional_int BasementWallXIndex = _,
883 : ObjexxFCL::Optional_int BasementFloorYIndex = _,
884 : ObjexxFCL::Optional_int XIndex = _,
885 : ObjexxFCL::Optional_int XWallIndex = _,
886 : ObjexxFCL::Optional_int InsulationXIndex = _,
887 : ObjexxFCL::Optional_int YIndex = _,
888 : ObjexxFCL::Optional_int YFloorIndex = _,
889 : ObjexxFCL::Optional_int InsulationYIndex = _,
890 : ObjexxFCL::Optional_int ZIndex = _,
891 : ObjexxFCL::Optional_int ZWallIndex = _,
892 : ObjexxFCL::Optional_int InsulationZIndex = _);
893 :
894 : void createCellArray(std::vector<Real64> const &XBoundaryPoints,
895 : std::vector<Real64> const &YBoundaryPoints,
896 : std::vector<Real64> const &ZBoundaryPoints);
897 :
898 : void setupCellNeighbors();
899 :
900 : void setupPipeCircuitInOutCells();
901 :
902 : int getCellWidthsCount(RegionType dir) const;
903 :
904 : void getCellWidths(GridRegion &g, RegionType direction) const;
905 :
906 : void addNeighborInformation(int X,
907 : int Y,
908 : int Z,
909 : Direction direction,
910 : Real64 ThisCentroidToNeighborWall,
911 : Real64 ThisWallToNeighborCentroid,
912 : Real64 ThisAdiabaticMultiplier);
913 :
914 : Real64 GetBasementWallHeatFlux(EnergyPlusData &state);
915 :
916 : Real64 GetBasementFloorHeatFlux(EnergyPlusData &state);
917 :
918 : void UpdateBasementSurfaceTemperatures(EnergyPlusData &state);
919 :
920 : Real64 GetZoneInterfaceHeatFlux(EnergyPlusData &state);
921 :
922 : void UpdateZoneSurfaceTemperatures(EnergyPlusData &state);
923 :
924 : Real64 GetAverageTempByType(EnergyPlusData &state, CellType cellType) const;
925 :
926 : void InitializeSoilMoistureCalcs();
927 :
928 : void EvaluateSoilRhoCp(Real64 CellTemp, Real64 &rhoCp) const;
929 :
930 : void ShiftTemperaturesForNewTimeStep();
931 :
932 : void ShiftTemperaturesForNewIteration();
933 :
934 : bool IsConverged_CurrentToPrevIteration();
935 :
936 : bool CheckForOutOfRangeTemps() const;
937 :
938 : void EvaluateNeighborCharacteristics(
939 : CartesianCell &ThisCell, Direction CurDirection, Real64 &NeighborTemp, Real64 &Resistance, Real64 &AdiabaticMultiplier);
940 :
941 : void EvaluateCellNeighborDirections(CartesianCell const &cell, int &NumFieldCells, int &NumBoundaryCells);
942 :
943 : void DoEndOfIterationOperations(EnergyPlusData &state, bool &Finished);
944 :
945 : void DoOneTimeInitializations(EnergyPlusData &state, Circuit *thisCircuit);
946 :
947 : void DoStartOfTimeStepInitializations(EnergyPlusData &state);
948 :
949 : void DoStartOfTimeStepInitializations(EnergyPlusData &state, Circuit *thisCircuit);
950 :
951 : Real64 GetFarfieldTemp(EnergyPlusData &state, CartesianCell const &cell);
952 :
953 : void PreparePipeCircuitSimulation(Circuit *thisCircuit);
954 :
955 : void PerformPipeCircuitSimulation(EnergyPlusData &state, Circuit *thisCircuit);
956 :
957 : void PerformPipeCellSimulation(Circuit *thisCircuit, CartesianCell &ThisCell, Real64 FlowRate, Real64 EnteringTemp);
958 :
959 : void SimulateRadialToCartesianInterface(CartesianCell &ThisCell);
960 :
961 : void PerformTemperatureFieldUpdate(EnergyPlusData &state);
962 :
963 : Real64 EvaluateFieldCellTemperature(CartesianCell &ThisCell);
964 :
965 : Real64 EvaluateGroundSurfaceTemperature(EnergyPlusData &state, CartesianCell &cell);
966 :
967 : Real64 EvaluateBasementCellTemperature(EnergyPlusData &state, CartesianCell &cell);
968 :
969 : Real64 EvaluateZoneInterfaceTemperature(CartesianCell &cell);
970 :
971 : Real64 EvaluateFarfieldBoundaryTemperature(EnergyPlusData &state, CartesianCell &cell);
972 :
973 : void EvaluateFarfieldCharacteristics(
974 : EnergyPlusData &state, CartesianCell &cell, Direction direction, Real64 &neighbortemp, Real64 &resistance, Real64 &adiabaticMultiplier);
975 :
976 : void PerformIterationLoop(EnergyPlusData &state);
977 :
978 : void PerformIterationLoop(EnergyPlusData &state, Circuit *thisCircuit);
979 :
980 : void InitPipingSystems(EnergyPlusData &state, Circuit *thisCircuit);
981 :
982 : void UpdatePipingSystems(EnergyPlusData &state, Circuit *thisCircuit);
983 :
984 : void SetupZoneCoupledOutputVariables(EnergyPlusData &state);
985 : };
986 :
987 : void SimulateGroundDomains(EnergyPlusData &state, bool initOnly);
988 :
989 : void CheckIfAnySlabs(EnergyPlusData &state);
990 :
991 : void CheckIfAnyBasements(EnergyPlusData &state);
992 :
993 : void GetPipingSystemsAndGroundDomainsInput(EnergyPlusData &state);
994 :
995 : void ReadGeneralDomainInputs(EnergyPlusData &state, const int IndexStart, const int NumGeneralizedDomains, bool &ErrorsFound);
996 :
997 : void ReadZoneCoupledDomainInputs(EnergyPlusData &state, const int StartingDomainNumForZone, const int NumZoneCoupledDomains, bool &ErrorsFound);
998 :
999 : void ReadBasementInputs(EnergyPlusData &state, const int StartingDomainNumForBasement, const int NumBasements, bool &ErrorsFound);
1000 :
1001 : bool SiteGroundDomainUsingNoMassMat(EnergyPlusData &state, Real64 const MaterialThickness, int const MaterialNum);
1002 :
1003 : void SiteGroundDomainNoMassMatError(EnergyPlusData &state,
1004 : std::string_view FieldName,
1005 : std::string const &UserInputField,
1006 : std::string const &ObjectName);
1007 :
1008 : void ReadPipeCircuitInputs(EnergyPlusData &state, bool &ErrorsFound);
1009 :
1010 : void ReadPipeSegmentInputs(EnergyPlusData &state, bool &ErrorsFound);
1011 :
1012 : void ReadHorizontalTrenchInputs(EnergyPlusData &state,
1013 : const int StartingDomainNumForHorizontal,
1014 : const int StartingCircuitNumForHorizontal,
1015 : bool &ErrorsFound);
1016 :
1017 : void SetupPipingSystemOutputVariables(EnergyPlusData &state);
1018 :
1019 : void IssueSevereInputFieldError(EnergyPlusData &state,
1020 : std::string_view const RoutineName,
1021 : std::string const &ObjectName,
1022 : std::string const &InstanceName,
1023 : std::string_view FieldName,
1024 : std::string const &FieldEntry,
1025 : std::string const &Condition,
1026 : bool &ErrorsFound);
1027 :
1028 : void IssueSevereInputFieldError(EnergyPlusData &state,
1029 : std::string_view const RoutineName,
1030 : std::string const &ObjectName,
1031 : std::string const &InstanceName,
1032 : std::string_view FieldName,
1033 : Real64 FieldEntry,
1034 : std::string const &Condition,
1035 : bool &ErrorsFound);
1036 :
1037 : int GetSurfaceCountForOSCM(EnergyPlusData &state, int OSCMIndex);
1038 :
1039 : std::vector<int> GetSurfaceIndecesForOSCM(EnergyPlusData &state, int OSCMIndex);
1040 :
1041 : std::vector<ZoneCoupledSurfaceData> GetSurfaceDataForOSCM(EnergyPlusData &state, int OSCMIndex);
1042 :
1043 71 : bool inline IsInRangeReal(Real64 const r, Real64 const lower, Real64 const upper)
1044 : {
1045 71 : return ((r >= lower) && (r <= upper));
1046 : }
1047 :
1048 3 : bool inline IsInRange_BasementModel(Real64 const r, Real64 const lower, Real64 const upper)
1049 : {
1050 3 : return ((r >= lower) && (r < upper));
1051 : }
1052 :
1053 : void ShiftPipeTemperaturesForNewIteration(CartesianCell &ThisPipeCell);
1054 :
1055 : std::vector<Real64> CreateBoundaryList(std::vector<GridRegion> const &RegionList, Real64 DirExtentMax, RegionType DirDirection);
1056 :
1057 : void SimulateOuterMostRadialSoilSlice(Circuit *thisCircuit, CartesianCell &ThisCell);
1058 :
1059 : void SimulateAllInteriorRadialSoilSlices(CartesianCell &ThisCell);
1060 :
1061 : void SimulateInnerMostRadialSoilSlice(Circuit *thisCircuit, CartesianCell &ThisCell);
1062 :
1063 : void SimulateRadialInsulationCell(CartesianCell &ThisCell);
1064 :
1065 : void SimulateRadialPipeCell(Circuit *thisCircuit, CartesianCell &ThisCell);
1066 :
1067 : void SimulateFluidCell(Circuit *thisCircuit, CartesianCell &ThisCell, Real64 FlowRate, Real64 EnteringFluidTemp);
1068 :
1069 : bool IsConverged_PipeCurrentToPrevIteration(Circuit *thisCircuit, CartesianCell const &CellToCheck);
1070 :
1071 : } // namespace PlantPipingSystemsManager
1072 :
1073 : struct PlantPipingSysMgrData : BaseGlobalStruct
1074 : {
1075 :
1076 : bool GetInputFlag = true;
1077 : bool GetSegmentInputFlag = true;
1078 : bool GetCircuitInputFlag = true;
1079 : bool WriteEIOFlag = true;
1080 : std::vector<PlantPipingSystemsManager::Domain> domains;
1081 : std::vector<PlantPipingSystemsManager::Circuit> circuits;
1082 : std::vector<PlantPipingSystemsManager::Segment> segments;
1083 : std::unordered_map<std::string, std::string> GroundDomainUniqueNames;
1084 :
1085 796 : void init_state([[maybe_unused]] EnergyPlusData &state) override
1086 : {
1087 796 : }
1088 :
1089 0 : void clear_state() override
1090 : {
1091 0 : this->GetInputFlag = true;
1092 0 : this->GetSegmentInputFlag = true;
1093 0 : this->GetCircuitInputFlag = true;
1094 0 : this->WriteEIOFlag = true;
1095 0 : this->domains.clear();
1096 0 : this->circuits.clear();
1097 0 : this->segments.clear();
1098 0 : this->GroundDomainUniqueNames.clear();
1099 0 : }
1100 : };
1101 :
1102 : } // namespace EnergyPlus
1103 :
1104 : #endif
|