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 : // ObjexxFCL Headers
49 : #include <ObjexxFCL/Array.functions.hh>
50 : #include <ObjexxFCL/Fmath.hh>
51 :
52 : // EnergyPlus Headers
53 : #include <AirflowNetwork/Solver.hpp>
54 : #include <EnergyPlus/Data/EnergyPlusData.hh>
55 : #include <EnergyPlus/DataHVACGlobals.hh>
56 : #include <EnergyPlus/DataIPShortCuts.hh>
57 : #include <EnergyPlus/DataLoopNode.hh>
58 : #include <EnergyPlus/DataZoneEquipment.hh>
59 : #include <EnergyPlus/GeneralRoutines.hh>
60 : #include <EnergyPlus/InputProcessing/InputProcessor.hh>
61 : #include <EnergyPlus/MixerComponent.hh>
62 : #include <EnergyPlus/NodeInputManager.hh>
63 : #include <EnergyPlus/ReturnAirPathManager.hh>
64 : #include <EnergyPlus/UtilityRoutines.hh>
65 : #include <EnergyPlus/ZonePlenum.hh>
66 :
67 : namespace EnergyPlus {
68 :
69 : namespace ReturnAirPathManager {
70 : // Module containing the routines dealing with the AirLoopHVAC:ReturnPath (formerly Return Air Path)
71 :
72 : // MODULE INFORMATION:
73 : // AUTHOR Russ Taylor
74 : // DATE WRITTEN January 1998
75 : // MODIFIED Lawrie, September 1999 -- consolidate ReturnAirPath data structure
76 : // RE-ENGINEERED na
77 :
78 : // PURPOSE OF THIS MODULE:
79 : // To manage the return air path.
80 :
81 424465 : void SimReturnAirPath(EnergyPlusData &state)
82 : {
83 :
84 : // SUBROUTINE INFORMATION:
85 : // AUTHOR: Russ Taylor
86 : // DATE WRITTEN: Nov 1997
87 :
88 : // Locals
89 : int ReturnAirPathNum;
90 :
91 : // Obtains and Allocates Mixer related parameters from input file
92 424465 : if (state.dataRetAirPathMrg->GetInputFlag) { // First time subroutine has been entered
93 110 : GetReturnAirPathInput(state);
94 110 : state.dataRetAirPathMrg->GetInputFlag = false;
95 : }
96 :
97 500313 : for (ReturnAirPathNum = 1; ReturnAirPathNum <= state.dataZoneEquip->NumReturnAirPaths; ++ReturnAirPathNum) {
98 75848 : CalcReturnAirPath(state, ReturnAirPathNum);
99 : }
100 424465 : }
101 :
102 111 : void GetReturnAirPathInput(EnergyPlusData &state)
103 : {
104 : // SUBROUTINE INFORMATION:
105 : // AUTHOR: Russ Taylor
106 : // DATE WRITTEN: Nov 1997
107 :
108 : // PURPOSE OF THIS SUBROUTINE: This subroutine
109 :
110 : // Using/Aliasing
111 : using NodeInputManager::GetOnlySingleNode;
112 : using namespace DataLoopNode;
113 :
114 : //////////// hoisted into namespace ////////////////////////////////////////////////
115 : // static bool ErrorsFound( false );
116 : ////////////////////////////////////////////////////////////////////////////////////
117 :
118 111 : bool ErrorsFound = false;
119 :
120 111 : if (allocated(state.dataZoneEquip->ReturnAirPath)) {
121 110 : return;
122 : }
123 1 : auto &cCurrentModuleObject = state.dataIPShortCut->cCurrentModuleObject;
124 1 : cCurrentModuleObject = "AirLoopHVAC:ReturnPath";
125 1 : state.dataZoneEquip->NumReturnAirPaths = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject);
126 :
127 1 : if (state.dataZoneEquip->NumReturnAirPaths > 0) {
128 : int NumAlphas;
129 : int NumNums;
130 : int IOStat;
131 :
132 1 : state.dataZoneEquip->ReturnAirPath.allocate(state.dataZoneEquip->NumReturnAirPaths);
133 :
134 2 : for (int PathNum = 1; PathNum <= state.dataZoneEquip->NumReturnAirPaths; ++PathNum) {
135 :
136 2 : state.dataInputProcessing->inputProcessor->getObjectItem(state,
137 : cCurrentModuleObject,
138 : PathNum,
139 1 : state.dataIPShortCut->cAlphaArgs,
140 : NumAlphas,
141 1 : state.dataIPShortCut->rNumericArgs,
142 : NumNums,
143 : IOStat);
144 1 : Util::IsNameEmpty(state, state.dataIPShortCut->cAlphaArgs(1), cCurrentModuleObject, ErrorsFound);
145 :
146 1 : state.dataZoneEquip->ReturnAirPath(PathNum).Name = state.dataIPShortCut->cAlphaArgs(1);
147 1 : state.dataZoneEquip->ReturnAirPath(PathNum).NumOfComponents = nint((NumAlphas - 2.0) / 2.0);
148 :
149 1 : state.dataZoneEquip->ReturnAirPath(PathNum).OutletNodeNum =
150 2 : GetOnlySingleNode(state,
151 1 : state.dataIPShortCut->cAlphaArgs(2),
152 : ErrorsFound,
153 : DataLoopNode::ConnectionObjectType::AirLoopHVACReturnPath,
154 1 : state.dataIPShortCut->cAlphaArgs(1),
155 : DataLoopNode::NodeFluidType::Air,
156 : DataLoopNode::ConnectionType::Outlet,
157 : NodeInputManager::CompFluidStream::Primary,
158 : ObjectIsParent);
159 :
160 1 : state.dataZoneEquip->ReturnAirPath(PathNum).ComponentType.allocate(state.dataZoneEquip->ReturnAirPath(PathNum).NumOfComponents);
161 1 : state.dataZoneEquip->ReturnAirPath(PathNum).ComponentType = "";
162 1 : state.dataZoneEquip->ReturnAirPath(PathNum).ComponentTypeEnum.allocate(state.dataZoneEquip->ReturnAirPath(PathNum).NumOfComponents);
163 1 : state.dataZoneEquip->ReturnAirPath(PathNum).ComponentTypeEnum = DataZoneEquipment::AirLoopHVACZone::Invalid;
164 1 : state.dataZoneEquip->ReturnAirPath(PathNum).ComponentName.allocate(state.dataZoneEquip->ReturnAirPath(PathNum).NumOfComponents);
165 1 : state.dataZoneEquip->ReturnAirPath(PathNum).ComponentName = "";
166 1 : state.dataZoneEquip->ReturnAirPath(PathNum).ComponentIndex.allocate(state.dataZoneEquip->ReturnAirPath(PathNum).NumOfComponents);
167 1 : state.dataZoneEquip->ReturnAirPath(PathNum).ComponentIndex = 0;
168 1 : int Counter = 3;
169 :
170 2 : for (int CompNum = 1; CompNum <= state.dataZoneEquip->ReturnAirPath(PathNum).NumOfComponents; ++CompNum) {
171 :
172 1 : if ((Util::SameString(state.dataIPShortCut->cAlphaArgs(Counter), "AirLoopHVAC:ZoneMixer")) ||
173 1 : (Util::SameString(state.dataIPShortCut->cAlphaArgs(Counter), "AirLoopHVAC:ReturnPlenum"))) {
174 :
175 : bool IsNotOK; // Flag to verify name
176 1 : state.dataZoneEquip->ReturnAirPath(PathNum).ComponentType(CompNum) = state.dataIPShortCut->cAlphaArgs(Counter);
177 1 : state.dataZoneEquip->ReturnAirPath(PathNum).ComponentName(CompNum) = state.dataIPShortCut->cAlphaArgs(Counter + 1);
178 2 : ValidateComponent(state,
179 1 : state.dataZoneEquip->ReturnAirPath(PathNum).ComponentType(CompNum),
180 1 : state.dataZoneEquip->ReturnAirPath(PathNum).ComponentName(CompNum),
181 : IsNotOK,
182 : "AirLoopHVAC:ReturnPath");
183 1 : if (IsNotOK) {
184 0 : ShowContinueError(state, format("In AirLoopHVAC:ReturnPath ={}", state.dataZoneEquip->ReturnAirPath(PathNum).Name));
185 0 : ErrorsFound = true;
186 : }
187 1 : state.dataZoneEquip->ReturnAirPath(PathNum).ComponentTypeEnum(CompNum) = static_cast<DataZoneEquipment::AirLoopHVACZone>(
188 2 : getEnumValue(DataZoneEquipment::AirLoopHVACTypeNamesCC, state.dataIPShortCut->cAlphaArgs(Counter)));
189 :
190 : } else {
191 0 : ShowSevereError(
192 0 : state, format("Unhandled component type in AirLoopHVAC:ReturnPath of {}", state.dataIPShortCut->cAlphaArgs(Counter)));
193 0 : ShowContinueError(state, format("Occurs in AirLoopHVAC:ReturnPath = {}", state.dataZoneEquip->ReturnAirPath(PathNum).Name));
194 0 : ShowContinueError(state, "Must be \"AirLoopHVAC:ZoneMixer\" or \"AirLoopHVAC:ReturnPlenum\"");
195 0 : ErrorsFound = true;
196 : }
197 :
198 1 : Counter += 2;
199 : }
200 : }
201 : }
202 :
203 1 : if (ErrorsFound) {
204 0 : ShowFatalError(state, "Errors found getting AirLoopHVAC:ReturnPath. Preceding condition(s) causes termination.");
205 : }
206 : }
207 :
208 75848 : void CalcReturnAirPath(EnergyPlusData &state, int &ReturnAirPathNum)
209 : {
210 : // SUBROUTINE INFORMATION:
211 : // AUTHOR: Russ Taylor
212 : // DATE WRITTEN: Nov 1997
213 :
214 : // PURPOSE OF THIS SUBROUTINE: This subroutine
215 :
216 : // METHODOLOGY EMPLOYED:
217 :
218 : // REFERENCES:
219 :
220 : // USE STATEMENTS:
221 :
222 : // Using/Aliasing
223 : using MixerComponent::SimAirMixer;
224 : using ZonePlenum::SimAirZonePlenum;
225 :
226 : // Locals
227 : int ComponentNum;
228 :
229 151697 : for (ComponentNum = 1; ComponentNum <= state.dataZoneEquip->ReturnAirPath(ReturnAirPathNum).NumOfComponents; ++ComponentNum) {
230 75849 : switch (state.dataZoneEquip->ReturnAirPath(ReturnAirPathNum).ComponentTypeEnum(ComponentNum)) {
231 75842 : case DataZoneEquipment::AirLoopHVACZone::Mixer: // 'AirLoopHVAC:ZoneMixer'
232 :
233 75842 : if (!(state.afn->AirflowNetworkFanActivated && state.afn->distribution_simulated)) {
234 67549 : SimAirMixer(state,
235 67549 : state.dataZoneEquip->ReturnAirPath(ReturnAirPathNum).ComponentName(ComponentNum),
236 67549 : state.dataZoneEquip->ReturnAirPath(ReturnAirPathNum).ComponentIndex(ComponentNum));
237 : }
238 :
239 75842 : break;
240 :
241 7 : case DataZoneEquipment::AirLoopHVACZone::ReturnPlenum: // 'AirLoopHVAC:ReturnPlenum'
242 :
243 14 : SimAirZonePlenum(state,
244 7 : state.dataZoneEquip->ReturnAirPath(ReturnAirPathNum).ComponentName(ComponentNum),
245 : DataZoneEquipment::AirLoopHVACZone::ReturnPlenum,
246 7 : state.dataZoneEquip->ReturnAirPath(ReturnAirPathNum).ComponentIndex(ComponentNum));
247 7 : break;
248 :
249 0 : default:
250 0 : ShowSevereError(state,
251 0 : format("Invalid AirLoopHVAC:ReturnPath Component={}",
252 0 : state.dataZoneEquip->ReturnAirPath(ReturnAirPathNum).ComponentType(ComponentNum)));
253 0 : ShowContinueError(state, format("Occurs in AirLoopHVAC:ReturnPath ={}", state.dataZoneEquip->ReturnAirPath(ReturnAirPathNum).Name));
254 0 : ShowFatalError(state, "Preceding condition causes termination.");
255 0 : break;
256 : }
257 : }
258 75848 : }
259 :
260 0 : void ReportReturnAirPath([[maybe_unused]] int &ReturnAirPathNum) // unused1208
261 : {
262 : // SUBROUTINE INFORMATION:
263 : // AUTHOR: Russ Taylor
264 : // DATE WRITTEN: Nov 1997
265 :
266 : // PURPOSE OF THIS SUBROUTINE: This subroutine
267 :
268 : // METHODOLOGY EMPLOYED:
269 :
270 : // REFERENCES:
271 :
272 : // USE STATEMENTS:
273 0 : }
274 :
275 : } // namespace ReturnAirPathManager
276 :
277 : } // namespace EnergyPlus
|