Line data Source code
1 : // EnergyPlus, Copyright (c) 1996-2025, The Board of Trustees of the University of Illinois,
2 : // The Regents of the University of California, through Lawrence Berkeley National Laboratory
3 : // (subject to receipt of any required approvals from the U.S. Dept. of Energy), Oak Ridge
4 : // National Laboratory, managed by UT-Battelle, Alliance for Sustainable Energy, LLC, and other
5 : // contributors. All rights reserved.
6 : //
7 : // NOTICE: This Software was developed under funding from the U.S. Department of Energy and the
8 : // U.S. Government consequently retains certain rights. As such, the U.S. Government has been
9 : // granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable,
10 : // worldwide license in the Software to reproduce, distribute copies to the public, prepare
11 : // derivative works, and perform publicly and display publicly, and to permit others to do so.
12 : //
13 : // Redistribution and use in source and binary forms, with or without modification, are permitted
14 : // provided that the following conditions are met:
15 : //
16 : // (1) Redistributions of source code must retain the above copyright notice, this list of
17 : // conditions and the following disclaimer.
18 : //
19 : // (2) Redistributions in binary form must reproduce the above copyright notice, this list of
20 : // conditions and the following disclaimer in the documentation and/or other materials
21 : // provided with the distribution.
22 : //
23 : // (3) Neither the name of the University of California, Lawrence Berkeley National Laboratory,
24 : // the University of Illinois, U.S. Dept. of Energy nor the names of its contributors may be
25 : // used to endorse or promote products derived from this software without specific prior
26 : // written permission.
27 : //
28 : // (4) Use of EnergyPlus(TM) Name. If Licensee (i) distributes the software in stand-alone form
29 : // without changes from the version obtained under this License, or (ii) Licensee makes a
30 : // reference solely to the software portion of its product, Licensee must refer to the
31 : // software as "EnergyPlus version X" software, where "X" is the version number Licensee
32 : // obtained under this License and may not use a different name for the software. Except as
33 : // specifically required in this Section (4), Licensee shall not use in a company name, a
34 : // product name, in advertising, publicity, or other promotional activities any name, trade
35 : // name, trademark, logo, or other designation of "EnergyPlus", "E+", "e+" or confusingly
36 : // similar designation, without the U.S. Department of Energy's prior written consent.
37 : //
38 : // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
39 : // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
40 : // AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
41 : // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
42 : // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
43 : // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
44 : // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
45 : // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
46 : // POSSIBILITY OF SUCH DAMAGE.
47 :
48 : // C++ Headers
49 : #include <string>
50 :
51 : // EnergyPlus Headers
52 : #include <EnergyPlus/BranchNodeConnections.hh>
53 : #include <EnergyPlus/Data/EnergyPlusData.hh>
54 : #include <EnergyPlus/DataHVACGlobals.hh>
55 : #include <EnergyPlus/DataIPShortCuts.hh>
56 : #include <EnergyPlus/DataLoopNode.hh>
57 : #include <EnergyPlus/General.hh>
58 : #include <EnergyPlus/GlobalNames.hh>
59 : #include <EnergyPlus/InputProcessing/InputProcessor.hh>
60 : #include <EnergyPlus/NodeInputManager.hh>
61 : #include <EnergyPlus/Pipes.hh>
62 : #include <EnergyPlus/Plant/DataPlant.hh>
63 : #include <EnergyPlus/Plant/PlantLocation.hh>
64 : #include <EnergyPlus/PlantComponent.hh>
65 : #include <EnergyPlus/PlantUtilities.hh>
66 : #include <EnergyPlus/UtilityRoutines.hh>
67 :
68 : namespace EnergyPlus::Pipes {
69 :
70 : // Module containing the routines dealing with the <module_name>
71 :
72 : // MODULE INFORMATION:
73 : // AUTHOR <author>
74 : // DATE WRITTEN <date_written>
75 : // MODIFIED Rahul Chillar , Jan 2005
76 : // RE-ENGINEERED na
77 :
78 5587 : PlantComponent *LocalPipeData::factory(EnergyPlusData &state, DataPlant::PlantEquipmentType objectType, std::string const &objectName)
79 : {
80 : // Process the input data for pipes if it hasn't been done already
81 5587 : if (state.dataPipes->GetPipeInputFlag) {
82 456 : GetPipeInput(state);
83 456 : state.dataPipes->GetPipeInputFlag = false;
84 : }
85 : // Now look for this particular pipe in the list
86 43849 : for (auto &pipe : state.dataPipes->LocalPipe) {
87 43849 : if (pipe.Type == objectType && pipe.Name == objectName) {
88 5587 : return &pipe;
89 : }
90 11174 : }
91 : // If we didn't find it, fatal
92 : ShowFatalError(state, format("LocalPipeDataFactory: Error getting inputs for pipe named: {}", objectName)); // LCOV_EXCL_LINE
93 : // Shut up the compiler
94 : return nullptr; // LCOV_EXCL_LINE
95 : }
96 :
97 179017280 : void LocalPipeData::simulate(EnergyPlusData &state,
98 : [[maybe_unused]] const PlantLocation &calledFromLocation,
99 : [[maybe_unused]] bool const FirstHVACIteration,
100 : [[maybe_unused]] Real64 &CurLoad,
101 : [[maybe_unused]] bool const RunFlag)
102 : {
103 :
104 179017280 : if (state.dataGlobal->BeginEnvrnFlag && this->EnvrnFlag) {
105 34506 : this->initEachEnvironment(state);
106 34506 : this->EnvrnFlag = false;
107 : }
108 :
109 179017280 : if (!state.dataGlobal->BeginEnvrnFlag) {
110 177824704 : this->EnvrnFlag = true;
111 : }
112 :
113 179017280 : PlantUtilities::SafeCopyPlantNode(state, this->InletNodeNum, this->OutletNodeNum, this->plantLoc.loopNum);
114 179017280 : }
115 :
116 5587 : void LocalPipeData::oneTimeInit_new(EnergyPlusData &state)
117 : {
118 5587 : int FoundOnLoop = 0;
119 5587 : bool errFlag = false;
120 5587 : PlantUtilities::ScanPlantLoopsForObject(state, this->Name, this->Type, this->plantLoc, errFlag, _, _, FoundOnLoop, _, _);
121 : // Clang can't tell that the FoundOnLoop argument is actually passed by reference since it is an optional, so it thinks FoundOnLoop is always 0.
122 : #pragma clang diagnostic push
123 : #pragma ide diagnostic ignored "ConstantConditionsOC"
124 5587 : if (FoundOnLoop == 0) {
125 : ShowFatalError(state, format("SimPipes: Pipe=\"{}\" not found on a Plant Loop.", this->Name)); // LCOV_EXCL_LINE
126 : }
127 : #pragma clang diagnostic pop
128 5587 : if (errFlag) {
129 : ShowFatalError(state, "SimPipes: Program terminated due to previous condition(s)."); // LCOV_EXCL_LINE
130 : }
131 5587 : }
132 :
133 34506 : void LocalPipeData::initEachEnvironment(EnergyPlusData &state) const
134 : {
135 34506 : PlantUtilities::InitComponentNodes(
136 34506 : state, 0.0, state.dataPlnt->PlantLoop(this->plantLoc.loopNum).MaxMassFlowRate, this->InletNodeNum, this->OutletNodeNum);
137 34506 : }
138 0 : void LocalPipeData::oneTimeInit([[maybe_unused]] EnergyPlusData &state)
139 : {
140 0 : }
141 :
142 456 : void GetPipeInput(EnergyPlusData &state)
143 : {
144 : // SUBROUTINE INFORMATION:
145 : // AUTHOR: Dan Fisher
146 : // DATE WRITTEN: April 1998
147 : // MODIFIED na
148 : // RE-ENGINEERED na
149 :
150 : // Using/Aliasing
151 : using BranchNodeConnections::TestCompSet;
152 : using NodeInputManager::GetOnlySingleNode;
153 :
154 : // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
155 456 : int PipeNum = 0;
156 456 : int NumAlphas = 0; // Number of elements in the alpha array
157 456 : int NumNums = 0; // Number of elements in the numeric array
158 456 : int IOStat = 0; // IO Status when calling get input subroutine
159 456 : bool ErrorsFound(false);
160 :
161 : // GET NUMBER OF ALL EQUIPMENT TYPES
162 456 : int NumWaterPipes = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Pipe:Adiabatic");
163 456 : int NumSteamPipes = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, "Pipe:Adiabatic:Steam");
164 456 : int const NumLocalPipes = NumWaterPipes + NumSteamPipes;
165 456 : state.dataPipes->LocalPipe.allocate(NumLocalPipes);
166 456 : state.dataPipes->LocalPipeUniqueNames.reserve(static_cast<unsigned>(NumLocalPipes));
167 456 : auto &cCurrentModuleObject = state.dataIPShortCut->cCurrentModuleObject;
168 456 : cCurrentModuleObject = "Pipe:Adiabatic";
169 6004 : for (int PipeWaterNum = 1; PipeWaterNum <= NumWaterPipes; ++PipeWaterNum) {
170 5548 : ++PipeNum;
171 11096 : state.dataInputProcessing->inputProcessor->getObjectItem(state,
172 : cCurrentModuleObject,
173 : PipeWaterNum,
174 5548 : state.dataIPShortCut->cAlphaArgs,
175 : NumAlphas,
176 5548 : state.dataIPShortCut->rNumericArgs,
177 : NumNums,
178 : IOStat);
179 5548 : GlobalNames::VerifyUniqueInterObjectName(
180 5548 : state, state.dataPipes->LocalPipeUniqueNames, state.dataIPShortCut->cAlphaArgs(1), cCurrentModuleObject, ErrorsFound);
181 5548 : state.dataPipes->LocalPipe(PipeNum).Name = state.dataIPShortCut->cAlphaArgs(1);
182 5548 : state.dataPipes->LocalPipe(PipeNum).Type = DataPlant::PlantEquipmentType::Pipe;
183 :
184 11096 : state.dataPipes->LocalPipe(PipeNum).InletNodeNum = GetOnlySingleNode(state,
185 5548 : state.dataIPShortCut->cAlphaArgs(2),
186 : ErrorsFound,
187 : DataLoopNode::ConnectionObjectType::PipeAdiabatic,
188 5548 : state.dataIPShortCut->cAlphaArgs(1),
189 : DataLoopNode::NodeFluidType::Water,
190 : DataLoopNode::ConnectionType::Inlet,
191 : NodeInputManager::CompFluidStream::Primary,
192 : DataLoopNode::ObjectIsNotParent);
193 11096 : state.dataPipes->LocalPipe(PipeNum).OutletNodeNum = GetOnlySingleNode(state,
194 5548 : state.dataIPShortCut->cAlphaArgs(3),
195 : ErrorsFound,
196 : DataLoopNode::ConnectionObjectType::PipeAdiabatic,
197 5548 : state.dataIPShortCut->cAlphaArgs(1),
198 : DataLoopNode::NodeFluidType::Water,
199 : DataLoopNode::ConnectionType::Outlet,
200 : NodeInputManager::CompFluidStream::Primary,
201 : DataLoopNode::ObjectIsNotParent);
202 16644 : TestCompSet(state,
203 : cCurrentModuleObject,
204 5548 : state.dataIPShortCut->cAlphaArgs(1),
205 5548 : state.dataIPShortCut->cAlphaArgs(2),
206 5548 : state.dataIPShortCut->cAlphaArgs(3),
207 : "Pipe Nodes");
208 : }
209 :
210 456 : PipeNum = NumWaterPipes;
211 456 : cCurrentModuleObject = "Pipe:Adiabatic:Steam";
212 :
213 495 : for (int PipeSteamNum = 1; PipeSteamNum <= NumSteamPipes; ++PipeSteamNum) {
214 39 : ++PipeNum;
215 78 : state.dataInputProcessing->inputProcessor->getObjectItem(state,
216 : cCurrentModuleObject,
217 : PipeSteamNum,
218 39 : state.dataIPShortCut->cAlphaArgs,
219 : NumAlphas,
220 39 : state.dataIPShortCut->rNumericArgs,
221 : NumNums,
222 : IOStat);
223 39 : GlobalNames::VerifyUniqueInterObjectName(
224 39 : state, state.dataPipes->LocalPipeUniqueNames, state.dataIPShortCut->cAlphaArgs(1), cCurrentModuleObject, ErrorsFound);
225 39 : state.dataPipes->LocalPipe(PipeNum).Name = state.dataIPShortCut->cAlphaArgs(1);
226 39 : state.dataPipes->LocalPipe(PipeNum).Type = DataPlant::PlantEquipmentType::PipeSteam;
227 78 : state.dataPipes->LocalPipe(PipeNum).InletNodeNum = GetOnlySingleNode(state,
228 39 : state.dataIPShortCut->cAlphaArgs(2),
229 : ErrorsFound,
230 : DataLoopNode::ConnectionObjectType::PipeAdiabaticSteam,
231 39 : state.dataIPShortCut->cAlphaArgs(1),
232 : DataLoopNode::NodeFluidType::Steam,
233 : DataLoopNode::ConnectionType::Inlet,
234 : NodeInputManager::CompFluidStream::Primary,
235 : DataLoopNode::ObjectIsNotParent);
236 78 : state.dataPipes->LocalPipe(PipeNum).OutletNodeNum = GetOnlySingleNode(state,
237 39 : state.dataIPShortCut->cAlphaArgs(3),
238 : ErrorsFound,
239 : DataLoopNode::ConnectionObjectType::PipeAdiabaticSteam,
240 39 : state.dataIPShortCut->cAlphaArgs(1),
241 : DataLoopNode::NodeFluidType::Steam,
242 : DataLoopNode::ConnectionType::Outlet,
243 : NodeInputManager::CompFluidStream::Primary,
244 : DataLoopNode::ObjectIsNotParent);
245 117 : TestCompSet(state,
246 : cCurrentModuleObject,
247 39 : state.dataIPShortCut->cAlphaArgs(1),
248 39 : state.dataIPShortCut->cAlphaArgs(2),
249 39 : state.dataIPShortCut->cAlphaArgs(3),
250 : "Pipe Nodes");
251 : }
252 :
253 456 : if (ErrorsFound) {
254 : ShowFatalError(state, "GetPipeInput: Errors getting input for pipes"); // LCOV_EXCL_LINE
255 : }
256 456 : }
257 :
258 : } // namespace EnergyPlus::Pipes
|