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 HVACInterfaceManager_hh_INCLUDED
49 : #define HVACInterfaceManager_hh_INCLUDED
50 :
51 : // ObjexxFCL Headers
52 : #include <ObjexxFCL/Array1D.hh>
53 :
54 : // EnergyPlus Headers
55 : #include <EnergyPlus/Data/BaseData.hh>
56 : #include <EnergyPlus/DataConvergParams.hh>
57 : #include <EnergyPlus/EnergyPlus.hh>
58 : #include <EnergyPlus/Plant/Enums.hh>
59 : #include <EnergyPlus/Plant/PlantLocation.hh>
60 :
61 : namespace EnergyPlus {
62 :
63 : // Forward declarations
64 : struct EnergyPlusData;
65 :
66 : namespace HVACInterfaceManager {
67 :
68 : // Common Pipe Recirc Flow Directions
69 : // can't change these to enum class since these are used in SetupOutputVariable()
70 : constexpr int NoRecircFlow(0);
71 : constexpr int PrimaryRecirc(1); // flow from Supply-outlet/Demand-inlet to Supply-inlet/demand-outlet
72 : constexpr int SecondaryRecirc(2); // flow from Supply-inlet/Demand-outlet to Supply-outlet/demand-inlet
73 :
74 : enum class FlowType
75 : {
76 : Invalid = -1,
77 : Constant,
78 : Variable,
79 : Num
80 : };
81 :
82 : struct CommonPipeData
83 : {
84 : // Members
85 : DataPlant::CommonPipeType CommonPipeType = DataPlant::CommonPipeType::No; // type of common pipe used if any
86 : FlowType SupplySideInletPumpType = FlowType::Invalid;
87 : FlowType DemandSideInletPumpType = FlowType::Invalid;
88 : // Following report variables are used in uncontrolled common pipe
89 : int FlowDir = 0; // Direction in which flow is in Common Pipe
90 : Real64 Flow = 0.0; // Flow in the Common Pipe
91 : Real64 Temp = 0.0;
92 : // Following report variables are used in two-way common pipe
93 : Real64 SecCPLegFlow = 0.0; // Mass flow in the secondary side Common pipe leg
94 : Real64 PriCPLegFlow = 0.0; // Mass flow in the primary side Common pipe leg
95 : Real64 SecToPriFlow = 0.0; // Mass flow in the pipe from Secondary to primary side
96 : Real64 PriToSecFlow = 0.0; // Mass flow in the pipe from primary to Secondary side
97 : Real64 PriInTemp = 0.0; // Temperature at primary inlet node
98 : Real64 PriOutTemp = 0.0; // Temperature at primary outlet node
99 : Real64 SecInTemp = 0.0; // Temperature at secondary inlet node
100 : Real64 SecOutTemp = 0.0; // Temperature at secondary outlet node
101 : Real64 PriInletSetPoint = 0.0; // Setpoint at Primary inlet node
102 : Real64 SecInletSetPoint = 0.0; // Setpoint at Secondary inlet node
103 : bool PriInletControlled = false; // True if Primary inlet node is controlled
104 : bool SecInletControlled = false; // True if secondary inlet is controlled
105 : Real64 PriFlowRequest = 0.0; // total flow request on supply side.
106 : bool MyEnvrnFlag = true;
107 : };
108 :
109 : void UpdateHVACInterface(EnergyPlusData &state,
110 : int AirLoopNum, // airloop number for which air loop this is
111 : DataConvergParams::CalledFrom CalledFrom,
112 : int OutletNode, // Node number for the outlet of the side of the loop just simulated
113 : int InletNode, // Node number for the inlet of the side that needs the outlet node data
114 : bool &OutOfToleranceFlag // True when the other side of the loop need to be (re)simulated
115 : );
116 :
117 : void UpdatePlantLoopInterface(EnergyPlusData &state,
118 : PlantLocation const &plantLoc, // The 'outlet node' Location
119 : int ThisLoopSideOutletNode, // Node number for the inlet of the side that needs the outlet node data
120 : int OtherLoopSideInletNode, // Node number for the outlet of the side of the loop just simulated
121 : bool &OutOfToleranceFlag, // True when the other side of the loop need to be (re)simulated
122 : DataPlant::CommonPipeType CommonPipeType);
123 :
124 : void UpdateHalfLoopInletTemp(EnergyPlusData &state, int LoopNum, DataPlant::LoopSideLocation TankInletLoopSide, Real64 &TankOutletTemp);
125 :
126 : void UpdateCommonPipe(EnergyPlusData &state,
127 : const PlantLocation &TankInletPlantLoc,
128 : DataPlant::CommonPipeType CommonPipeType,
129 : Real64 &MixedOutletTemp);
130 :
131 : void ManageSingleCommonPipe(EnergyPlusData &state,
132 : int LoopNum, // plant loop number
133 : DataPlant::LoopSideLocation LoopSide, // plant loop side number
134 : Real64 TankOutletTemp, // inlet temperature to the common pipe passed in from the capacitance calculation
135 : Real64 &MixedOutletTemp // inlet temperature to the common pipe passed in from the capacitance calculation
136 : );
137 :
138 : void ManageTwoWayCommonPipe(EnergyPlusData &state, PlantLocation const &plantLoc, Real64 TankOutletTemp);
139 :
140 : void SetupCommonPipes(EnergyPlusData &state);
141 :
142 : // In-Place Right Shift by 1 of Array Elements
143 72401020 : inline void rshift1(std::array<Real64, DataConvergParams::ConvergLogStackDepth> &a)
144 : {
145 72401020 : Real64 lastVal = a[a.size() - 1];
146 724010200 : for (unsigned int i = a.size() - 1; i > 0; --i) {
147 651609180 : a[i] = a[i - 1];
148 : }
149 72401020 : a[0] = lastVal;
150 72401020 : }
151 :
152 : } // namespace HVACInterfaceManager
153 :
154 : struct HVACInterfaceManagerData : BaseGlobalStruct
155 : {
156 :
157 : bool CommonPipeSetupFinished = false;
158 : Array1D<HVACInterfaceManager::CommonPipeData> PlantCommonPipe;
159 : Array1D<Real64> TmpRealARR = Array1D<Real64>(DataConvergParams::ConvergLogStackDepth); // Tuned Made static
160 :
161 796 : void init_state([[maybe_unused]] EnergyPlusData &state) override
162 : {
163 796 : }
164 :
165 0 : void clear_state() override
166 : {
167 0 : this->CommonPipeSetupFinished = false;
168 0 : this->PlantCommonPipe.deallocate();
169 0 : }
170 : };
171 :
172 : } // namespace EnergyPlus
173 :
174 : #endif
|