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 PlantUtilities_hh_INCLUDED
49 : #define PlantUtilities_hh_INCLUDED
50 :
51 : // ObjexxFCL Headers
52 : #include <ObjexxFCL/Optional.hh>
53 :
54 : // EnergyPlus Headers
55 : #include <EnergyPlus/Data/BaseData.hh>
56 : #include <EnergyPlus/EnergyPlus.hh>
57 : #include <EnergyPlus/Plant/Enums.hh>
58 : #include <EnergyPlus/Plant/PlantLocation.hh>
59 :
60 : namespace EnergyPlus {
61 :
62 : // Forward declarations
63 : struct EnergyPlusData;
64 :
65 : namespace PlantUtilities {
66 :
67 : // Functions
68 : void InitComponentNodes(EnergyPlusData &state, Real64 const MinCompMdot, Real64 const MaxCompMdot, int const InletNode, int const OutletNode);
69 :
70 : void SetComponentFlowRate(EnergyPlusData &state,
71 : Real64 &CompFlow, // [kg/s]
72 : int InletNode, // component's inlet node index in node structure
73 : int OutletNode, // component's outlet node index in node structure
74 : PlantLocation const &plantLoc // component location for PlantLoop
75 : );
76 :
77 : void SetActuatedBranchFlowRate(EnergyPlusData &state,
78 : Real64 &CompFlow,
79 : int ActuatedNode,
80 : PlantLocation const &plantLoc,
81 : bool ResetMode // flag to indicate if this is a real flow set, or a reset flow setting.
82 : );
83 :
84 : Real64 RegulateCondenserCompFlowReqOp(EnergyPlusData &state, PlantLocation const &plantLoc, Real64 TentativeFlowRequest);
85 :
86 : bool AnyPlantSplitterMixerLacksContinuity(EnergyPlusData &state);
87 :
88 : void CheckPlantMixerSplitterConsistency(EnergyPlusData &state,
89 : const int LoopNum,
90 : const DataPlant::LoopSideLocation LoopSideNum,
91 : const bool FirstHVACIteration);
92 :
93 : void CheckForRunawayPlantTemps(EnergyPlusData &state, int LoopNum, const DataPlant::LoopSideLocation LoopSideNum);
94 :
95 : void SetAllFlowLocks(EnergyPlusData &state, DataPlant::FlowLock Value);
96 :
97 : void ResetAllPlantInterConnectFlags(EnergyPlusData &state);
98 :
99 : void PullCompInterconnectTrigger(EnergyPlusData &state,
100 : const PlantLocation &plantLoc, // Component Location
101 : int &UniqueCriteriaCheckIndex, // An integer given to this particular check
102 : const PlantLocation &ConnectedPlantLoc, // Interconnected Component's Location
103 : const DataPlant::CriteriaType CriteriaType, // The criteria check to use, see DataPlant: SimFlagCriteriaTypes
104 : const Real64 CriteriaValue // The value of the criteria check to evaluate
105 : );
106 :
107 : void UpdateChillerComponentCondenserSide(EnergyPlusData &state,
108 : int LoopNum, // component's loop index
109 : DataPlant::LoopSideLocation LoopSide, // component's loop side number
110 : DataPlant::PlantEquipmentType Type, // Component's type index
111 : int InletNodeNum, // Component's inlet node pointer
112 : int OutletNodeNum, // Component's outlet node pointer
113 : Real64 ModelCondenserHeatRate, // model's heat rejection rate at condenser (W)
114 : Real64 ModelInletTemp, // model's inlet temperature (C)
115 : Real64 ModelOutletTemp, // model's outlet temperature (C)
116 : Real64 ModelMassFlowRate, // model's condenser water mass flow rate (kg/s)
117 : bool FirstHVACIteration);
118 :
119 : void UpdateComponentHeatRecoverySide(EnergyPlusData &state,
120 : int LoopNum, // component's loop index
121 : DataPlant::LoopSideLocation LoopSide, // component's loop side number
122 : DataPlant::PlantEquipmentType Type, // Component's type index
123 : int InletNodeNum, // Component's inlet node pointer
124 : int OutletNodeNum, // Component's outlet node pointer
125 : Real64 ModelRecoveryHeatRate, // model's heat rejection rate at recovery (W)
126 : Real64 ModelInletTemp, // model's inlet temperature (C)
127 : Real64 ModelOutletTemp, // model's outlet temperature (C)
128 : Real64 ModelMassFlowRate, // model's condenser water mass flow rate (kg/s)
129 : bool FirstHVACIteration);
130 :
131 : void UpdateAbsorberChillerComponentGeneratorSide(EnergyPlusData &state,
132 : int LoopNum, // component's loop index
133 : DataPlant::LoopSideLocation LoopSide, // component's loop side number
134 : DataPlant::PlantEquipmentType Type, // Component's type index
135 : int InletNodeNum, // Component's inlet node pointer
136 : int OutletNodeNum, // Component's outlet node pointer
137 : DataLoopNode::NodeFluidType HeatSourceType, // Type of fluid in Generator loop
138 : Real64 ModelGeneratorHeatRate, // model's generator heat rate (W)
139 : Real64 ModelMassFlowRate, // model's generator mass flow rate (kg/s)
140 : bool FirstHVACIteration);
141 :
142 : void InterConnectTwoPlantLoopSides(EnergyPlusData &state,
143 : PlantLocation const &Loop1PlantLoc,
144 : PlantLocation const &Loop2PlantLoc,
145 : DataPlant::PlantEquipmentType ComponentType,
146 : bool Loop1DemandsOnLoop2);
147 :
148 : void ShiftPlantLoopSideCallingOrder(EnergyPlusData &state, int OldIndex, int NewIndex);
149 :
150 : void RegisterPlantCompDesignFlow(EnergyPlusData &state,
151 : int ComponentInletNodeNum, // the component's water inlet node number
152 : Real64 DesPlantFlow // the component's design fluid volume flow rate [m3/s]
153 : );
154 :
155 : void SafeCopyPlantNode(EnergyPlusData &state,
156 : int InletNodeNum,
157 : int OutletNodeNum,
158 : ObjexxFCL::Optional_int_const LoopNum = _,
159 : ObjexxFCL::Optional<Real64 const> OutletTemp = _ // set on outlet node if present and water.
160 : );
161 :
162 : Real64 BoundValueToNodeMinMaxAvail(EnergyPlusData &state, Real64 ValueToBound, int NodeNumToBoundWith);
163 :
164 : void TightenNodeMinMaxAvails(EnergyPlusData &state, int NodeNum, Real64 NewMinAvail, Real64 NewMaxAvail);
165 :
166 : Real64 BoundValueToWithinTwoValues(Real64 ValueToBound, Real64 LowerBound, Real64 UpperBound);
167 :
168 : bool IntegerIsWithinTwoValues(int ValueToCheck, int LowerBound, int UpperBound);
169 :
170 : void LogPlantConvergencePoints(EnergyPlusData &state, bool FirstHVACIteration);
171 :
172 : void ScanPlantLoopsForObject(EnergyPlusData &state,
173 : std::string_view CompName,
174 : DataPlant::PlantEquipmentType CompType,
175 : PlantLocation &plantLoc,
176 : bool &errFlag,
177 : ObjexxFCL::Optional<Real64 const> LowLimitTemp = _,
178 : ObjexxFCL::Optional<Real64 const> HighLimitTemp = _,
179 : ObjexxFCL::Optional_int CountMatchPlantLoops = _,
180 : ObjexxFCL::Optional_int_const InletNodeNumber = _,
181 : ObjexxFCL::Optional_int_const SingleLoopSearch = _,
182 : ObjexxFCL::Optional_bool_const suppressErrors = _);
183 :
184 : void ScanPlantLoopsForNodeNum(EnergyPlusData &state,
185 : std::string_view const CallerName, // really used for error messages
186 : int NodeNum, // index in Node structure of node to be scanned
187 : PlantLocation &pLantLoc, // return value for location
188 : ObjexxFCL::Optional_int CompNum = _);
189 :
190 : bool AnyPlantLoopSidesNeedSim(EnergyPlusData &state);
191 :
192 : void SetAllPlantSimFlagsToValue(EnergyPlusData &state, bool Value);
193 :
194 : void ShowBranchesOnLoop(EnergyPlusData &state, int LoopNum); // Loop number of loop
195 :
196 : int MyPlantSizingIndex(EnergyPlusData &state,
197 : std::string_view CompType, // component description
198 : std::string_view CompName, // user name of component
199 : int NodeNumIn, // component water inlet node
200 : int NodeNumOut, // component water outlet node
201 : bool &ErrorsFound, // set to true if there's an error
202 : bool const PrintErrorFlag = true // used for WSHP's where condenser loop may not be on a plant loop
203 : );
204 :
205 : bool verifyTwoNodeNumsOnSamePlantLoop(EnergyPlusData &state, int nodeIndexA, int nodeIndexB);
206 :
207 : Real64 MinFlowIfBranchHasVSPump(
208 : EnergyPlusData &state, PlantLocation const &pLantLoc, bool &foundBranchPump, bool &foundLoopPump, bool const setFlowStatus);
209 :
210 : struct CriteriaData
211 : {
212 : // Members
213 : int CallingCompLoopNum; // for debug error handling
214 : DataPlant::LoopSideLocation CallingCompLoopSideNum; // for debug error handling
215 : int CallingCompBranchNum; // for debug error handling
216 : int CallingCompCompNum; // for debug error handling
217 : Real64 ThisCriteriaCheckValue; // the previous value, to check the current against
218 :
219 : // Default Constructor
220 18323424 : CriteriaData()
221 18323424 : : CallingCompLoopNum(0), CallingCompLoopSideNum(DataPlant::LoopSideLocation::Invalid), CallingCompBranchNum(0), CallingCompCompNum(0),
222 18323424 : ThisCriteriaCheckValue(0.0)
223 : {
224 18323424 : }
225 : };
226 :
227 : } // namespace PlantUtilities
228 :
229 : struct PlantUtilitiesData : BaseGlobalStruct
230 : {
231 :
232 : Array1D<PlantUtilities::CriteriaData> CriteriaChecks; // stores criteria information
233 :
234 796 : void init_state([[maybe_unused]] EnergyPlusData &state) override
235 : {
236 796 : }
237 :
238 0 : void clear_state() override
239 : {
240 0 : this->CriteriaChecks.deallocate();
241 0 : }
242 : };
243 :
244 : } // namespace EnergyPlus
245 :
246 : #endif
|