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 BranchInputManager_hh_INCLUDED
49 : #define BranchInputManager_hh_INCLUDED
50 :
51 : // ObjexxFCL Headers
52 : #include <ObjexxFCL/Array1D.hh>
53 : #include <ObjexxFCL/Optional.hh>
54 :
55 : // EnergyPlus Headers
56 : #include <EnergyPlus/Data/BaseData.hh>
57 : #include <EnergyPlus/DataBranchAirLoopPlant.hh>
58 : #include <EnergyPlus/DataGlobals.hh>
59 : #include <EnergyPlus/DataLoopNode.hh>
60 : #include <EnergyPlus/EnergyPlus.hh>
61 :
62 : namespace EnergyPlus {
63 :
64 : // Forward declarations
65 : struct EnergyPlusData;
66 :
67 : namespace BranchInputManager {
68 :
69 : struct ConnectorData
70 : {
71 : // Members
72 : std::string Name; // Name for this Connector
73 : int NumOfConnectors = 0; // Number of Connectors in this group
74 : int NumOfSplitters = 0; // Number of Splitters in this connector group
75 : int NumOfMixers = 0; // Number of Mixers in this connector group
76 : Array1D_string ConnectorType; // Connector:Splitter or Connector:Mixer
77 : Array1D_string ConnectorName; // Name for that Connector:Splitter or Connector:Mixer
78 : Array1D_int ConnectorMatchNo; // Pointer to index where this Splitter or Mixer matches
79 : // Splitter => Mixer or Mixer => Splitter. 0 indicates no match
80 : };
81 :
82 : struct BranchListData
83 : {
84 : // Members
85 : std::string Name; // Name of this Branch List
86 : int NumOfBranchNames = 0; // Number of Branches on the Branch List
87 : Array1D_string BranchNames; // Names of the branches on this branch list
88 : std::string LoopName; // Name of Loop this Branch list belongs to
89 : std::string LoopType; // Loop type this branch is on
90 : };
91 :
92 : struct ComponentData
93 : {
94 : // Members
95 : std::string CType; // Component Type (Cannot be SPLITTER or MIXER)
96 : std::string Name; // Component Name
97 : int CtrlType = 0; // Active, Passive, Bypass (1,2,3)
98 : std::string InletNodeName; // Inlet Node ID
99 : int InletNode = 0; // Inlet Node Number
100 : std::string OutletNodeName; // Outlet Node ID
101 : int OutletNode = 0; // Outlet Node Number
102 : };
103 :
104 : struct BranchData
105 : {
106 : // Members
107 : std::string Name; // Name for this Branch
108 : std::string AssignedLoopName; // Loop Name for this branch
109 : DataBranchAirLoopPlant::PressureCurveType PressureCurveType =
110 : DataBranchAirLoopPlant::PressureCurveType::Invalid; // Integer index of pressure curve type
111 : int PressureCurveIndex = 0; // Integer index of pressure curve
112 : DataLoopNode::NodeFluidType FluidType = DataLoopNode::NodeFluidType::Blank; // Fluid type (see DataLoopNode)
113 : int NumOfComponents = 0; // Number of Components on this Branch
114 : Array1D<ComponentData> Component; // Component definitions for each component
115 : };
116 :
117 : struct SplitterData
118 : {
119 : // Members
120 : std::string Name; // Splitter Name
121 : std::string InletBranchName; // Splitter Inlet Branch Name
122 : int NumOutletBranches = 0; // Number of outlets on this Splitter
123 : Array1D_string OutletBranchNames; // Names of the Outlet Branches
124 : };
125 :
126 : struct MixerData
127 : {
128 : // Members
129 : std::string Name; // Mixer Name
130 : std::string OutletBranchName; // Mixer Outlet Branch Name
131 : int NumInletBranches = 0; // Number of inlets for this Mixer
132 : Array1D_string InletBranchNames; // Names of Inlet Branches
133 : };
134 :
135 : // Functions
136 : void ManageBranchInput(EnergyPlusData &state);
137 :
138 : //==================================================================================
139 : // Routines that "get" data from internal branch management structure
140 : //==================================================================================
141 :
142 : void GetBranchList(EnergyPlusData &state,
143 : std::string const &LoopName, // Name of Loop Branch List is on
144 : std::string const &BranchListName, // Branch List Name from Input
145 : int &NumBranchNames, // Number of Branches for this Branch List
146 : Array1D_string &BranchNames, // Names of Branches on this Branch List
147 : std::string const &LoopType // Type of Loop Branch list is on
148 : );
149 :
150 : int NumBranchesInBranchList(EnergyPlusData &state, std::string const &BranchListName);
151 :
152 : void GetBranchData(EnergyPlusData &state,
153 : std::string const &LoopName, // Loop Name of this Branch
154 : std::string const &BranchName, // Requested Branch Name
155 : DataBranchAirLoopPlant::PressureCurveType &PressCurveType, // Index of a pressure curve object
156 : int &PressCurveIndex, // Index of a pressure curve object
157 : int &NumComps, // Number of Components on Branch
158 : Array1D_string &CompType, // Component Type for each item on Branch
159 : Array1D_string &CompName, // Component Name for each item on Branch
160 : Array1D_string &CompInletNodeNames, // Component Inlet Node IDs for each item on Branch
161 : Array1D_int &CompInletNodeNums, // Component Inlet Node Numbers for each item on Branch
162 : Array1D_string &CompOutletNodeNames, // Component Outlet Node IDs for each item on Branch
163 : Array1D_int &CompOutletNodeNums, // Component Outlet Node Numbers for each item on Branch
164 : bool &ErrorsFound);
165 :
166 : int NumCompsInBranch(EnergyPlusData &state, std::string const &BranchName);
167 :
168 : int GetAirBranchIndex(EnergyPlusData &state, std::string const &CompType, std::string_view CompName);
169 :
170 : void GetBranchFanTypeName(EnergyPlusData &state,
171 : int BranchNum,
172 : std::string &FanType,
173 : std::string &FanName,
174 : bool &ErrFound // Set to true if error found, false otherwise
175 : );
176 :
177 : void GetInternalBranchData(EnergyPlusData &state,
178 : std::string const &LoopName, // Loop Name for Branch
179 : std::string const &BranchName, // Requested Branch Name
180 : DataBranchAirLoopPlant::PressureCurveType &PressCurveType, // Index of pressure curve object
181 : int &PressCurveIndex, // Index of pressure curve object
182 : int &NumComps, // Number of Components on Branch
183 : Array1D<ComponentData> const &BComponents, // Component data returned
184 : bool &ErrorsFound // True when Loop Name is already assigned and this not same loop
185 : );
186 :
187 : void GetNumSplitterMixerInConntrList(EnergyPlusData &state,
188 : std::string const &LoopName, // Loop Name for this Splitter (used in error message)
189 : std::string const &ConnectorListName, // Requested Connector List Name
190 : int &numSplitters, // Number of splitters in the loop
191 : int &numMixers, // Number of mixers in the loop
192 : bool &ErrorsFound // if no connector list
193 : );
194 :
195 : void GetConnectorList(EnergyPlusData &state,
196 : std::string const &ConnectorListName, // Requested Connector List
197 : ConnectorData &Connectoid, // Returned Connector Data
198 : ObjexxFCL::Optional_int_const NumInList = _ // Number of the current connector in the list of connectors
199 : );
200 :
201 : void GetLoopMixer(EnergyPlusData &state,
202 : std::string const &LoopName, // Loop Name for Mixer
203 : std::string const &ConnectorListName, // Requested Connector List Name
204 : std::string &MixerName, // Name of Mixer
205 : bool &IsMixer, // True when Mixer is on this connector, false otherwise
206 : std::string &OutletNodeName, // Outlet Node ID
207 : int &OutletNodeNum, // Outlet Node Number
208 : int &NumInletNodes, // Number of Inlet Nodes
209 : Array1D_string &InletNodeNames, // Inlet Node IDs
210 : Array1D_int &InletNodeNums, // Inlet Node Numbers
211 : bool &ErrorsFound,
212 : ObjexxFCL::Optional_int_const ConnectorNumber = _, // number of the current item in connector list
213 : ObjexxFCL::Optional_int MixerNumber = _ // Mixer number for this specific splitter
214 : );
215 :
216 : void GetLoopSplitter(EnergyPlusData &state,
217 : std::string const &LoopName, // Loop Name for this Splitter
218 : std::string const &ConnectorListName, // Requested Connector List Name
219 : std::string &SplitterName, // Name of Splitter
220 : bool &IsSplitter, // True if splitter on this connector list, false otherwise
221 : std::string &InletNodeName, // Inlet Node ID
222 : int &InletNodeNum, // Inlet Node Number
223 : int &NumOutletNodes, // Number of Outlet Nodes
224 : Array1D_string &OutletNodeNames, // Outlet Node IDs
225 : Array1D_int &OutletNodeNums, // Outlet Node Numbers
226 : bool &ErrorsFound,
227 : ObjexxFCL::Optional_int_const ConnectorNumber = _, // number of the current item in connector list
228 : ObjexxFCL::Optional_int SplitterNumber = _ // splitter number for this specific splitter
229 : );
230 :
231 : std::string GetFirstBranchInletNodeName(EnergyPlusData &state, std::string const &BranchListName); // Branch List name to search
232 :
233 : std::string GetLastBranchOutletNodeName(EnergyPlusData &state, std::string const &BranchListName); // Branch List name to search
234 :
235 : //==================================================================================
236 : // Routines that get the input for the internal branch management structure
237 : //==================================================================================
238 :
239 : void GetBranchInput(EnergyPlusData &state);
240 :
241 : void GetSingleBranchInput(EnergyPlusData &state,
242 : std::string_view RoutineName,
243 : int BCount,
244 : Array1D_string const &Alphas,
245 : Array1D_string const &cAlphaFields,
246 : int NumAlphas,
247 : Array1D_int &NodeNums,
248 : Array1D_bool const &lAlphaBlanks);
249 :
250 : void GetBranchListInput(EnergyPlusData &state);
251 :
252 : void GetConnectorListInput(EnergyPlusData &state);
253 :
254 : void GetSplitterInput(EnergyPlusData &state);
255 :
256 : void GetMixerInput(EnergyPlusData &state);
257 :
258 : void FindPlantLoopBranchConnection(EnergyPlusData &state,
259 : std::string const &BranchListName,
260 : std::string &FoundPlantLoopName,
261 : int &FoundPlantLoopNum,
262 : std::string &FoundSupplyDemand,
263 : Real64 &FoundVolFlowRate,
264 : bool &MatchedPlantLoop);
265 :
266 : void FindCondenserLoopBranchConnection(EnergyPlusData &state,
267 : std::string const &BranchListName,
268 : std::string &FoundCondLoopName,
269 : int &FoundCondLoopNum,
270 : std::string &FoundSupplyDemand,
271 : Real64 &FoundVolFlowRate,
272 : bool &MatchedCondLoop);
273 :
274 : void FindAirLoopBranchConnection(EnergyPlusData &state,
275 : std::string const &BranchListName,
276 : std::string &FoundAirLoopName,
277 : int &FoundAirLoopNum,
278 : std::string &FoundAir,
279 : Real64 &FoundVolFlowRate,
280 : bool &MatchedAirLoop);
281 :
282 : void FindAirPlantCondenserLoopFromBranchList(EnergyPlusData &state,
283 : std::string const &BranchListName, // Branch List Name
284 : std::string &LoopType, // LoopType (if found, Plant,Condenser or Air)
285 : std::string &LoopSupplyDemandAir, // Supply if "Supply" or Demand if "Demand" or Air if "Air"
286 : bool &MatchedLoop // true if found
287 : );
288 :
289 : //==================================================================================
290 : // Routines that test branch integrity
291 : //==================================================================================
292 :
293 : void AuditBranches(EnergyPlusData &state,
294 : bool mustprint, // true if the warning should be printed.
295 : ObjexxFCL::Optional_string_const CompType = _, // when mustprint (ScanPlantLoop) use CompType in error message and scan
296 : ObjexxFCL::Optional_string_const CompName = _ // when mustprint (ScanPlantLoop) use CompName in error message and scan
297 : );
298 :
299 : void TestBranchIntegrity(EnergyPlusData &state, bool &ErrFound); // ErrFound is a return value, true or false
300 :
301 : } // namespace BranchInputManager
302 :
303 : struct BranchInputManagerData : BaseGlobalStruct
304 : {
305 : bool GetBranchInputFlag = true; // Flag used to retrieve Input
306 : bool GetBranchListInputFlag = true; // Flag used to retrieve Input
307 : bool GetSplitterInputFlag = true; // Flag used to retrieve Input
308 : bool GetMixerInputFlag = true; // Flag used to retrieve Input
309 : bool GetConnectorListInputFlag = true; // Flag used to retrieve Input
310 : bool InvalidBranchDefinitions = false;
311 : bool GetBranchInputOneTimeFlag = true;
312 :
313 : Array1D<BranchInputManager::BranchListData> BranchList; // Branch List data for each Branch List
314 : Array1D<BranchInputManager::BranchData> Branch; // Branch Data for each Branch
315 : Array1D<BranchInputManager::ConnectorData> ConnectorLists; // Connector List data for each Connector List
316 : Array1D<BranchInputManager::SplitterData> Splitters; // Splitter Data for each Splitter
317 : Array1D<BranchInputManager::MixerData> Mixers; // Mixer Data for each Mixer
318 : Array1D<BranchInputManager::ComponentData> BComponents; // Component data to be returned
319 :
320 796 : void init_state([[maybe_unused]] EnergyPlusData &state) override
321 : {
322 796 : }
323 :
324 0 : void clear_state() override
325 : {
326 0 : new (this) BranchInputManagerData();
327 0 : }
328 : };
329 :
330 : } // namespace EnergyPlus
331 :
332 : #endif
|