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 <cmath>
50 :
51 : // EnergyPlus Headers
52 : #include <EnergyPlus/BranchNodeConnections.hh>
53 : #include <EnergyPlus/Data/EnergyPlusData.hh>
54 : #include <EnergyPlus/DataDefineEquip.hh>
55 : #include <EnergyPlus/DataEnvironment.hh>
56 : #include <EnergyPlus/DataHeatBalance.hh>
57 : #include <EnergyPlus/DataIPShortCuts.hh>
58 : #include <EnergyPlus/DataLoopNode.hh>
59 : #include <EnergyPlus/DataRuntimeLanguage.hh>
60 : #include <EnergyPlus/DataWater.hh>
61 : #include <EnergyPlus/DataZoneEnergyDemands.hh>
62 : #include <EnergyPlus/DataZoneEquipment.hh>
63 : #include <EnergyPlus/EMSManager.hh>
64 : #include <EnergyPlus/FluidProperties.hh>
65 : #include <EnergyPlus/GlobalNames.hh>
66 : #include <EnergyPlus/HeatBalanceInternalHeatGains.hh>
67 : #include <EnergyPlus/InputProcessing/InputProcessor.hh>
68 : #include <EnergyPlus/NodeInputManager.hh>
69 : #include <EnergyPlus/Plant/PlantLocation.hh>
70 : #include <EnergyPlus/PlantUtilities.hh>
71 : #include <EnergyPlus/PluginManager.hh>
72 : #include <EnergyPlus/Psychrometrics.hh>
73 : #include <EnergyPlus/UserDefinedComponents.hh>
74 : #include <EnergyPlus/UtilityRoutines.hh>
75 : #include <EnergyPlus/WaterManager.hh>
76 :
77 : namespace EnergyPlus {
78 :
79 : namespace UserDefinedComponents {
80 :
81 : // Module containing the routines dealing with the User Defined HVAC and Plant component models
82 :
83 : // MODULE INFORMATION:
84 : // AUTHOR B. Griffith
85 : // DATE WRITTEN January 2012
86 : // MODIFIED na
87 : // RE-ENGINEERED na
88 :
89 : // PURPOSE OF THIS MODULE:
90 : // Collect component models for custom program with Erl.
91 :
92 0 : PlantComponent *UserPlantComponentStruct::factory(EnergyPlusData &state, std::string const &objectName)
93 : {
94 : // Process the input data
95 0 : if (state.dataUserDefinedComponents->GetPlantCompInput) {
96 0 : GetUserDefinedPlantComponents(state);
97 0 : state.dataUserDefinedComponents->GetPlantCompInput = false;
98 : }
99 : // Now look for this particular object
100 0 : for (auto &thisComp : state.dataUserDefinedComponents->UserPlantComp) {
101 0 : if (thisComp.Name == objectName) {
102 0 : return &thisComp;
103 : }
104 0 : }
105 : // If we didn't find it, fatal
106 0 : ShowFatalError(state,
107 : format("LocalUserDefinedPlantComponentFactory: Error getting inputs for object named: {}", objectName)); // LCOV_EXCL_LINE
108 : // Shut up the compiler
109 : return nullptr; // LCOV_EXCL_LINE
110 : }
111 :
112 0 : void UserPlantComponentStruct::onInitLoopEquip(EnergyPlusData &state, const PlantLocation &calledFromLocation)
113 : {
114 0 : Real64 myLoad = 0.0;
115 0 : int thisLoop = 0;
116 :
117 0 : this->initialize(state, calledFromLocation.loopNum, myLoad);
118 :
119 0 : for (int loop = 1; loop <= this->NumPlantConnections; ++loop) {
120 0 : if (calledFromLocation.loopNum != this->Loop(loop).plantLoc.loopNum) {
121 0 : continue;
122 : }
123 0 : if (calledFromLocation.loopSideNum != this->Loop(loop).plantLoc.loopSideNum) {
124 0 : continue;
125 : }
126 0 : thisLoop = loop;
127 : }
128 :
129 0 : if (thisLoop > 0) {
130 0 : if (this->Loop(thisLoop).ErlInitProgramMngr > 0) {
131 : bool anyEMSRan;
132 0 : EMSManager::ManageEMS(state, EMSManager::EMSCallFrom::UserDefinedComponentModel, anyEMSRan, this->Loop(thisLoop).ErlInitProgramMngr);
133 0 : } else if (this->Loop(thisLoop).initPluginLocation > -1) {
134 0 : state.dataPluginManager->pluginManager->runSingleUserDefinedPlugin(state, this->Loop(thisLoop).initPluginLocation);
135 0 : } else if (this->Loop(thisLoop).initCallbackIndex > -1) {
136 0 : state.dataPluginManager->pluginManager->runSingleUserDefinedCallback(state, this->Loop(thisLoop).initCallbackIndex);
137 : }
138 :
139 0 : PlantUtilities::InitComponentNodes(state,
140 0 : this->Loop(thisLoop).MassFlowRateMin,
141 0 : this->Loop(thisLoop).MassFlowRateMax,
142 0 : this->Loop(thisLoop).InletNodeNum,
143 0 : this->Loop(thisLoop).OutletNodeNum);
144 :
145 0 : PlantUtilities::RegisterPlantCompDesignFlow(state, this->Loop(thisLoop).InletNodeNum, this->Loop(thisLoop).DesignVolumeFlowRate);
146 :
147 : } else {
148 : // throw warning
149 0 : ShowFatalError(
150 : state,
151 0 : format("SimUserDefinedPlantComponent: did not find where called from. Loop number called from ={}, loop side called from ={}.",
152 0 : calledFromLocation.loopNum,
153 0 : calledFromLocation.loopSideNum));
154 : }
155 0 : }
156 :
157 0 : void UserPlantComponentStruct::getDesignCapacities(
158 : [[maybe_unused]] EnergyPlusData &state, const PlantLocation &calledFromLocation, Real64 &MaxLoad, Real64 &MinLoad, Real64 &OptLoad)
159 : {
160 0 : int thisLoop = 0;
161 0 : for (int loop = 1; loop <= this->NumPlantConnections; ++loop) {
162 0 : if (calledFromLocation.loopNum != this->Loop(loop).plantLoc.loopNum) {
163 0 : continue;
164 : }
165 0 : if (calledFromLocation.loopSideNum != this->Loop(loop).plantLoc.loopSideNum) {
166 0 : continue;
167 : }
168 0 : thisLoop = loop;
169 : }
170 :
171 0 : MinLoad = this->Loop(thisLoop).MinLoad;
172 0 : MaxLoad = this->Loop(thisLoop).MaxLoad;
173 0 : OptLoad = this->Loop(thisLoop).OptLoad;
174 0 : }
175 :
176 0 : void UserPlantComponentStruct::UserPlantComponentStruct::simulate(EnergyPlusData &state,
177 : const EnergyPlus::PlantLocation &calledFromLocation,
178 : [[maybe_unused]] bool FirstHVACIteration,
179 : Real64 &CurLoad,
180 : [[maybe_unused]] bool RunFlag)
181 : {
182 : // SUBROUTINE INFORMATION:
183 : // AUTHOR B. Griffith
184 : // DATE WRITTEN Jan 2012
185 : // MODIFIED na
186 : // RE-ENGINEERED na
187 :
188 : // PURPOSE OF THIS SUBROUTINE:
189 : // User Defined plant generic component
190 :
191 0 : if (state.dataGlobal->BeginEnvrnFlag) {
192 0 : this->onInitLoopEquip(state, calledFromLocation);
193 : }
194 :
195 : bool anyEMSRan;
196 0 : int thisLoop = 0;
197 :
198 0 : for (int loop = 1; loop <= this->NumPlantConnections; ++loop) {
199 0 : if (calledFromLocation.loopNum != this->Loop(loop).plantLoc.loopNum) {
200 0 : continue;
201 : }
202 0 : if (calledFromLocation.loopSideNum != this->Loop(loop).plantLoc.loopSideNum) {
203 0 : continue;
204 : }
205 0 : thisLoop = loop;
206 : }
207 :
208 0 : this->initialize(state, thisLoop, CurLoad);
209 :
210 0 : if (thisLoop > 0) {
211 0 : if (this->Loop(thisLoop).ErlSimProgramMngr > 0) {
212 0 : EMSManager::ManageEMS(state, EMSManager::EMSCallFrom::UserDefinedComponentModel, anyEMSRan, this->Loop(thisLoop).ErlSimProgramMngr);
213 0 : } else if (this->Loop(thisLoop).simPluginLocation > -1) {
214 0 : state.dataPluginManager->pluginManager->runSingleUserDefinedPlugin(state, this->Loop(thisLoop).simPluginLocation);
215 0 : } else if (this->Loop(thisLoop).simCallbackIndex > -1) {
216 0 : state.dataPluginManager->pluginManager->runSingleUserDefinedCallback(state, this->Loop(thisLoop).simCallbackIndex);
217 : }
218 : }
219 :
220 0 : if (this->ErlSimProgramMngr > 0) {
221 0 : EMSManager::ManageEMS(state, EMSManager::EMSCallFrom::UserDefinedComponentModel, anyEMSRan, this->ErlSimProgramMngr);
222 0 : } else if (this->simPluginLocation > -1) {
223 0 : state.dataPluginManager->pluginManager->runSingleUserDefinedPlugin(state, this->simPluginLocation);
224 0 : } else if (this->simCallbackIndex > -1) {
225 0 : state.dataPluginManager->pluginManager->runSingleUserDefinedCallback(state, this->simCallbackIndex);
226 : }
227 :
228 0 : this->report(state, thisLoop);
229 0 : }
230 :
231 0 : void SimCoilUserDefined(EnergyPlusData &state,
232 : std::string_view EquipName, // user name for component
233 : int &CompIndex,
234 : int const AirLoopNum,
235 : bool &HeatingActive,
236 : bool &CoolingActive)
237 : {
238 :
239 : // SUBROUTINE INFORMATION:
240 : // AUTHOR B. Griffith
241 : // DATE WRITTEN Feb. 2012
242 : // MODIFIED na
243 : // RE-ENGINEERED na
244 :
245 : int CompNum;
246 :
247 0 : if (state.dataUserDefinedComponents->GetPlantCompInput) {
248 0 : GetUserDefinedPlantComponents(state);
249 0 : state.dataUserDefinedComponents->GetPlantCompInput = false;
250 : }
251 :
252 : // Find the correct Equipment
253 0 : if (CompIndex == 0) {
254 0 : CompNum = Util::FindItemInList(EquipName, state.dataUserDefinedComponents->UserCoil);
255 0 : if (CompNum == 0) {
256 0 : ShowFatalError(state, "SimUserDefinedPlantComponent: User Defined Coil not found");
257 : }
258 0 : CompIndex = CompNum;
259 : } else {
260 0 : CompNum = CompIndex;
261 0 : if (CompNum < 1 || CompNum > state.dataUserDefinedComponents->NumUserCoils) {
262 0 : ShowFatalError(state,
263 0 : format("SimUserDefinedPlantComponent: Invalid CompIndex passed={}, Number of units ={}, Entered Unit name = {}",
264 : CompNum,
265 0 : state.dataUserDefinedComponents->NumUserCoils,
266 : EquipName));
267 : }
268 0 : if (state.dataUserDefinedComponents->CheckUserCoilName(CompNum)) {
269 0 : if (EquipName != state.dataUserDefinedComponents->UserCoil(CompNum).Name) {
270 0 : ShowFatalError(
271 : state,
272 0 : format("SimUserDefinedPlantComponent: Invalid CompIndex passed={}, Unit name={}, stored unit name for that index={}",
273 : CompNum,
274 : EquipName,
275 0 : state.dataUserDefinedComponents->UserCoil(CompNum).Name));
276 : }
277 0 : state.dataUserDefinedComponents->CheckUserCoilName(CompNum) = false;
278 : }
279 : }
280 : bool anyEMSRan;
281 0 : if (state.dataGlobal->BeginEnvrnFlag) {
282 0 : if (state.dataUserDefinedComponents->UserCoil(CompNum).ErlInitProgramMngr > 0) {
283 0 : EMSManager::ManageEMS(state,
284 : EMSManager::EMSCallFrom::UserDefinedComponentModel,
285 : anyEMSRan,
286 0 : state.dataUserDefinedComponents->UserCoil(CompNum).ErlInitProgramMngr);
287 0 : } else if (state.dataUserDefinedComponents->UserCoil(CompNum).initPluginLocation > -1) {
288 0 : state.dataPluginManager->pluginManager->runSingleUserDefinedPlugin(
289 0 : state, state.dataUserDefinedComponents->UserCoil(CompNum).initPluginLocation);
290 0 : } else if (state.dataUserDefinedComponents->UserCoil(CompNum).initCallbackIndex > -1) {
291 0 : state.dataPluginManager->pluginManager->runSingleUserDefinedCallback(
292 0 : state, state.dataUserDefinedComponents->UserCoil(CompNum).initCallbackIndex);
293 : }
294 :
295 0 : if (state.dataUserDefinedComponents->UserCoil(CompNum).PlantIsConnected) {
296 :
297 0 : PlantUtilities::InitComponentNodes(state,
298 0 : state.dataUserDefinedComponents->UserCoil(CompNum).Loop.MassFlowRateMin,
299 0 : state.dataUserDefinedComponents->UserCoil(CompNum).Loop.MassFlowRateMax,
300 0 : state.dataUserDefinedComponents->UserCoil(CompNum).Loop.InletNodeNum,
301 0 : state.dataUserDefinedComponents->UserCoil(CompNum).Loop.OutletNodeNum);
302 :
303 0 : PlantUtilities::RegisterPlantCompDesignFlow(state,
304 0 : state.dataUserDefinedComponents->UserCoil(CompNum).Loop.InletNodeNum,
305 0 : state.dataUserDefinedComponents->UserCoil(CompNum).Loop.DesignVolumeFlowRate);
306 : }
307 : }
308 :
309 0 : state.dataUserDefinedComponents->UserCoil(CompNum).initialize(state);
310 :
311 0 : if (state.dataUserDefinedComponents->UserCoil(CompNum).ErlSimProgramMngr > 0) {
312 0 : EMSManager::ManageEMS(state,
313 : EMSManager::EMSCallFrom::UserDefinedComponentModel,
314 : anyEMSRan,
315 0 : state.dataUserDefinedComponents->UserCoil(CompNum).ErlSimProgramMngr);
316 0 : } else if (state.dataUserDefinedComponents->UserCoil(CompNum).simPluginLocation > -1) {
317 0 : state.dataPluginManager->pluginManager->runSingleUserDefinedPlugin(state,
318 0 : state.dataUserDefinedComponents->UserCoil(CompNum).simPluginLocation);
319 0 : } else if (state.dataUserDefinedComponents->UserCoil(CompNum).simCallbackIndex > -1) {
320 0 : state.dataPluginManager->pluginManager->runSingleUserDefinedCallback(state,
321 0 : state.dataUserDefinedComponents->UserCoil(CompNum).simCallbackIndex);
322 : }
323 :
324 0 : state.dataUserDefinedComponents->UserCoil(CompNum).report(state);
325 :
326 0 : if (AirLoopNum != -1) { // IF the system is not an equipment of outdoor air unit
327 : // determine if heating or cooling on primary air stream
328 0 : HeatingActive = state.dataLoopNodes->Node(state.dataUserDefinedComponents->UserCoil(CompNum).Air(1).InletNodeNum).Temp <
329 0 : state.dataLoopNodes->Node(state.dataUserDefinedComponents->UserCoil(CompNum).Air(1).OutletNodeNum).Temp;
330 :
331 : Real64 EnthInlet =
332 0 : Psychrometrics::PsyHFnTdbW(state.dataLoopNodes->Node(state.dataUserDefinedComponents->UserCoil(CompNum).Air(1).InletNodeNum).Temp,
333 0 : state.dataLoopNodes->Node(state.dataUserDefinedComponents->UserCoil(CompNum).Air(1).InletNodeNum).HumRat);
334 : Real64 EnthOutlet =
335 0 : Psychrometrics::PsyHFnTdbW(state.dataLoopNodes->Node(state.dataUserDefinedComponents->UserCoil(CompNum).Air(1).OutletNodeNum).Temp,
336 0 : state.dataLoopNodes->Node(state.dataUserDefinedComponents->UserCoil(CompNum).Air(1).OutletNodeNum).HumRat);
337 0 : CoolingActive = EnthInlet > EnthOutlet;
338 : }
339 0 : }
340 :
341 12291 : void SimZoneAirUserDefined(EnergyPlusData &state,
342 : std::string_view CompName, // name of the packaged terminal heat pump
343 : int const ZoneNum, // number of zone being served
344 : Real64 &SensibleOutputProvided, // sensible capacity delivered to zone
345 : Real64 &LatentOutputProvided, // Latent add/removal (kg/s), dehumid = negative
346 : int &CompIndex // index to zone hvac unit
347 : )
348 : {
349 :
350 : // SUBROUTINE INFORMATION:
351 : // AUTHOR B. Griffith
352 : // DATE WRITTEN February, 2012
353 : // MODIFIED na
354 : // RE-ENGINEERED na
355 :
356 : int CompNum;
357 :
358 12291 : if (state.dataUserDefinedComponents->GetInput) {
359 1 : GetUserDefinedComponents(state);
360 1 : state.dataUserDefinedComponents->GetInput = false;
361 : }
362 :
363 : // Find the correct Equipment
364 12291 : if (CompIndex == 0) {
365 3 : CompNum = Util::FindItemInList(CompName, state.dataUserDefinedComponents->UserZoneAirHVAC);
366 3 : if (CompNum == 0) {
367 0 : ShowFatalError(state, "SimUserDefinedPlantComponent: User Defined Coil not found");
368 : }
369 3 : CompIndex = CompNum;
370 : } else {
371 12288 : CompNum = CompIndex;
372 12288 : if (CompNum < 1 || CompNum > state.dataUserDefinedComponents->NumUserZoneAir) {
373 0 : ShowFatalError(state,
374 0 : format("SimUserDefinedPlantComponent: Invalid CompIndex passed={}, Number of units ={}, Entered Unit name = {}",
375 : CompNum,
376 0 : state.dataUserDefinedComponents->NumUserZoneAir,
377 : CompName));
378 : }
379 12288 : if (state.dataUserDefinedComponents->CheckUserZoneAirName(CompNum)) {
380 3 : if (CompName != state.dataUserDefinedComponents->UserZoneAirHVAC(CompNum).Name) {
381 0 : ShowFatalError(
382 : state,
383 0 : format("SimUserDefinedPlantComponent: Invalid CompIndex passed={}, Unit name={}, stored unit name for that index={}",
384 : CompNum,
385 : CompName,
386 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompNum).Name));
387 : }
388 3 : state.dataUserDefinedComponents->CheckUserZoneAirName(CompNum) = false;
389 : }
390 : }
391 : bool anyEMSRan;
392 12291 : if (state.dataGlobal->BeginEnvrnFlag) {
393 72 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompNum).initialize(state, ZoneNum);
394 :
395 72 : if (state.dataUserDefinedComponents->UserZoneAirHVAC(CompNum).ErlInitProgramMngr > 0) {
396 48 : EMSManager::ManageEMS(state,
397 : EMSManager::EMSCallFrom::UserDefinedComponentModel,
398 : anyEMSRan,
399 48 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompNum).ErlInitProgramMngr);
400 24 : } else if (state.dataUserDefinedComponents->UserZoneAirHVAC(CompNum).initPluginLocation > -1) {
401 0 : state.dataPluginManager->pluginManager->runSingleUserDefinedPlugin(
402 0 : state, state.dataUserDefinedComponents->UserZoneAirHVAC(CompNum).initPluginLocation);
403 24 : } else if (state.dataUserDefinedComponents->UserZoneAirHVAC(CompNum).initCallbackIndex > -1) {
404 0 : state.dataPluginManager->pluginManager->runSingleUserDefinedCallback(
405 0 : state, state.dataUserDefinedComponents->UserZoneAirHVAC(CompNum).initCallbackIndex);
406 : }
407 72 : if (state.dataUserDefinedComponents->UserZoneAirHVAC(CompNum).NumPlantConnections > 0) {
408 0 : for (int Loop = 1; Loop <= state.dataUserDefinedComponents->UserZoneAirHVAC(CompNum).NumPlantConnections; ++Loop) {
409 :
410 0 : PlantUtilities::InitComponentNodes(state,
411 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompNum).Loop(Loop).MassFlowRateMin,
412 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompNum).Loop(Loop).MassFlowRateMax,
413 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompNum).Loop(Loop).InletNodeNum,
414 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompNum).Loop(Loop).OutletNodeNum);
415 :
416 0 : PlantUtilities::RegisterPlantCompDesignFlow(
417 : state,
418 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompNum).Loop(Loop).InletNodeNum,
419 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompNum).Loop(Loop).DesignVolumeFlowRate);
420 : }
421 : }
422 :
423 : } // BeginEnvrnFlag
424 :
425 12291 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompNum).initialize(state, ZoneNum);
426 :
427 12291 : if (state.dataUserDefinedComponents->UserZoneAirHVAC(CompNum).ErlSimProgramMngr > 0) {
428 8194 : EMSManager::ManageEMS(state,
429 : EMSManager::EMSCallFrom::UserDefinedComponentModel,
430 : anyEMSRan,
431 8194 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompNum).ErlSimProgramMngr);
432 4097 : } else if (state.dataUserDefinedComponents->UserZoneAirHVAC(CompNum).simPluginLocation > -1) {
433 0 : state.dataPluginManager->pluginManager->runSingleUserDefinedPlugin(
434 0 : state, state.dataUserDefinedComponents->UserZoneAirHVAC(CompNum).simPluginLocation);
435 4097 : } else if (state.dataUserDefinedComponents->UserZoneAirHVAC(CompNum).simCallbackIndex > -1) {
436 4097 : state.dataPluginManager->pluginManager->runSingleUserDefinedCallback(
437 4097 : state, state.dataUserDefinedComponents->UserZoneAirHVAC(CompNum).simCallbackIndex);
438 : }
439 :
440 12291 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompNum).report(state);
441 :
442 : // calculate delivered capacity
443 : Real64 AirMassFlow =
444 12291 : min(state.dataLoopNodes->Node(state.dataUserDefinedComponents->UserZoneAirHVAC(CompNum).ZoneAir.InletNodeNum).MassFlowRate,
445 12291 : state.dataLoopNodes->Node(state.dataUserDefinedComponents->UserZoneAirHVAC(CompNum).ZoneAir.OutletNodeNum).MassFlowRate);
446 : // calculate sensible load met using delta enthalpy at a constant (minimum) humidity ratio)
447 12291 : Real64 MinHumRat = min(state.dataLoopNodes->Node(state.dataUserDefinedComponents->UserZoneAirHVAC(CompNum).ZoneAir.InletNodeNum).HumRat,
448 12291 : state.dataLoopNodes->Node(state.dataUserDefinedComponents->UserZoneAirHVAC(CompNum).ZoneAir.OutletNodeNum).HumRat);
449 12291 : SensibleOutputProvided =
450 12291 : AirMassFlow *
451 12291 : (Psychrometrics::PsyHFnTdbW(
452 12291 : state.dataLoopNodes->Node(state.dataUserDefinedComponents->UserZoneAirHVAC(CompNum).ZoneAir.OutletNodeNum).Temp, MinHumRat) -
453 12291 : Psychrometrics::PsyHFnTdbW(
454 12291 : state.dataLoopNodes->Node(state.dataUserDefinedComponents->UserZoneAirHVAC(CompNum).ZoneAir.InletNodeNum).Temp, MinHumRat));
455 :
456 12291 : Real64 SpecHumOut = state.dataLoopNodes->Node(state.dataUserDefinedComponents->UserZoneAirHVAC(CompNum).ZoneAir.OutletNodeNum).HumRat;
457 12291 : Real64 SpecHumIn = state.dataLoopNodes->Node(state.dataUserDefinedComponents->UserZoneAirHVAC(CompNum).ZoneAir.InletNodeNum).HumRat;
458 12291 : LatentOutputProvided = AirMassFlow * (SpecHumOut - SpecHumIn); // Latent rate, kg/s (dehumid = negative)
459 12291 : }
460 :
461 0 : void SimAirTerminalUserDefined(EnergyPlusData &state,
462 : std::string_view CompName,
463 : [[maybe_unused]] bool const FirstHVACIteration,
464 : int const ZoneNum,
465 : [[maybe_unused]] int const ZoneNodeNum,
466 : int &CompIndex)
467 : {
468 :
469 : // SUBROUTINE INFORMATION:
470 : // AUTHOR B. Griffith
471 : // DATE WRITTEN March 2012
472 : // MODIFIED na
473 : // RE-ENGINEERED na
474 :
475 : // PURPOSE OF THIS SUBROUTINE:
476 : // simulation call for generic air terminal
477 :
478 : int CompNum;
479 :
480 0 : if (state.dataUserDefinedComponents->GetInput) {
481 0 : GetUserDefinedComponents(state);
482 0 : state.dataUserDefinedComponents->GetInput = false;
483 : }
484 :
485 : // Find the correct Equipment
486 0 : if (CompIndex == 0) {
487 0 : CompNum = Util::FindItemInList(CompName, state.dataUserDefinedComponents->UserAirTerminal);
488 0 : if (CompNum == 0) {
489 0 : ShowFatalError(state, "SimUserDefinedPlantComponent: User Defined Coil not found");
490 : }
491 0 : CompIndex = CompNum;
492 : } else {
493 0 : CompNum = CompIndex;
494 0 : if (CompNum < 1 || CompNum > state.dataUserDefinedComponents->NumUserAirTerminals) {
495 0 : ShowFatalError(state,
496 0 : format("SimUserDefinedPlantComponent: Invalid CompIndex passed={}, Number of units ={}, Entered Unit name = {}",
497 : CompNum,
498 0 : state.dataUserDefinedComponents->NumUserAirTerminals,
499 : CompName));
500 : }
501 0 : if (state.dataUserDefinedComponents->CheckUserAirTerminal(CompNum)) {
502 0 : if (CompName != state.dataUserDefinedComponents->UserAirTerminal(CompNum).Name) {
503 0 : ShowFatalError(
504 : state,
505 0 : format("SimUserDefinedPlantComponent: Invalid CompIndex passed={}, Unit name={}, stored unit name for that index={}",
506 : CompNum,
507 : CompName,
508 0 : state.dataUserDefinedComponents->UserAirTerminal(CompNum).Name));
509 : }
510 0 : state.dataUserDefinedComponents->CheckUserAirTerminal(CompNum) = false;
511 : }
512 : }
513 : bool anyEMSRan;
514 0 : if (state.dataGlobal->BeginEnvrnFlag) {
515 0 : state.dataUserDefinedComponents->UserAirTerminal(CompNum).initialize(state, ZoneNum);
516 :
517 0 : if (state.dataUserDefinedComponents->UserAirTerminal(CompNum).ErlInitProgramMngr > 0) {
518 0 : EMSManager::ManageEMS(state,
519 : EMSManager::EMSCallFrom::UserDefinedComponentModel,
520 : anyEMSRan,
521 0 : state.dataUserDefinedComponents->UserAirTerminal(CompNum).ErlInitProgramMngr);
522 0 : } else if (state.dataUserDefinedComponents->UserAirTerminal(CompNum).initPluginLocation > -1) {
523 0 : state.dataPluginManager->pluginManager->runSingleUserDefinedPlugin(
524 0 : state, state.dataUserDefinedComponents->UserAirTerminal(CompNum).initPluginLocation);
525 0 : } else if (state.dataUserDefinedComponents->UserAirTerminal(CompNum).initCallbackIndex > -1) {
526 0 : state.dataPluginManager->pluginManager->runSingleUserDefinedCallback(
527 0 : state, state.dataUserDefinedComponents->UserAirTerminal(CompNum).initCallbackIndex);
528 : }
529 0 : if (state.dataUserDefinedComponents->UserAirTerminal(CompNum).NumPlantConnections > 0) {
530 0 : for (int Loop = 1; Loop <= state.dataUserDefinedComponents->UserAirTerminal(CompNum).NumPlantConnections; ++Loop) {
531 :
532 0 : PlantUtilities::InitComponentNodes(state,
533 0 : state.dataUserDefinedComponents->UserAirTerminal(CompNum).Loop(Loop).MassFlowRateMin,
534 0 : state.dataUserDefinedComponents->UserAirTerminal(CompNum).Loop(Loop).MassFlowRateMax,
535 0 : state.dataUserDefinedComponents->UserAirTerminal(CompNum).Loop(Loop).InletNodeNum,
536 0 : state.dataUserDefinedComponents->UserAirTerminal(CompNum).Loop(Loop).OutletNodeNum);
537 :
538 0 : PlantUtilities::RegisterPlantCompDesignFlow(
539 : state,
540 0 : state.dataUserDefinedComponents->UserAirTerminal(CompNum).Loop(Loop).InletNodeNum,
541 0 : state.dataUserDefinedComponents->UserAirTerminal(CompNum).Loop(Loop).DesignVolumeFlowRate);
542 : }
543 : }
544 :
545 : } // BeginEnvrnFlag
546 :
547 0 : state.dataUserDefinedComponents->UserAirTerminal(CompNum).initialize(state, ZoneNum);
548 :
549 0 : if (state.dataUserDefinedComponents->UserAirTerminal(CompNum).ErlSimProgramMngr > 0) {
550 0 : EMSManager::ManageEMS(state,
551 : EMSManager::EMSCallFrom::UserDefinedComponentModel,
552 : anyEMSRan,
553 0 : state.dataUserDefinedComponents->UserAirTerminal(CompNum).ErlSimProgramMngr);
554 0 : } else if (state.dataUserDefinedComponents->UserAirTerminal(CompNum).simPluginLocation > -1) {
555 0 : state.dataPluginManager->pluginManager->runSingleUserDefinedPlugin(
556 0 : state, state.dataUserDefinedComponents->UserAirTerminal(CompNum).simPluginLocation);
557 0 : } else if (state.dataUserDefinedComponents->UserAirTerminal(CompNum).simCallbackIndex > -1) {
558 0 : state.dataPluginManager->pluginManager->runSingleUserDefinedCallback(
559 0 : state, state.dataUserDefinedComponents->UserAirTerminal(CompNum).simCallbackIndex);
560 : }
561 :
562 0 : state.dataUserDefinedComponents->UserAirTerminal(CompNum).report(state);
563 0 : }
564 :
565 2 : void GetUserDefinedPlantComponents(EnergyPlusData &state)
566 : {
567 2 : bool ErrorsFound(false);
568 : int NumAlphas; // Number of elements in the alpha array
569 : int NumNums; // Number of elements in the numeric array
570 : int IOStat; // IO Status when calling get input subroutine
571 : int TotalArgs; // argument for call to GetObjectDefMaxArgs
572 2 : Array1D_string cAlphaFieldNames;
573 2 : Array1D_bool lAlphaFieldBlanks;
574 2 : Array1D_string cAlphaArgs;
575 2 : Array1D<Real64> rNumericArgs;
576 2 : std::string cCurrentModuleObject;
577 :
578 2 : cCurrentModuleObject = "PlantComponent:UserDefined";
579 2 : state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, cCurrentModuleObject, TotalArgs, NumAlphas, NumNums);
580 :
581 2 : cAlphaFieldNames.allocate(NumAlphas);
582 2 : cAlphaArgs.allocate(NumAlphas);
583 2 : lAlphaFieldBlanks.dimension(NumAlphas, false);
584 2 : rNumericArgs.dimension(NumNums, 0.0);
585 :
586 : // need to make sure GetEMSInput has run...
587 :
588 4 : state.dataUserDefinedComponents->NumUserPlantComps =
589 2 : state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject);
590 2 : if (state.dataUserDefinedComponents->NumUserPlantComps > 0) {
591 0 : state.dataUserDefinedComponents->UserPlantComp.allocate(state.dataUserDefinedComponents->NumUserPlantComps);
592 0 : state.dataUserDefinedComponents->CheckUserPlantCompName.dimension(state.dataUserDefinedComponents->NumUserPlantComps, true);
593 0 : for (int CompLoop = 1; CompLoop <= state.dataUserDefinedComponents->NumUserPlantComps; ++CompLoop) {
594 0 : state.dataInputProcessing->inputProcessor->getObjectItem(state,
595 : cCurrentModuleObject,
596 : CompLoop,
597 : cAlphaArgs,
598 : NumAlphas,
599 : rNumericArgs,
600 : NumNums,
601 : IOStat,
602 : _,
603 : lAlphaFieldBlanks,
604 : cAlphaFieldNames,
605 : _);
606 0 : Util::IsNameEmpty(state, cAlphaArgs(1), cCurrentModuleObject, ErrorsFound);
607 :
608 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Name = cAlphaArgs(1);
609 :
610 : // now get program manager for model simulations
611 0 : if (!lAlphaFieldBlanks(2)) {
612 0 : int StackMngrNum = Util::FindItemInList(cAlphaArgs(2), state.dataRuntimeLang->EMSProgramCallManager);
613 0 : if (StackMngrNum > 0) { // found it
614 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).ErlSimProgramMngr = StackMngrNum;
615 : } else {
616 : // check Python Plugins
617 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).simPluginLocation =
618 0 : state.dataPluginManager->pluginManager->getLocationOfUserDefinedPlugin(state, cAlphaArgs(2));
619 0 : if (state.dataUserDefinedComponents->UserPlantComp(CompLoop).simPluginLocation == -1) {
620 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).simCallbackIndex =
621 0 : state.dataPluginManager->pluginManager->getUserDefinedCallbackIndex(state, cAlphaArgs(2));
622 0 : if (state.dataUserDefinedComponents->UserPlantComp(CompLoop).simCallbackIndex == -1) {
623 0 : ShowSevereError(state, format("Invalid {}={}", cAlphaFieldNames(2), cAlphaArgs(2)));
624 0 : ShowContinueError(state, format("Entered in {}={}", cCurrentModuleObject, cAlphaArgs(1)));
625 0 : ShowContinueError(
626 : state,
627 : "Program Manager Name not found as an EMS Program Manager, API callback or a Python Plugin Instance object.");
628 0 : ErrorsFound = true;
629 : }
630 : }
631 : }
632 : }
633 :
634 0 : int NumPlantConnections = std::floor(rNumericArgs(1));
635 :
636 0 : if ((NumPlantConnections >= 1) && (NumPlantConnections <= 4)) {
637 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Loop.allocate(NumPlantConnections);
638 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).NumPlantConnections = NumPlantConnections;
639 0 : for (int ConnectionLoop = 1; ConnectionLoop <= NumPlantConnections; ++ConnectionLoop) {
640 0 : const std::string LoopStr = fmt::to_string(ConnectionLoop);
641 0 : int aArgCount = (ConnectionLoop - 1) * 6 + 3;
642 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Loop(ConnectionLoop).InletNodeNum =
643 0 : NodeInputManager::GetOnlySingleNode(state,
644 0 : cAlphaArgs(aArgCount),
645 : ErrorsFound,
646 : DataLoopNode::ConnectionObjectType::PlantComponentUserDefined,
647 0 : cAlphaArgs(1),
648 : DataLoopNode::NodeFluidType::Water,
649 : DataLoopNode::ConnectionType::Inlet,
650 : static_cast<NodeInputManager::CompFluidStream>(ConnectionLoop),
651 : DataLoopNode::ObjectIsNotParent);
652 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Loop(ConnectionLoop).OutletNodeNum =
653 0 : NodeInputManager::GetOnlySingleNode(state,
654 0 : cAlphaArgs(aArgCount + 1),
655 : ErrorsFound,
656 : DataLoopNode::ConnectionObjectType::PlantComponentUserDefined,
657 0 : cAlphaArgs(1),
658 : DataLoopNode::NodeFluidType::Water,
659 : DataLoopNode::ConnectionType::Outlet,
660 : static_cast<NodeInputManager::CompFluidStream>(ConnectionLoop),
661 : DataLoopNode::ObjectIsNotParent);
662 :
663 0 : BranchNodeConnections::TestCompSet(
664 0 : state, cCurrentModuleObject, cAlphaArgs(1), cAlphaArgs(aArgCount), cAlphaArgs(aArgCount + 1), "Plant Nodes " + LoopStr);
665 :
666 : {
667 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Loop(ConnectionLoop).HowLoadServed =
668 : static_cast<DataPlant::HowMet>(
669 0 : getEnumValue(DataPlant::HowMetTypeNamesUC, Util::makeUPPER(cAlphaArgs(aArgCount + 2))));
670 0 : if (state.dataUserDefinedComponents->UserPlantComp(CompLoop).Loop(ConnectionLoop).HowLoadServed ==
671 : DataPlant::HowMet::ByNominalCapLowOutLimit) {
672 : // actuator for low out limit
673 0 : SetupEMSActuator(state,
674 0 : "Plant Connection " + LoopStr,
675 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Name,
676 : "Low Outlet Temperature Limit",
677 : "[C]",
678 0 : state.dataUserDefinedComponents->lDummy_EMSActuatedPlantComp,
679 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Loop(ConnectionLoop).LowOutTempLimit);
680 0 : } else if (state.dataUserDefinedComponents->UserPlantComp(CompLoop).Loop(ConnectionLoop).HowLoadServed ==
681 : DataPlant::HowMet::ByNominalCapHiOutLimit) {
682 : // actuator for hi out limit
683 0 : SetupEMSActuator(state,
684 0 : "Plant Connection " + LoopStr,
685 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Name,
686 : "High Outlet Temperature Limit",
687 : "[C]",
688 0 : state.dataUserDefinedComponents->lDummy_EMSActuatedPlantComp,
689 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Loop(ConnectionLoop).HiOutTempLimit);
690 : }
691 : }
692 :
693 : {
694 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Loop(ConnectionLoop).FlowPriority =
695 : static_cast<DataPlant::LoopFlowStatus>(
696 0 : getEnumValue(DataPlant::LoopFlowStatusTypeNamesUC, Util::makeUPPER(cAlphaArgs(aArgCount + 3))));
697 : }
698 :
699 : // find program manager for initial setup, begin environment and sizing of this plant connection
700 0 : if (!lAlphaFieldBlanks(aArgCount + 4)) {
701 0 : int StackMngrNum = Util::FindItemInList(cAlphaArgs(aArgCount + 4), state.dataRuntimeLang->EMSProgramCallManager);
702 0 : if (StackMngrNum > 0) { // found it
703 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Loop(ConnectionLoop).ErlInitProgramMngr = StackMngrNum;
704 : } else {
705 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Loop(ConnectionLoop).initPluginLocation =
706 0 : state.dataPluginManager->pluginManager->getLocationOfUserDefinedPlugin(state, cAlphaArgs(aArgCount + 4));
707 0 : if (state.dataUserDefinedComponents->UserPlantComp(CompLoop).Loop(ConnectionLoop).initPluginLocation == -1) {
708 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Loop(ConnectionLoop).initCallbackIndex =
709 0 : state.dataPluginManager->pluginManager->getUserDefinedCallbackIndex(state, cAlphaArgs(aArgCount + 4));
710 0 : if (state.dataUserDefinedComponents->UserPlantComp(CompLoop).Loop(ConnectionLoop).initCallbackIndex == -1) {
711 0 : ShowSevereError(state, format("Invalid {}={}", cAlphaFieldNames(aArgCount + 4), cAlphaArgs(aArgCount + 4)));
712 0 : ShowContinueError(state, format("Entered in {}={}", cCurrentModuleObject, cAlphaArgs(1)));
713 0 : ShowContinueError(state,
714 : "Program Manager Name not found as an EMS Program Manager, API callback, or a Python "
715 : "Plugin Instance object.");
716 0 : ErrorsFound = true;
717 : }
718 : }
719 : }
720 : }
721 :
722 : // find program to call for model simulations for just this plant connection
723 0 : if (!lAlphaFieldBlanks(aArgCount + 5)) {
724 0 : int StackMngrNum = Util::FindItemInList(cAlphaArgs(aArgCount + 5), state.dataRuntimeLang->EMSProgramCallManager);
725 0 : if (StackMngrNum > 0) { // found it
726 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Loop(ConnectionLoop).ErlSimProgramMngr = StackMngrNum;
727 : } else {
728 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Loop(ConnectionLoop).simPluginLocation =
729 0 : state.dataPluginManager->pluginManager->getLocationOfUserDefinedPlugin(state, cAlphaArgs(aArgCount + 5));
730 0 : if (state.dataUserDefinedComponents->UserPlantComp(CompLoop).Loop(ConnectionLoop).simPluginLocation == -1) {
731 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Loop(ConnectionLoop).simCallbackIndex =
732 0 : state.dataPluginManager->pluginManager->getUserDefinedCallbackIndex(state, cAlphaArgs(aArgCount + 5));
733 0 : if (state.dataUserDefinedComponents->UserPlantComp(CompLoop).Loop(ConnectionLoop).simCallbackIndex == -1) {
734 0 : ShowSevereError(state, format("Invalid {}={}", cAlphaFieldNames(aArgCount + 4), cAlphaArgs(aArgCount + 4)));
735 0 : ShowContinueError(state, format("Entered in {}={}", cCurrentModuleObject, cAlphaArgs(1)));
736 0 : ShowContinueError(state, "Program Manager Name not found as EMS Program, API callback, or Python Plugin.");
737 0 : ErrorsFound = true;
738 : }
739 : }
740 : }
741 : }
742 : // Setup Internal Variables
743 : // model input related internal variables
744 0 : SetupEMSInternalVariable(state,
745 0 : "Inlet Temperature for Plant Connection " + LoopStr,
746 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Name,
747 : "[C]",
748 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Loop(ConnectionLoop).InletTemp);
749 0 : SetupEMSInternalVariable(state,
750 0 : "Inlet Mass Flow Rate for Plant Connection " + LoopStr,
751 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Name,
752 : "[kg/s]",
753 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Loop(ConnectionLoop).InletMassFlowRate);
754 0 : if (state.dataUserDefinedComponents->UserPlantComp(CompLoop).Loop(ConnectionLoop).HowLoadServed !=
755 : DataPlant::HowMet::NoneDemand) {
756 0 : SetupEMSInternalVariable(state,
757 0 : "Load Request for Plant Connection " + LoopStr,
758 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Name,
759 : "[W]",
760 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Loop(ConnectionLoop).MyLoad);
761 : }
762 0 : SetupEMSInternalVariable(state,
763 0 : "Inlet Density for Plant Connection " + LoopStr,
764 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Name,
765 : "[kg/m3]",
766 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Loop(ConnectionLoop).InletRho);
767 0 : SetupEMSInternalVariable(state,
768 0 : "Inlet Specific Heat for Plant Connection " + LoopStr,
769 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Name,
770 : "[J/kg-C]",
771 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Loop(ConnectionLoop).InletCp);
772 : // model results related actuators
773 0 : SetupEMSActuator(state,
774 0 : "Plant Connection " + LoopStr,
775 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Name,
776 : "Outlet Temperature",
777 : "[C]",
778 0 : state.dataUserDefinedComponents->lDummy_EMSActuatedPlantComp,
779 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Loop(ConnectionLoop).OutletTemp);
780 0 : SetupEMSActuator(state,
781 0 : "Plant Connection " + LoopStr,
782 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Name,
783 : "Mass Flow Rate",
784 : "[kg/s]",
785 0 : state.dataUserDefinedComponents->lDummy_EMSActuatedPlantComp,
786 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Loop(ConnectionLoop).MassFlowRateRequest);
787 : // model initialization and sizing related actuators
788 0 : SetupEMSActuator(state,
789 0 : "Plant Connection " + LoopStr,
790 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Name,
791 : "Minimum Mass Flow Rate",
792 : "[kg/s]",
793 0 : state.dataUserDefinedComponents->lDummy_EMSActuatedPlantComp,
794 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Loop(ConnectionLoop).MassFlowRateMin);
795 0 : SetupEMSActuator(state,
796 0 : "Plant Connection " + LoopStr,
797 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Name,
798 : "Maximum Mass Flow Rate",
799 : "[kg/s]",
800 0 : state.dataUserDefinedComponents->lDummy_EMSActuatedPlantComp,
801 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Loop(ConnectionLoop).MassFlowRateMax);
802 0 : SetupEMSActuator(state,
803 0 : "Plant Connection " + LoopStr,
804 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Name,
805 : "Design Volume Flow Rate",
806 : "[m3/s]",
807 0 : state.dataUserDefinedComponents->lDummy_EMSActuatedPlantComp,
808 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Loop(ConnectionLoop).DesignVolumeFlowRate);
809 0 : SetupEMSActuator(state,
810 0 : "Plant Connection " + LoopStr,
811 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Name,
812 : "Minimum Loading Capacity",
813 : "[W]",
814 0 : state.dataUserDefinedComponents->lDummy_EMSActuatedPlantComp,
815 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Loop(ConnectionLoop).MinLoad);
816 0 : SetupEMSActuator(state,
817 0 : "Plant Connection " + LoopStr,
818 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Name,
819 : "Maximum Loading Capacity",
820 : "[W]",
821 0 : state.dataUserDefinedComponents->lDummy_EMSActuatedPlantComp,
822 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Loop(ConnectionLoop).MaxLoad);
823 0 : SetupEMSActuator(state,
824 0 : "Plant Connection " + LoopStr,
825 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Name,
826 : "Optimal Loading Capacity",
827 : "[W]",
828 0 : state.dataUserDefinedComponents->lDummy_EMSActuatedPlantComp,
829 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Loop(ConnectionLoop).OptLoad);
830 0 : }
831 : }
832 :
833 0 : if (!lAlphaFieldBlanks(27)) {
834 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Air.InletNodeNum =
835 0 : NodeInputManager::GetOnlySingleNode(state,
836 0 : cAlphaArgs(27),
837 : ErrorsFound,
838 : DataLoopNode::ConnectionObjectType::PlantComponentUserDefined,
839 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Name,
840 : DataLoopNode::NodeFluidType::Air,
841 : DataLoopNode::ConnectionType::OutsideAirReference,
842 : NodeInputManager::CompFluidStream::Primary,
843 : DataLoopNode::ObjectIsNotParent);
844 : // model input related internal variables
845 0 : SetupEMSInternalVariable(state,
846 : "Inlet Temperature for Air Connection",
847 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Name,
848 : "[C]",
849 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Air.InletTemp);
850 0 : SetupEMSInternalVariable(state,
851 : "Inlet Mass Flow Rate for Air Connection",
852 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Name,
853 : "[kg/s]",
854 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Air.InletMassFlowRate);
855 0 : SetupEMSInternalVariable(state,
856 : "Inlet Humidity Ratio for Air Connection",
857 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Name,
858 : "[kgWater/kgDryAir]",
859 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Air.InletHumRat);
860 0 : SetupEMSInternalVariable(state,
861 : "Inlet Density for Air Connection",
862 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Name,
863 : "[kg/m3]",
864 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Air.InletRho);
865 0 : SetupEMSInternalVariable(state,
866 : "Inlet Specific Heat for Air Connection",
867 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Name,
868 : "[J/kg-C]",
869 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Air.InletCp);
870 : }
871 :
872 0 : if (!lAlphaFieldBlanks(28)) {
873 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Air.OutletNodeNum =
874 0 : NodeInputManager::GetOnlySingleNode(state,
875 0 : cAlphaArgs(28),
876 : ErrorsFound,
877 : DataLoopNode::ConnectionObjectType::PlantComponentUserDefined,
878 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Name,
879 : DataLoopNode::NodeFluidType::Air,
880 : DataLoopNode::ConnectionType::ReliefAir,
881 : NodeInputManager::CompFluidStream::Primary,
882 : DataLoopNode::ObjectIsNotParent);
883 : // outlet air node results
884 0 : SetupEMSActuator(state,
885 : "Air Connection",
886 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Name,
887 : "Outlet Temperature",
888 : "[C]",
889 0 : state.dataUserDefinedComponents->lDummy_EMSActuatedPlantComp,
890 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Air.OutletTemp);
891 0 : SetupEMSActuator(state,
892 : "Air Connection",
893 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Name,
894 : "Outlet Humidity Ratio",
895 : "[kgWater/kgDryAir]",
896 0 : state.dataUserDefinedComponents->lDummy_EMSActuatedPlantComp,
897 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Air.OutletHumRat);
898 0 : SetupEMSActuator(state,
899 : "Air Connection",
900 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Name,
901 : "Mass Flow Rate",
902 : "[kg/s]",
903 0 : state.dataUserDefinedComponents->lDummy_EMSActuatedPlantComp,
904 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Air.OutletMassFlowRate);
905 : }
906 :
907 0 : if (!lAlphaFieldBlanks(29)) {
908 0 : WaterManager::SetupTankDemandComponent(state,
909 0 : cAlphaArgs(1),
910 : cCurrentModuleObject,
911 0 : cAlphaArgs(29),
912 : ErrorsFound,
913 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Water.SupplyTankID,
914 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Water.SupplyTankDemandARRID);
915 :
916 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Water.SuppliedByWaterSystem = true;
917 0 : SetupEMSActuator(state,
918 : "Water System",
919 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Name,
920 : "Supplied Volume Flow Rate",
921 : "[m3/s]",
922 0 : state.dataUserDefinedComponents->lDummy_EMSActuatedPlantComp,
923 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Water.SupplyVdotRequest);
924 : }
925 :
926 0 : if (!lAlphaFieldBlanks(30)) {
927 0 : WaterManager::SetupTankSupplyComponent(state,
928 0 : cAlphaArgs(1),
929 : cCurrentModuleObject,
930 0 : cAlphaArgs(30),
931 : ErrorsFound,
932 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Water.CollectionTankID,
933 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Water.CollectionTankSupplyARRID);
934 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Water.CollectsToWaterSystem = true;
935 0 : SetupEMSActuator(state,
936 : "Water System",
937 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Name,
938 : "Collected Volume Flow Rate",
939 : "[m3/s]",
940 0 : state.dataUserDefinedComponents->lDummy_EMSActuatedPlantComp,
941 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Water.CollectedVdot);
942 : }
943 :
944 0 : if (!lAlphaFieldBlanks(31)) {
945 :
946 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Zone.ZoneNum =
947 0 : Util::FindItemInList(cAlphaArgs(31), state.dataHeatBal->Zone);
948 0 : if (state.dataUserDefinedComponents->UserPlantComp(CompLoop).Zone.ZoneNum == 0) {
949 0 : ShowSevereError(state,
950 0 : format("{} = {}: Ambient Zone Name not found = {}", cCurrentModuleObject, cAlphaArgs(1), cAlphaArgs(31)));
951 0 : ErrorsFound = true;
952 : } else {
953 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Zone.DeviceHasInternalGains = true;
954 0 : SetupZoneInternalGain(state,
955 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Zone.ZoneNum,
956 0 : cAlphaArgs(1),
957 : DataHeatBalance::IntGainType::PlantComponentUserDefined,
958 0 : &state.dataUserDefinedComponents->UserPlantComp(CompLoop).Zone.ConvectionGainRate,
959 0 : &state.dataUserDefinedComponents->UserPlantComp(CompLoop).Zone.ReturnAirConvectionGainRate,
960 0 : &state.dataUserDefinedComponents->UserPlantComp(CompLoop).Zone.ThermalRadiationGainRate,
961 0 : &state.dataUserDefinedComponents->UserPlantComp(CompLoop).Zone.LatentGainRate,
962 0 : &state.dataUserDefinedComponents->UserPlantComp(CompLoop).Zone.ReturnAirLatentGainRate,
963 0 : &state.dataUserDefinedComponents->UserPlantComp(CompLoop).Zone.CarbonDioxideGainRate,
964 0 : &state.dataUserDefinedComponents->UserPlantComp(CompLoop).Zone.GenericContamGainRate);
965 :
966 0 : SetupEMSActuator(state,
967 : "Component Zone Internal Gain",
968 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Name,
969 : "Sensible Heat Gain Rate",
970 : "[W]",
971 0 : state.dataUserDefinedComponents->lDummy_EMSActuatedPlantComp,
972 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Zone.ConvectionGainRate);
973 0 : SetupEMSActuator(state,
974 : "Component Zone Internal Gain",
975 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Name,
976 : "Return Air Heat Sensible Gain Rate",
977 : "[W]",
978 0 : state.dataUserDefinedComponents->lDummy_EMSActuatedPlantComp,
979 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Zone.ReturnAirConvectionGainRate);
980 0 : SetupEMSActuator(state,
981 : "Component Zone Internal Gain",
982 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Name,
983 : "Thermal Radiation Heat Gain Rate",
984 : "[W]",
985 0 : state.dataUserDefinedComponents->lDummy_EMSActuatedPlantComp,
986 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Zone.ThermalRadiationGainRate);
987 0 : SetupEMSActuator(state,
988 : "Component Zone Internal Gain",
989 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Name,
990 : "Latent Heat Gain Rate",
991 : "[W]",
992 0 : state.dataUserDefinedComponents->lDummy_EMSActuatedPlantComp,
993 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Zone.LatentGainRate);
994 0 : SetupEMSActuator(state,
995 : "Component Zone Internal Gain",
996 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Name,
997 : "Return Air Latent Heat Gain Rate",
998 : "[W]",
999 0 : state.dataUserDefinedComponents->lDummy_EMSActuatedPlantComp,
1000 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Zone.ReturnAirLatentGainRate);
1001 0 : SetupEMSActuator(state,
1002 : "Component Zone Internal Gain",
1003 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Name,
1004 : "Carbon Dioxide Gain Rate",
1005 : "[W]",
1006 0 : state.dataUserDefinedComponents->lDummy_EMSActuatedPlantComp,
1007 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Zone.CarbonDioxideGainRate);
1008 0 : SetupEMSActuator(state,
1009 : "Component Zone Internal Gain",
1010 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Name,
1011 : "Gaseous Contaminant Gain Rate",
1012 : "[W]",
1013 0 : state.dataUserDefinedComponents->lDummy_EMSActuatedPlantComp,
1014 0 : state.dataUserDefinedComponents->UserPlantComp(CompLoop).Zone.GenericContamGainRate);
1015 : }
1016 : }
1017 :
1018 : // make sure user has entered at least some erl program managers to actually calculate something
1019 0 : int MgrCountTest = 0;
1020 0 : if (state.dataUserDefinedComponents->UserPlantComp(CompLoop).ErlSimProgramMngr > 0) {
1021 0 : MgrCountTest = 1;
1022 : }
1023 0 : for (int ConnectionLoop = 1; ConnectionLoop <= NumPlantConnections; ++ConnectionLoop) {
1024 0 : if (state.dataUserDefinedComponents->UserPlantComp(CompLoop).Loop(ConnectionLoop).ErlInitProgramMngr > 0) {
1025 0 : ++MgrCountTest;
1026 : }
1027 0 : if (state.dataUserDefinedComponents->UserPlantComp(CompLoop).Loop(ConnectionLoop).ErlSimProgramMngr > 0) {
1028 0 : ++MgrCountTest;
1029 : }
1030 0 : if (state.dataUserDefinedComponents->UserPlantComp(CompLoop).Loop(ConnectionLoop).initPluginLocation >= 0) {
1031 0 : ++MgrCountTest;
1032 : }
1033 0 : if (state.dataUserDefinedComponents->UserPlantComp(CompLoop).Loop(ConnectionLoop).simPluginLocation >= 0) {
1034 0 : ++MgrCountTest;
1035 : }
1036 0 : if (state.dataUserDefinedComponents->UserPlantComp(CompLoop).Loop(ConnectionLoop).initCallbackIndex >= 0) {
1037 0 : ++MgrCountTest;
1038 : }
1039 0 : if (state.dataUserDefinedComponents->UserPlantComp(CompLoop).Loop(ConnectionLoop).simCallbackIndex >= 0) {
1040 0 : ++MgrCountTest;
1041 : }
1042 : }
1043 0 : if (MgrCountTest == 0) {
1044 0 : ShowSevereError(state, format("Invalid {}={}", cCurrentModuleObject, cAlphaArgs(1)));
1045 0 : ShowContinueError(state, "At least one program calling manager is needed.");
1046 0 : ErrorsFound = true;
1047 : }
1048 : }
1049 : } // NumUserPlantComps > 0
1050 :
1051 2 : if (ErrorsFound) {
1052 0 : ShowFatalError(state, format("GetUserDefinedComponents: Errors found in processing {} input.", cCurrentModuleObject));
1053 : }
1054 :
1055 2 : cCurrentModuleObject = "Coil:UserDefined";
1056 2 : state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, cCurrentModuleObject, TotalArgs, NumAlphas, NumNums);
1057 :
1058 2 : cAlphaFieldNames.allocate(NumAlphas);
1059 2 : cAlphaArgs.allocate(NumAlphas);
1060 2 : lAlphaFieldBlanks.dimension(NumAlphas, false);
1061 2 : rNumericArgs.dimension(NumNums, 0.0);
1062 :
1063 2 : state.dataUserDefinedComponents->NumUserCoils = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject);
1064 :
1065 2 : if (state.dataUserDefinedComponents->NumUserCoils > 0) {
1066 1 : state.dataUserDefinedComponents->UserCoil.allocate(state.dataUserDefinedComponents->NumUserCoils);
1067 1 : state.dataUserDefinedComponents->CheckUserCoilName.dimension(state.dataUserDefinedComponents->NumUserCoils, true);
1068 2 : for (int CompLoop = 1; CompLoop <= state.dataUserDefinedComponents->NumUserCoils; ++CompLoop) {
1069 1 : state.dataInputProcessing->inputProcessor->getObjectItem(state,
1070 : cCurrentModuleObject,
1071 : CompLoop,
1072 : cAlphaArgs,
1073 : NumAlphas,
1074 : rNumericArgs,
1075 : NumNums,
1076 : IOStat,
1077 : _,
1078 : lAlphaFieldBlanks,
1079 : cAlphaFieldNames,
1080 : _);
1081 1 : Util::IsNameEmpty(state, cAlphaArgs(1), cCurrentModuleObject, ErrorsFound);
1082 :
1083 : // ErrorsFound will be set to True if problem was found, left untouched otherwise
1084 1 : GlobalNames::VerifyUniqueCoilName(state, cCurrentModuleObject, cAlphaArgs(1), ErrorsFound, cCurrentModuleObject + " Name");
1085 :
1086 1 : state.dataUserDefinedComponents->UserCoil(CompLoop).Name = cAlphaArgs(1);
1087 :
1088 : // now get program manager for model simulations
1089 1 : if (!lAlphaFieldBlanks(2)) {
1090 0 : int StackMngrNum = Util::FindItemInList(cAlphaArgs(2), state.dataRuntimeLang->EMSProgramCallManager);
1091 0 : if (StackMngrNum > 0) { // found it
1092 0 : state.dataUserDefinedComponents->UserCoil(CompLoop).ErlSimProgramMngr = StackMngrNum;
1093 : } else {
1094 0 : state.dataUserDefinedComponents->UserCoil(CompLoop).simPluginLocation =
1095 0 : state.dataPluginManager->pluginManager->getLocationOfUserDefinedPlugin(state, cAlphaArgs(2));
1096 0 : if (state.dataUserDefinedComponents->UserCoil(CompLoop).simPluginLocation == -1) {
1097 0 : state.dataUserDefinedComponents->UserCoil(CompLoop).simCallbackIndex =
1098 0 : state.dataPluginManager->pluginManager->getUserDefinedCallbackIndex(state, cAlphaArgs(2));
1099 0 : if (state.dataUserDefinedComponents->UserCoil(CompLoop).simCallbackIndex == -1) {
1100 0 : ShowSevereError(state, format("Invalid {}={}", cAlphaFieldNames(2), cAlphaArgs(2)));
1101 0 : ShowContinueError(state, format("Entered in {}={}", cCurrentModuleObject, cAlphaArgs(1)));
1102 0 : ShowContinueError(
1103 : state,
1104 : "Program Manager Name not found as an EMS Program Manager, API callback, or a Python Plugin Instance object.");
1105 0 : ErrorsFound = true;
1106 : }
1107 : }
1108 : }
1109 : }
1110 :
1111 : // now get program manager for model initializations
1112 1 : if (!lAlphaFieldBlanks(3)) {
1113 1 : int StackMngrNum = Util::FindItemInList(cAlphaArgs(3), state.dataRuntimeLang->EMSProgramCallManager);
1114 1 : if (StackMngrNum > 0) { // found it
1115 1 : state.dataUserDefinedComponents->UserCoil(CompLoop).ErlInitProgramMngr = StackMngrNum;
1116 : } else {
1117 0 : state.dataUserDefinedComponents->UserCoil(CompLoop).initPluginLocation =
1118 0 : state.dataPluginManager->pluginManager->getLocationOfUserDefinedPlugin(state, cAlphaArgs(3));
1119 0 : if (state.dataUserDefinedComponents->UserCoil(CompLoop).initPluginLocation == -1) {
1120 0 : state.dataUserDefinedComponents->UserCoil(CompLoop).initCallbackIndex =
1121 0 : state.dataPluginManager->pluginManager->getUserDefinedCallbackIndex(state, cAlphaArgs(3));
1122 0 : if (state.dataUserDefinedComponents->UserCoil(CompLoop).initCallbackIndex == -1) {
1123 0 : ShowSevereError(state, format("Invalid {}={}", cAlphaFieldNames(3), cAlphaArgs(3)));
1124 0 : ShowContinueError(state, format("Entered in {}={}", cCurrentModuleObject, cAlphaArgs(1)));
1125 0 : ShowContinueError(
1126 : state,
1127 : "Program Manager Name not found as an EMS Program Manager, API callback or a Python Plugin Instance object.");
1128 0 : ErrorsFound = true;
1129 : }
1130 : }
1131 : }
1132 : }
1133 :
1134 1 : int NumAirConnections = std::floor(rNumericArgs(1));
1135 1 : if ((NumAirConnections >= 1) && (NumAirConnections <= 2)) {
1136 1 : state.dataUserDefinedComponents->UserCoil(CompLoop).Air.allocate(NumAirConnections);
1137 1 : state.dataUserDefinedComponents->UserCoil(CompLoop).NumAirConnections = NumAirConnections;
1138 3 : for (int ConnectionLoop = 1; ConnectionLoop <= NumAirConnections; ++ConnectionLoop) {
1139 2 : int aArgCount = (ConnectionLoop - 1) * 2 + 4;
1140 2 : state.dataUserDefinedComponents->UserCoil(CompLoop).Air(ConnectionLoop).InletNodeNum =
1141 4 : NodeInputManager::GetOnlySingleNode(state,
1142 2 : cAlphaArgs(aArgCount),
1143 : ErrorsFound,
1144 : DataLoopNode::ConnectionObjectType::CoilUserDefined,
1145 2 : state.dataUserDefinedComponents->UserCoil(CompLoop).Name,
1146 : DataLoopNode::NodeFluidType::Air,
1147 : DataLoopNode::ConnectionType::Inlet,
1148 : static_cast<NodeInputManager::CompFluidStream>(ConnectionLoop),
1149 : DataLoopNode::ObjectIsNotParent);
1150 :
1151 2 : const std::string LoopStr = fmt::to_string(ConnectionLoop);
1152 : // model input related internal variables
1153 2 : SetupEMSInternalVariable(state,
1154 4 : "Inlet Temperature for Air Connection " + LoopStr,
1155 2 : state.dataUserDefinedComponents->UserCoil(CompLoop).Name,
1156 : "[C]",
1157 2 : state.dataUserDefinedComponents->UserCoil(CompLoop).Air(ConnectionLoop).InletTemp);
1158 2 : SetupEMSInternalVariable(state,
1159 4 : "Inlet Mass Flow Rate for Air Connection " + LoopStr,
1160 2 : state.dataUserDefinedComponents->UserCoil(CompLoop).Name,
1161 : "[kg/s]",
1162 2 : state.dataUserDefinedComponents->UserCoil(CompLoop).Air(ConnectionLoop).InletMassFlowRate);
1163 2 : SetupEMSInternalVariable(state,
1164 4 : "Inlet Humidity Ratio for Air Connection " + LoopStr,
1165 2 : state.dataUserDefinedComponents->UserCoil(CompLoop).Name,
1166 : "[kgWater/kgDryAir]",
1167 2 : state.dataUserDefinedComponents->UserCoil(CompLoop).Air(ConnectionLoop).InletHumRat);
1168 2 : SetupEMSInternalVariable(state,
1169 4 : "Inlet Density for Air Connection " + LoopStr,
1170 2 : state.dataUserDefinedComponents->UserCoil(CompLoop).Name,
1171 : "[kg/m3]",
1172 2 : state.dataUserDefinedComponents->UserCoil(CompLoop).Air(ConnectionLoop).InletRho);
1173 2 : SetupEMSInternalVariable(state,
1174 4 : "Inlet Specific Heat for Air Connection " + LoopStr,
1175 2 : state.dataUserDefinedComponents->UserCoil(CompLoop).Name,
1176 : "[J/kg-C]",
1177 2 : state.dataUserDefinedComponents->UserCoil(CompLoop).Air(ConnectionLoop).InletCp);
1178 :
1179 2 : state.dataUserDefinedComponents->UserCoil(CompLoop).Air(ConnectionLoop).OutletNodeNum =
1180 4 : NodeInputManager::GetOnlySingleNode(state,
1181 2 : cAlphaArgs(aArgCount + 1),
1182 : ErrorsFound,
1183 : DataLoopNode::ConnectionObjectType::CoilUserDefined,
1184 2 : state.dataUserDefinedComponents->UserCoil(CompLoop).Name,
1185 : DataLoopNode::NodeFluidType::Air,
1186 : DataLoopNode::ConnectionType::Outlet,
1187 : static_cast<NodeInputManager::CompFluidStream>(ConnectionLoop),
1188 : DataLoopNode::ObjectIsNotParent);
1189 4 : SetupEMSActuator(state,
1190 4 : "Air Connection " + LoopStr,
1191 2 : state.dataUserDefinedComponents->UserCoil(CompLoop).Name,
1192 : "Outlet Temperature",
1193 : "[C]",
1194 2 : state.dataUserDefinedComponents->lDummy_EMSActuatedPlantComp,
1195 2 : state.dataUserDefinedComponents->UserCoil(CompLoop).Air(ConnectionLoop).OutletTemp);
1196 4 : SetupEMSActuator(state,
1197 4 : "Air Connection " + LoopStr,
1198 2 : state.dataUserDefinedComponents->UserCoil(CompLoop).Name,
1199 : "Outlet Humidity Ratio",
1200 : "[kgWater/kgDryAir]",
1201 2 : state.dataUserDefinedComponents->lDummy_EMSActuatedPlantComp,
1202 2 : state.dataUserDefinedComponents->UserCoil(CompLoop).Air(ConnectionLoop).OutletHumRat);
1203 4 : SetupEMSActuator(state,
1204 4 : "Air Connection " + LoopStr,
1205 2 : state.dataUserDefinedComponents->UserCoil(CompLoop).Name,
1206 : "Mass Flow Rate",
1207 : "[kg/s]",
1208 2 : state.dataUserDefinedComponents->lDummy_EMSActuatedPlantComp,
1209 2 : state.dataUserDefinedComponents->UserCoil(CompLoop).Air(ConnectionLoop).OutletMassFlowRate);
1210 :
1211 2 : BranchNodeConnections::TestCompSet(
1212 4 : state, cCurrentModuleObject, cAlphaArgs(1), cAlphaArgs(aArgCount), cAlphaArgs(aArgCount + 1), "Air Nodes " + LoopStr);
1213 2 : }
1214 :
1215 1 : if (!lAlphaFieldBlanks(8)) {
1216 1 : if (cAlphaArgs(8) == "YES") {
1217 0 : state.dataUserDefinedComponents->UserCoil(CompLoop).PlantIsConnected = true;
1218 1 : } else if (cAlphaArgs(8) == "NO") {
1219 1 : state.dataUserDefinedComponents->UserCoil(CompLoop).PlantIsConnected = false;
1220 : }
1221 : } else {
1222 0 : state.dataUserDefinedComponents->UserCoil(CompLoop).PlantIsConnected = false;
1223 : }
1224 :
1225 1 : if (state.dataUserDefinedComponents->UserCoil(CompLoop).PlantIsConnected) { // get input
1226 0 : state.dataUserDefinedComponents->UserCoil(CompLoop).Loop.InletNodeNum =
1227 0 : NodeInputManager::GetOnlySingleNode(state,
1228 0 : cAlphaArgs(9),
1229 : ErrorsFound,
1230 : DataLoopNode::ConnectionObjectType::CoilUserDefined,
1231 0 : cAlphaArgs(1),
1232 : DataLoopNode::NodeFluidType::Water,
1233 : DataLoopNode::ConnectionType::Inlet,
1234 : NodeInputManager::CompFluidStream::Tertiary,
1235 : DataLoopNode::ObjectIsNotParent);
1236 0 : state.dataUserDefinedComponents->UserCoil(CompLoop).Loop.OutletNodeNum =
1237 0 : NodeInputManager::GetOnlySingleNode(state,
1238 0 : cAlphaArgs(10),
1239 : ErrorsFound,
1240 : DataLoopNode::ConnectionObjectType::CoilUserDefined,
1241 0 : cAlphaArgs(1),
1242 : DataLoopNode::NodeFluidType::Water,
1243 : DataLoopNode::ConnectionType::Outlet,
1244 : NodeInputManager::CompFluidStream::Tertiary,
1245 : DataLoopNode::ObjectIsNotParent);
1246 :
1247 0 : BranchNodeConnections::TestCompSet(state, cCurrentModuleObject, cAlphaArgs(1), cAlphaArgs(9), cAlphaArgs(10), "Plant Nodes");
1248 :
1249 : // this model is only for plant connections that are "Demand"
1250 0 : state.dataUserDefinedComponents->UserCoil(CompLoop).Loop.HowLoadServed = DataPlant::HowMet::NoneDemand;
1251 : // this model is only for plant connections that are needy and turn loop on
1252 0 : state.dataUserDefinedComponents->UserCoil(CompLoop).Loop.FlowPriority = DataPlant::LoopFlowStatus::NeedyAndTurnsLoopOn;
1253 :
1254 : // Setup Internal Variables
1255 : // model input related internal variables
1256 0 : SetupEMSInternalVariable(state,
1257 : "Inlet Temperature for Plant Connection",
1258 0 : state.dataUserDefinedComponents->UserCoil(CompLoop).Name,
1259 : "[C]",
1260 0 : state.dataUserDefinedComponents->UserCoil(CompLoop).Loop.InletTemp);
1261 0 : SetupEMSInternalVariable(state,
1262 : "Inlet Mass Flow Rate for Plant Connection",
1263 0 : state.dataUserDefinedComponents->UserCoil(CompLoop).Name,
1264 : "[kg/s]",
1265 0 : state.dataUserDefinedComponents->UserCoil(CompLoop).Loop.InletMassFlowRate);
1266 0 : SetupEMSInternalVariable(state,
1267 : "Inlet Density for Plant Connection",
1268 0 : state.dataUserDefinedComponents->UserCoil(CompLoop).Name,
1269 : "[kg/m3]",
1270 0 : state.dataUserDefinedComponents->UserCoil(CompLoop).Loop.InletRho);
1271 0 : SetupEMSInternalVariable(state,
1272 : "Inlet Specific Heat for Plant Connection",
1273 0 : state.dataUserDefinedComponents->UserCoil(CompLoop).Name,
1274 : "[J/kg-C]",
1275 0 : state.dataUserDefinedComponents->UserCoil(CompLoop).Loop.InletCp);
1276 : // model results related actuators
1277 0 : SetupEMSActuator(state,
1278 : "Plant Connection",
1279 0 : state.dataUserDefinedComponents->UserCoil(CompLoop).Name,
1280 : "Outlet Temperature",
1281 : "[C]",
1282 0 : state.dataUserDefinedComponents->lDummy_EMSActuatedPlantComp,
1283 0 : state.dataUserDefinedComponents->UserCoil(CompLoop).Loop.OutletTemp);
1284 0 : SetupEMSActuator(state,
1285 : "Plant Connection",
1286 0 : state.dataUserDefinedComponents->UserCoil(CompLoop).Name,
1287 : "Mass Flow Rate",
1288 : "[kg/s]",
1289 0 : state.dataUserDefinedComponents->lDummy_EMSActuatedPlantComp,
1290 0 : state.dataUserDefinedComponents->UserCoil(CompLoop).Loop.MassFlowRateRequest);
1291 : // model initialization and sizing related actuators
1292 0 : SetupEMSActuator(state,
1293 : "Plant Connection",
1294 0 : state.dataUserDefinedComponents->UserCoil(CompLoop).Name,
1295 : "Design Volume Flow Rate",
1296 : "[m3/s]",
1297 0 : state.dataUserDefinedComponents->lDummy_EMSActuatedPlantComp,
1298 0 : state.dataUserDefinedComponents->UserCoil(CompLoop).Loop.DesignVolumeFlowRate);
1299 :
1300 0 : SetupEMSActuator(state,
1301 : "Plant Connection",
1302 0 : state.dataUserDefinedComponents->UserCoil(CompLoop).Name,
1303 : "Minimum Mass Flow Rate",
1304 : "[kg/s]",
1305 0 : state.dataUserDefinedComponents->lDummy_EMSActuatedPlantComp,
1306 0 : state.dataUserDefinedComponents->UserCoil(CompLoop).Loop.MassFlowRateMin);
1307 0 : SetupEMSActuator(state,
1308 : "Plant Connection",
1309 0 : state.dataUserDefinedComponents->UserCoil(CompLoop).Name,
1310 : "Maximum Mass Flow Rate",
1311 : "[kg/s]",
1312 0 : state.dataUserDefinedComponents->lDummy_EMSActuatedPlantComp,
1313 0 : state.dataUserDefinedComponents->UserCoil(CompLoop).Loop.MassFlowRateMax);
1314 : }
1315 :
1316 1 : if (!lAlphaFieldBlanks(11)) {
1317 0 : WaterManager::SetupTankDemandComponent(state,
1318 0 : cAlphaArgs(1),
1319 : cCurrentModuleObject,
1320 0 : cAlphaArgs(11),
1321 : ErrorsFound,
1322 0 : state.dataUserDefinedComponents->UserCoil(CompLoop).Water.SupplyTankID,
1323 0 : state.dataUserDefinedComponents->UserCoil(CompLoop).Water.SupplyTankDemandARRID);
1324 :
1325 0 : state.dataUserDefinedComponents->UserCoil(CompLoop).Water.SuppliedByWaterSystem = true;
1326 0 : SetupEMSActuator(state,
1327 : "Water System",
1328 0 : state.dataUserDefinedComponents->UserCoil(CompLoop).Name,
1329 : "Supplied Volume Flow Rate",
1330 : "[m3/s]",
1331 0 : state.dataUserDefinedComponents->lDummy_EMSActuatedPlantComp,
1332 0 : state.dataUserDefinedComponents->UserCoil(CompLoop).Water.SupplyVdotRequest);
1333 : }
1334 :
1335 1 : if (!lAlphaFieldBlanks(12)) {
1336 0 : WaterManager::SetupTankSupplyComponent(state,
1337 0 : cAlphaArgs(1),
1338 : cCurrentModuleObject,
1339 0 : cAlphaArgs(12),
1340 : ErrorsFound,
1341 0 : state.dataUserDefinedComponents->UserCoil(CompLoop).Water.CollectionTankID,
1342 0 : state.dataUserDefinedComponents->UserCoil(CompLoop).Water.CollectionTankSupplyARRID);
1343 0 : state.dataUserDefinedComponents->UserCoil(CompLoop).Water.CollectsToWaterSystem = true;
1344 0 : SetupEMSActuator(state,
1345 : "Water System",
1346 0 : state.dataUserDefinedComponents->UserCoil(CompLoop).Name,
1347 : "Collected Volume Flow Rate",
1348 : "[m3/s]",
1349 0 : state.dataUserDefinedComponents->lDummy_EMSActuatedPlantComp,
1350 0 : state.dataUserDefinedComponents->UserCoil(CompLoop).Water.CollectedVdot);
1351 : }
1352 :
1353 1 : if (!lAlphaFieldBlanks(13)) {
1354 :
1355 0 : state.dataUserDefinedComponents->UserCoil(CompLoop).Zone.ZoneNum =
1356 0 : Util::FindItemInList(cAlphaArgs(13), state.dataHeatBal->Zone);
1357 0 : if (state.dataUserDefinedComponents->UserCoil(CompLoop).Zone.ZoneNum == 0) {
1358 0 : ShowSevereError(
1359 0 : state, format("{} = {}: Ambient Zone Name not found = {}", cCurrentModuleObject, cAlphaArgs(1), cAlphaArgs(13)));
1360 0 : ErrorsFound = true;
1361 : } else {
1362 0 : state.dataUserDefinedComponents->UserCoil(CompLoop).Zone.DeviceHasInternalGains = true;
1363 0 : SetupZoneInternalGain(state,
1364 0 : state.dataUserDefinedComponents->UserCoil(CompLoop).Zone.ZoneNum,
1365 0 : cAlphaArgs(1),
1366 : DataHeatBalance::IntGainType::CoilUserDefined,
1367 0 : &state.dataUserDefinedComponents->UserCoil(CompLoop).Zone.ConvectionGainRate,
1368 0 : &state.dataUserDefinedComponents->UserCoil(CompLoop).Zone.ReturnAirConvectionGainRate,
1369 0 : &state.dataUserDefinedComponents->UserCoil(CompLoop).Zone.ThermalRadiationGainRate,
1370 0 : &state.dataUserDefinedComponents->UserCoil(CompLoop).Zone.LatentGainRate,
1371 0 : &state.dataUserDefinedComponents->UserCoil(CompLoop).Zone.ReturnAirLatentGainRate,
1372 0 : &state.dataUserDefinedComponents->UserCoil(CompLoop).Zone.CarbonDioxideGainRate,
1373 0 : &state.dataUserDefinedComponents->UserCoil(CompLoop).Zone.GenericContamGainRate);
1374 :
1375 0 : SetupEMSActuator(state,
1376 : "Component Zone Internal Gain",
1377 0 : state.dataUserDefinedComponents->UserCoil(CompLoop).Name,
1378 : "Sensible Heat Gain Rate",
1379 : "[W]",
1380 0 : state.dataUserDefinedComponents->lDummy_EMSActuatedPlantComp,
1381 0 : state.dataUserDefinedComponents->UserCoil(CompLoop).Zone.ConvectionGainRate);
1382 0 : SetupEMSActuator(state,
1383 : "Component Zone Internal Gain",
1384 0 : state.dataUserDefinedComponents->UserCoil(CompLoop).Name,
1385 : "Return Air Heat Sensible Gain Rate",
1386 : "[W]",
1387 0 : state.dataUserDefinedComponents->lDummy_EMSActuatedPlantComp,
1388 0 : state.dataUserDefinedComponents->UserCoil(CompLoop).Zone.ReturnAirConvectionGainRate);
1389 0 : SetupEMSActuator(state,
1390 : "Component Zone Internal Gain",
1391 0 : state.dataUserDefinedComponents->UserCoil(CompLoop).Name,
1392 : "Thermal Radiation Heat Gain Rate",
1393 : "[W]",
1394 0 : state.dataUserDefinedComponents->lDummy_EMSActuatedPlantComp,
1395 0 : state.dataUserDefinedComponents->UserCoil(CompLoop).Zone.ThermalRadiationGainRate);
1396 0 : SetupEMSActuator(state,
1397 : "Component Zone Internal Gain",
1398 0 : state.dataUserDefinedComponents->UserCoil(CompLoop).Name,
1399 : "Latent Heat Gain Rate",
1400 : "[W]",
1401 0 : state.dataUserDefinedComponents->lDummy_EMSActuatedPlantComp,
1402 0 : state.dataUserDefinedComponents->UserCoil(CompLoop).Zone.LatentGainRate);
1403 0 : SetupEMSActuator(state,
1404 : "Component Zone Internal Gain",
1405 0 : state.dataUserDefinedComponents->UserCoil(CompLoop).Name,
1406 : "Return Air Latent Heat Gain Rate",
1407 : "[W]",
1408 0 : state.dataUserDefinedComponents->lDummy_EMSActuatedPlantComp,
1409 0 : state.dataUserDefinedComponents->UserCoil(CompLoop).Zone.ReturnAirLatentGainRate);
1410 0 : SetupEMSActuator(state,
1411 : "Component Zone Internal Gain",
1412 0 : state.dataUserDefinedComponents->UserCoil(CompLoop).Name,
1413 : "Carbon Dioxide Gain Rate",
1414 : "[W]",
1415 0 : state.dataUserDefinedComponents->lDummy_EMSActuatedPlantComp,
1416 0 : state.dataUserDefinedComponents->UserCoil(CompLoop).Zone.CarbonDioxideGainRate);
1417 0 : SetupEMSActuator(state,
1418 : "Component Zone Internal Gain",
1419 0 : state.dataUserDefinedComponents->UserCoil(CompLoop).Name,
1420 : "Gaseous Contaminant Gain Rate",
1421 : "[W]",
1422 0 : state.dataUserDefinedComponents->lDummy_EMSActuatedPlantComp,
1423 0 : state.dataUserDefinedComponents->UserCoil(CompLoop).Zone.GenericContamGainRate);
1424 : }
1425 : }
1426 : }
1427 : }
1428 :
1429 : } // NumUserCoils > 0
1430 :
1431 2 : if (ErrorsFound) {
1432 0 : ShowFatalError(state, format("GetUserDefinedComponents: Errors found in processing {} input.", cCurrentModuleObject));
1433 : }
1434 2 : }
1435 :
1436 1 : void GetUserDefinedComponents(EnergyPlusData &state)
1437 : {
1438 :
1439 : // SUBROUTINE INFORMATION:
1440 : // AUTHOR B. Griffith
1441 : // DATE WRITTEN Jan 2012
1442 : // MODIFIED na
1443 : // RE-ENGINEERED na
1444 :
1445 1 : bool ErrorsFound(false);
1446 : int NumAlphas; // Number of elements in the alpha array
1447 : int NumNums; // Number of elements in the numeric array
1448 : int IOStat; // IO Status when calling get input subroutine
1449 : int TotalArgs; // argument for call to GetObjectDefMaxArgs
1450 1 : Array1D_string cAlphaFieldNames;
1451 1 : Array1D_bool lAlphaFieldBlanks;
1452 1 : Array1D_string cAlphaArgs;
1453 1 : Array1D<Real64> rNumericArgs;
1454 1 : std::string cCurrentModuleObject;
1455 :
1456 1 : if (state.dataUserDefinedComponents->GetPlantCompInput) {
1457 1 : GetUserDefinedPlantComponents(state);
1458 1 : state.dataUserDefinedComponents->GetPlantCompInput = false;
1459 : }
1460 :
1461 1 : cCurrentModuleObject = "ZoneHVAC:ForcedAir:UserDefined";
1462 1 : state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, cCurrentModuleObject, TotalArgs, NumAlphas, NumNums);
1463 :
1464 1 : cAlphaFieldNames.allocate(NumAlphas);
1465 1 : cAlphaArgs.allocate(NumAlphas);
1466 1 : lAlphaFieldBlanks.dimension(NumAlphas, false);
1467 1 : rNumericArgs.dimension(NumNums, 0.0);
1468 :
1469 1 : state.dataUserDefinedComponents->NumUserZoneAir = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject);
1470 1 : if (state.dataUserDefinedComponents->NumUserZoneAir > 0) {
1471 1 : state.dataUserDefinedComponents->UserZoneAirHVAC.allocate(state.dataUserDefinedComponents->NumUserZoneAir);
1472 1 : state.dataUserDefinedComponents->CheckUserZoneAirName.dimension(state.dataUserDefinedComponents->NumUserZoneAir, true);
1473 4 : for (int CompLoop = 1; CompLoop <= state.dataUserDefinedComponents->NumUserZoneAir; ++CompLoop) {
1474 3 : state.dataInputProcessing->inputProcessor->getObjectItem(state,
1475 : cCurrentModuleObject,
1476 : CompLoop,
1477 : cAlphaArgs,
1478 : NumAlphas,
1479 : rNumericArgs,
1480 : NumNums,
1481 : IOStat,
1482 : _,
1483 : lAlphaFieldBlanks,
1484 : cAlphaFieldNames,
1485 : _);
1486 3 : Util::IsNameEmpty(state, cAlphaArgs(1), cCurrentModuleObject, ErrorsFound);
1487 3 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Name = cAlphaArgs(1);
1488 :
1489 : // now get program manager for model simulations
1490 3 : if (!lAlphaFieldBlanks(2)) {
1491 3 : int StackMngrNum = Util::FindItemInList(cAlphaArgs(2), state.dataRuntimeLang->EMSProgramCallManager);
1492 3 : if (StackMngrNum > 0) { // found it
1493 2 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).ErlSimProgramMngr = StackMngrNum;
1494 : } else {
1495 1 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).simPluginLocation =
1496 1 : state.dataPluginManager->pluginManager->getLocationOfUserDefinedPlugin(state, cAlphaArgs(2));
1497 1 : if (state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).simPluginLocation == -1) {
1498 1 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).simCallbackIndex =
1499 1 : state.dataPluginManager->pluginManager->getUserDefinedCallbackIndex(state, cAlphaArgs(2));
1500 1 : if (state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).simCallbackIndex == -1) {
1501 0 : ShowSevereError(state, format("Invalid {}={}", cAlphaFieldNames(2), cAlphaArgs(2)));
1502 0 : ShowContinueError(state, format("Entered in {}={}", cCurrentModuleObject, cAlphaArgs(1)));
1503 0 : ShowContinueError(
1504 : state,
1505 : "Program Manager Name not found as an EMS Program Manager, API callback or a Python Plugin Instance object.");
1506 0 : ErrorsFound = true;
1507 : }
1508 : }
1509 : }
1510 : }
1511 :
1512 : // now get program manager for model initializations
1513 3 : if (!lAlphaFieldBlanks(3)) {
1514 2 : int StackMngrNum = Util::FindItemInList(cAlphaArgs(3), state.dataRuntimeLang->EMSProgramCallManager);
1515 2 : if (StackMngrNum > 0) { // found it
1516 2 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).ErlInitProgramMngr = StackMngrNum;
1517 : } else {
1518 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).initPluginLocation =
1519 0 : state.dataPluginManager->pluginManager->getLocationOfUserDefinedPlugin(state, cAlphaArgs(3));
1520 0 : if (state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).initPluginLocation == -1) {
1521 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).initCallbackIndex =
1522 0 : state.dataPluginManager->pluginManager->getUserDefinedCallbackIndex(state, cAlphaArgs(3));
1523 0 : if (state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).initCallbackIndex == -1) {
1524 0 : ShowSevereError(state, format("Invalid {}={}", cAlphaFieldNames(3), cAlphaArgs(3)));
1525 0 : ShowContinueError(state, format("Entered in {}={}", cCurrentModuleObject, cAlphaArgs(1)));
1526 0 : ShowContinueError(
1527 : state,
1528 : "Program Manager Name not found as an EMS Program Manager, API callback or a Python Plugin Instance object.");
1529 0 : ErrorsFound = true;
1530 : }
1531 : }
1532 : }
1533 : }
1534 :
1535 3 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).ZoneAir.InletNodeNum =
1536 6 : NodeInputManager::GetOnlySingleNode(state,
1537 3 : cAlphaArgs(4),
1538 : ErrorsFound,
1539 : DataLoopNode::ConnectionObjectType::ZoneHVACForcedAirUserDefined,
1540 3 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Name,
1541 : DataLoopNode::NodeFluidType::Air,
1542 : DataLoopNode::ConnectionType::Inlet,
1543 : NodeInputManager::CompFluidStream::Primary,
1544 : DataLoopNode::ObjectIsNotParent);
1545 : // model input related internal variables
1546 3 : SetupEMSInternalVariable(state,
1547 : "Inlet Temperature for Primary Air Connection",
1548 3 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Name,
1549 : "[C]",
1550 3 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).ZoneAir.InletTemp);
1551 3 : SetupEMSInternalVariable(state,
1552 : "Inlet Humidity Ratio for Primary Air Connection",
1553 3 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Name,
1554 : "[kgWater/kgDryAir]",
1555 3 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).ZoneAir.InletHumRat);
1556 3 : SetupEMSInternalVariable(state,
1557 : "Inlet Density for Primary Air Connection",
1558 3 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Name,
1559 : "[kg/m3]",
1560 3 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).ZoneAir.InletRho);
1561 3 : SetupEMSInternalVariable(state,
1562 : "Inlet Specific Heat for Primary Air Connection",
1563 3 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Name,
1564 : "[J/kg-C]",
1565 3 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).ZoneAir.InletCp);
1566 :
1567 3 : SetupEMSInternalVariable(state,
1568 : "Remaining Sensible Load to Heating Setpoint",
1569 3 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Name,
1570 : "[W]",
1571 3 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).RemainingOutputToHeatingSP);
1572 3 : SetupEMSInternalVariable(state,
1573 : "Remaining Sensible Load to Cooling Setpoint",
1574 3 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Name,
1575 : "[W]",
1576 3 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).RemainingOutputToCoolingSP);
1577 3 : SetupEMSInternalVariable(state,
1578 : "Remaining Latent Load to Humidifying Setpoint",
1579 3 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Name,
1580 : "[kg/s]",
1581 3 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).RemainingOutputReqToHumidSP);
1582 3 : SetupEMSInternalVariable(state,
1583 : "Remaining Latent Load to Dehumidifying Setpoint",
1584 3 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Name,
1585 : "[kg/s]",
1586 3 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).RemainingOutputReqToDehumidSP);
1587 :
1588 6 : SetupEMSActuator(state,
1589 : "Primary Air Connection",
1590 3 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Name,
1591 : "Inlet Mass Flow Rate",
1592 : "[kg/s]",
1593 3 : state.dataUserDefinedComponents->lDummy_GetUserDefComp,
1594 3 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).ZoneAir.InletMassFlowRate);
1595 3 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).ZoneAir.OutletNodeNum =
1596 6 : NodeInputManager::GetOnlySingleNode(state,
1597 3 : cAlphaArgs(5),
1598 : ErrorsFound,
1599 : DataLoopNode::ConnectionObjectType::ZoneHVACForcedAirUserDefined,
1600 3 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Name,
1601 : DataLoopNode::NodeFluidType::Air,
1602 : DataLoopNode::ConnectionType::Outlet,
1603 : NodeInputManager::CompFluidStream::Primary,
1604 : DataLoopNode::ObjectIsNotParent);
1605 6 : SetupEMSActuator(state,
1606 : "Primary Air Connection",
1607 3 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Name,
1608 : "Outlet Temperature",
1609 : "[C]",
1610 3 : state.dataUserDefinedComponents->lDummy_GetUserDefComp,
1611 3 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).ZoneAir.OutletTemp);
1612 6 : SetupEMSActuator(state,
1613 : "Primary Air Connection",
1614 3 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Name,
1615 : "Outlet Humidity Ratio",
1616 : "[kgWater/kgDryAir]",
1617 3 : state.dataUserDefinedComponents->lDummy_GetUserDefComp,
1618 3 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).ZoneAir.OutletHumRat);
1619 6 : SetupEMSActuator(state,
1620 : "Primary Air Connection",
1621 3 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Name,
1622 : "Outlet Mass Flow Rate",
1623 : "[kg/s]",
1624 3 : state.dataUserDefinedComponents->lDummy_GetUserDefComp,
1625 3 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).ZoneAir.OutletMassFlowRate);
1626 :
1627 3 : if (!lAlphaFieldBlanks(6)) {
1628 3 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).SourceAir.InletNodeNum =
1629 6 : NodeInputManager::GetOnlySingleNode(state,
1630 3 : cAlphaArgs(6),
1631 : ErrorsFound,
1632 : DataLoopNode::ConnectionObjectType::ZoneHVACForcedAirUserDefined,
1633 3 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Name,
1634 : DataLoopNode::NodeFluidType::Air,
1635 : DataLoopNode::ConnectionType::Inlet,
1636 : NodeInputManager::CompFluidStream::Secondary,
1637 : DataLoopNode::ObjectIsNotParent);
1638 : // model input related internal variables
1639 3 : SetupEMSInternalVariable(state,
1640 : "Inlet Temperature for Secondary Air Connection",
1641 3 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Name,
1642 : "[C]",
1643 3 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).SourceAir.InletTemp);
1644 :
1645 3 : SetupEMSInternalVariable(state,
1646 : "Inlet Humidity Ratio for Secondary Air Connection",
1647 3 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Name,
1648 : "[kgWater/kgDryAir]",
1649 3 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).SourceAir.InletHumRat);
1650 3 : SetupEMSInternalVariable(state,
1651 : "Inlet Density for Secondary Air Connection",
1652 3 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Name,
1653 : "[kg/m3]",
1654 3 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).SourceAir.InletRho);
1655 3 : SetupEMSInternalVariable(state,
1656 : "Inlet Specific Heat for Secondary Air Connection",
1657 3 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Name,
1658 : "[J/kg-C]",
1659 3 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).SourceAir.InletCp);
1660 6 : SetupEMSActuator(state,
1661 : "Secondary Air Connection",
1662 3 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Name,
1663 : "Inlet Mass Flow Rate",
1664 : "[kg/s]",
1665 3 : state.dataUserDefinedComponents->lDummy_GetUserDefComp,
1666 3 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).SourceAir.InletMassFlowRate);
1667 : }
1668 :
1669 3 : if (!lAlphaFieldBlanks(7)) {
1670 3 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).SourceAir.OutletNodeNum =
1671 6 : NodeInputManager::GetOnlySingleNode(state,
1672 3 : cAlphaArgs(7),
1673 : ErrorsFound,
1674 : DataLoopNode::ConnectionObjectType::ZoneHVACForcedAirUserDefined,
1675 3 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Name,
1676 : DataLoopNode::NodeFluidType::Air,
1677 : DataLoopNode::ConnectionType::Outlet,
1678 : NodeInputManager::CompFluidStream::Secondary,
1679 : DataLoopNode::ObjectIsNotParent);
1680 6 : SetupEMSActuator(state,
1681 : "Secondary Air Connection",
1682 3 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Name,
1683 : "Outlet Temperature",
1684 : "[C]",
1685 3 : state.dataUserDefinedComponents->lDummy_GetUserDefComp,
1686 3 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).SourceAir.OutletTemp);
1687 6 : SetupEMSActuator(state,
1688 : "Secondary Air Connection",
1689 3 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Name,
1690 : "Outlet Humidity Ratio",
1691 : "[kgWater/kgDryAir]",
1692 3 : state.dataUserDefinedComponents->lDummy_GetUserDefComp,
1693 3 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).SourceAir.OutletHumRat);
1694 6 : SetupEMSActuator(state,
1695 : "Secondary Air Connection",
1696 3 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Name,
1697 : "Mass Flow Rate",
1698 : "[kg/s]",
1699 3 : state.dataUserDefinedComponents->lDummy_GetUserDefComp,
1700 3 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).SourceAir.OutletMassFlowRate);
1701 : }
1702 :
1703 6 : if ((state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).SourceAir.InletNodeNum > 0) &&
1704 3 : (state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).SourceAir.OutletNodeNum > 0)) {
1705 : // CALL TestCompSet(state, TRIM(cCurrentModuleObject),cAlphaArgs(1),cAlphaArgs(6),cAlphaArgs(7),'Air Nodes')
1706 : }
1707 :
1708 3 : int NumPlantConnections = std::floor(rNumericArgs(1));
1709 3 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).NumPlantConnections = NumPlantConnections;
1710 3 : if ((NumPlantConnections >= 1) && (NumPlantConnections <= 3)) {
1711 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Loop.allocate(NumPlantConnections);
1712 0 : for (int ConnectionLoop = 1; ConnectionLoop <= NumPlantConnections; ++ConnectionLoop) {
1713 0 : int aArgCount = (ConnectionLoop - 1) * 2 + 8;
1714 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Loop(ConnectionLoop).InletNodeNum =
1715 0 : NodeInputManager::GetOnlySingleNode(state,
1716 0 : cAlphaArgs(aArgCount),
1717 : ErrorsFound,
1718 : DataLoopNode::ConnectionObjectType::ZoneHVACForcedAirUserDefined,
1719 0 : cAlphaArgs(1),
1720 : DataLoopNode::NodeFluidType::Water,
1721 : DataLoopNode::ConnectionType::Inlet,
1722 0 : static_cast<NodeInputManager::CompFluidStream>(ConnectionLoop + 2),
1723 : DataLoopNode::ObjectIsNotParent);
1724 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Loop(ConnectionLoop).OutletNodeNum =
1725 0 : NodeInputManager::GetOnlySingleNode(state,
1726 0 : cAlphaArgs(aArgCount + 1),
1727 : ErrorsFound,
1728 : DataLoopNode::ConnectionObjectType::ZoneHVACForcedAirUserDefined,
1729 0 : cAlphaArgs(1),
1730 : DataLoopNode::NodeFluidType::Water,
1731 : DataLoopNode::ConnectionType::Outlet,
1732 0 : static_cast<NodeInputManager::CompFluidStream>(ConnectionLoop + 2),
1733 : DataLoopNode::ObjectIsNotParent);
1734 0 : BranchNodeConnections::TestCompSet(
1735 0 : state, cCurrentModuleObject, cAlphaArgs(1), cAlphaArgs(aArgCount), cAlphaArgs(aArgCount + 1), "Plant Nodes");
1736 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Loop(ConnectionLoop).HowLoadServed = DataPlant::HowMet::NoneDemand;
1737 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Loop(ConnectionLoop).FlowPriority =
1738 : DataPlant::LoopFlowStatus::NeedyAndTurnsLoopOn;
1739 : // Setup Internal Variables
1740 0 : const std::string LoopStr = fmt::to_string(ConnectionLoop);
1741 : // model input related internal variables
1742 0 : SetupEMSInternalVariable(state,
1743 0 : "Inlet Temperature for Plant Connection " + LoopStr,
1744 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Name,
1745 : "[C]",
1746 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Loop(ConnectionLoop).InletTemp);
1747 0 : SetupEMSInternalVariable(state,
1748 0 : "Inlet Mass Flow Rate for Plant Connection " + LoopStr,
1749 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Name,
1750 : "[kg/s]",
1751 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Loop(ConnectionLoop).InletMassFlowRate);
1752 0 : SetupEMSInternalVariable(state,
1753 0 : "Inlet Density for Plant Connection " + LoopStr,
1754 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Name,
1755 : "[kg/m3]",
1756 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Loop(ConnectionLoop).InletRho);
1757 0 : SetupEMSInternalVariable(state,
1758 0 : "Inlet Specific Heat for Plant Connection " + LoopStr,
1759 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Name,
1760 : "[J/kg-C]",
1761 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Loop(ConnectionLoop).InletCp);
1762 : // model results related actuators
1763 0 : SetupEMSActuator(state,
1764 0 : "Plant Connection " + LoopStr,
1765 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Name,
1766 : "Outlet Temperature",
1767 : "[C]",
1768 0 : state.dataUserDefinedComponents->lDummy_GetUserDefComp,
1769 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Loop(ConnectionLoop).OutletTemp);
1770 0 : SetupEMSActuator(state,
1771 0 : "Plant Connection " + LoopStr,
1772 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Name,
1773 : "Mass Flow Rate",
1774 : "[kg/s]",
1775 0 : state.dataUserDefinedComponents->lDummy_GetUserDefComp,
1776 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Loop(ConnectionLoop).MassFlowRateRequest);
1777 : // model initialization and sizing related actuators
1778 0 : SetupEMSActuator(state,
1779 0 : "Plant Connection " + LoopStr,
1780 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Name,
1781 : "Minimum Mass Flow Rate",
1782 : "[kg/s]",
1783 0 : state.dataUserDefinedComponents->lDummy_GetUserDefComp,
1784 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Loop(ConnectionLoop).MassFlowRateMin);
1785 0 : SetupEMSActuator(state,
1786 0 : "Plant Connection " + LoopStr,
1787 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Name,
1788 : "Maximum Mass Flow Rate",
1789 : "[kg/s]",
1790 0 : state.dataUserDefinedComponents->lDummy_GetUserDefComp,
1791 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Loop(ConnectionLoop).MassFlowRateMax);
1792 0 : SetupEMSActuator(state,
1793 0 : "Plant Connection " + LoopStr,
1794 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Name,
1795 : "Design Volume Flow Rate",
1796 : "[m3/s]",
1797 0 : state.dataUserDefinedComponents->lDummy_GetUserDefComp,
1798 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Loop(ConnectionLoop).DesignVolumeFlowRate);
1799 0 : }
1800 : }
1801 :
1802 3 : if (!lAlphaFieldBlanks(14)) {
1803 0 : WaterManager::SetupTankDemandComponent(state,
1804 0 : cAlphaArgs(1),
1805 : cCurrentModuleObject,
1806 0 : cAlphaArgs(14),
1807 : ErrorsFound,
1808 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Water.SupplyTankID,
1809 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Water.SupplyTankDemandARRID);
1810 :
1811 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Water.SuppliedByWaterSystem = true;
1812 0 : SetupEMSActuator(state,
1813 : "Water System",
1814 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Name,
1815 : "Supplied Volume Flow Rate",
1816 : "[m3/s]",
1817 0 : state.dataUserDefinedComponents->lDummy_GetUserDefComp,
1818 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Water.SupplyVdotRequest);
1819 : }
1820 :
1821 3 : if (!lAlphaFieldBlanks(15)) {
1822 0 : WaterManager::SetupTankSupplyComponent(
1823 : state,
1824 0 : cAlphaArgs(1),
1825 : cCurrentModuleObject,
1826 0 : cAlphaArgs(15),
1827 : ErrorsFound,
1828 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Water.CollectionTankID,
1829 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Water.CollectionTankSupplyARRID);
1830 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Water.CollectsToWaterSystem = true;
1831 0 : SetupEMSActuator(state,
1832 : "Water System",
1833 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Name,
1834 : "Collected Volume Flow Rate",
1835 : "[m3/s]",
1836 0 : state.dataUserDefinedComponents->lDummy_GetUserDefComp,
1837 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Water.CollectedVdot);
1838 : }
1839 :
1840 3 : if (!lAlphaFieldBlanks(16)) {
1841 :
1842 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Zone.ZoneNum =
1843 0 : Util::FindItemInList(cAlphaArgs(16), state.dataHeatBal->Zone);
1844 0 : if (state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Zone.ZoneNum == 0) {
1845 0 : ShowSevereError(state,
1846 0 : format("{} = {}: Ambient Zone Name not found = {}", cCurrentModuleObject, cAlphaArgs(1), cAlphaArgs(16)));
1847 0 : ErrorsFound = true;
1848 : } else {
1849 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Zone.DeviceHasInternalGains = true;
1850 0 : SetupZoneInternalGain(state,
1851 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Zone.ZoneNum,
1852 0 : cAlphaArgs(1),
1853 : DataHeatBalance::IntGainType::ZoneHVACForcedAirUserDefined,
1854 0 : &state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Zone.ConvectionGainRate,
1855 0 : &state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Zone.ReturnAirConvectionGainRate,
1856 0 : &state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Zone.ThermalRadiationGainRate,
1857 0 : &state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Zone.LatentGainRate,
1858 0 : &state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Zone.ReturnAirLatentGainRate,
1859 0 : &state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Zone.CarbonDioxideGainRate,
1860 0 : &state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Zone.GenericContamGainRate);
1861 :
1862 0 : SetupEMSActuator(state,
1863 : "Component Zone Internal Gain",
1864 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Name,
1865 : "Sensible Heat Gain Rate",
1866 : "[W]",
1867 0 : state.dataUserDefinedComponents->lDummy_GetUserDefComp,
1868 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Zone.ConvectionGainRate);
1869 0 : SetupEMSActuator(state,
1870 : "Component Zone Internal Gain",
1871 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Name,
1872 : "Return Air Heat Sensible Gain Rate",
1873 : "[W]",
1874 0 : state.dataUserDefinedComponents->lDummy_GetUserDefComp,
1875 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Zone.ReturnAirConvectionGainRate);
1876 0 : SetupEMSActuator(state,
1877 : "Component Zone Internal Gain",
1878 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Name,
1879 : "Thermal Radiation Heat Gain Rate",
1880 : "[W]",
1881 0 : state.dataUserDefinedComponents->lDummy_GetUserDefComp,
1882 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Zone.ThermalRadiationGainRate);
1883 0 : SetupEMSActuator(state,
1884 : "Component Zone Internal Gain",
1885 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Name,
1886 : "Latent Heat Gain Rate",
1887 : "[W]",
1888 0 : state.dataUserDefinedComponents->lDummy_GetUserDefComp,
1889 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Zone.LatentGainRate);
1890 0 : SetupEMSActuator(state,
1891 : "Component Zone Internal Gain",
1892 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Name,
1893 : "Return Air Latent Heat Gain Rate",
1894 : "[W]",
1895 0 : state.dataUserDefinedComponents->lDummy_GetUserDefComp,
1896 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Zone.ReturnAirLatentGainRate);
1897 0 : SetupEMSActuator(state,
1898 : "Component Zone Internal Gain",
1899 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Name,
1900 : "Carbon Dioxide Gain Rate",
1901 : "[m3/s]",
1902 0 : state.dataUserDefinedComponents->lDummy_GetUserDefComp,
1903 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Zone.CarbonDioxideGainRate);
1904 0 : SetupEMSActuator(state,
1905 : "Component Zone Internal Gain",
1906 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Name,
1907 : "Gaseous Contaminant Gain Rate",
1908 : "[m3/s]",
1909 0 : state.dataUserDefinedComponents->lDummy_GetUserDefComp,
1910 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Zone.GenericContamGainRate);
1911 : }
1912 : }
1913 : }
1914 : } // NumUserZoneAir > 0
1915 :
1916 1 : if (ErrorsFound) {
1917 0 : ShowFatalError(state, format("GetUserDefinedComponents: Errors found in processing {} input.", cCurrentModuleObject));
1918 : }
1919 :
1920 1 : cCurrentModuleObject = "AirTerminal:SingleDuct:UserDefined";
1921 :
1922 1 : state.dataInputProcessing->inputProcessor->getObjectDefMaxArgs(state, cCurrentModuleObject, TotalArgs, NumAlphas, NumNums);
1923 :
1924 1 : cAlphaFieldNames.allocate(NumAlphas);
1925 1 : cAlphaArgs.allocate(NumAlphas);
1926 1 : lAlphaFieldBlanks.dimension(NumAlphas, false);
1927 1 : rNumericArgs.dimension(NumNums, 0.0);
1928 :
1929 2 : state.dataUserDefinedComponents->NumUserAirTerminals =
1930 1 : state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, cCurrentModuleObject);
1931 1 : if (state.dataUserDefinedComponents->NumUserAirTerminals > 0) {
1932 0 : state.dataUserDefinedComponents->UserAirTerminal.allocate(state.dataUserDefinedComponents->NumUserAirTerminals);
1933 0 : state.dataUserDefinedComponents->CheckUserAirTerminal.dimension(state.dataUserDefinedComponents->NumUserAirTerminals, true);
1934 0 : for (int CompLoop = 1; CompLoop <= state.dataUserDefinedComponents->NumUserAirTerminals; ++CompLoop) {
1935 0 : state.dataInputProcessing->inputProcessor->getObjectItem(state,
1936 : cCurrentModuleObject,
1937 : CompLoop,
1938 : cAlphaArgs,
1939 : NumAlphas,
1940 : rNumericArgs,
1941 : NumNums,
1942 : IOStat,
1943 : _,
1944 : lAlphaFieldBlanks,
1945 : cAlphaFieldNames,
1946 : _);
1947 0 : Util::IsNameEmpty(state, cAlphaArgs(1), cCurrentModuleObject, ErrorsFound);
1948 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Name = cAlphaArgs(1);
1949 :
1950 : // now get program manager for model simulations
1951 0 : if (!lAlphaFieldBlanks(2)) {
1952 0 : int StackMngrNum = Util::FindItemInList(cAlphaArgs(2), state.dataRuntimeLang->EMSProgramCallManager);
1953 0 : if (StackMngrNum > 0) { // found it
1954 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).ErlSimProgramMngr = StackMngrNum;
1955 : } else {
1956 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).simPluginLocation =
1957 0 : state.dataPluginManager->pluginManager->getLocationOfUserDefinedPlugin(state, cAlphaArgs(2));
1958 0 : if (state.dataUserDefinedComponents->UserAirTerminal(CompLoop).simPluginLocation == -1) {
1959 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).simCallbackIndex =
1960 0 : state.dataPluginManager->pluginManager->getUserDefinedCallbackIndex(state, cAlphaArgs(2));
1961 0 : if (state.dataUserDefinedComponents->UserAirTerminal(CompLoop).simCallbackIndex == -1) {
1962 0 : ShowSevereError(state, format("Invalid {}={}", cAlphaFieldNames(2), cAlphaArgs(2)));
1963 0 : ShowContinueError(state, format("Entered in {}={}", cCurrentModuleObject, cAlphaArgs(1)));
1964 0 : ShowContinueError(
1965 : state,
1966 : "Program Manager Name not found as an EMS Program Manager, API callback or a Python Plugin Instance object.");
1967 0 : ErrorsFound = true;
1968 : }
1969 : }
1970 : }
1971 : }
1972 :
1973 : // now get program manager for model initializations
1974 0 : if (!lAlphaFieldBlanks(3)) {
1975 0 : int StackMngrNum = Util::FindItemInList(cAlphaArgs(3), state.dataRuntimeLang->EMSProgramCallManager);
1976 0 : if (StackMngrNum > 0) { // found it
1977 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).ErlInitProgramMngr = StackMngrNum;
1978 : } else {
1979 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).initPluginLocation =
1980 0 : state.dataPluginManager->pluginManager->getLocationOfUserDefinedPlugin(state, cAlphaArgs(3));
1981 0 : if (state.dataUserDefinedComponents->UserAirTerminal(CompLoop).initPluginLocation == -1) {
1982 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).initCallbackIndex =
1983 0 : state.dataPluginManager->pluginManager->getUserDefinedCallbackIndex(state, cAlphaArgs(3));
1984 0 : if (state.dataUserDefinedComponents->UserAirTerminal(CompLoop).initCallbackIndex == -1) {
1985 0 : ShowSevereError(state, format("Invalid {}={}", cAlphaFieldNames(3), cAlphaArgs(3)));
1986 0 : ShowContinueError(state, format("Entered in {}={}", cCurrentModuleObject, cAlphaArgs(1)));
1987 0 : ShowContinueError(
1988 : state,
1989 : "Program Manager Name not found as an EMS Program Manager, API callback or a Python Plugin Instance object.");
1990 0 : ErrorsFound = true;
1991 : }
1992 : }
1993 : }
1994 : }
1995 :
1996 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).AirLoop.InletNodeNum =
1997 0 : NodeInputManager::GetOnlySingleNode(state,
1998 0 : cAlphaArgs(4),
1999 : ErrorsFound,
2000 : DataLoopNode::ConnectionObjectType::AirTerminalSingleDuctUserDefined,
2001 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Name,
2002 : DataLoopNode::NodeFluidType::Air,
2003 : DataLoopNode::ConnectionType::Inlet,
2004 : NodeInputManager::CompFluidStream::Primary,
2005 : DataLoopNode::ObjectIsNotParent,
2006 0 : cAlphaFieldNames(4));
2007 : // model input related internal variables
2008 0 : SetupEMSInternalVariable(state,
2009 : "Inlet Temperature for Primary Air Connection",
2010 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Name,
2011 : "[C]",
2012 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).AirLoop.InletTemp);
2013 0 : SetupEMSInternalVariable(state,
2014 : "Inlet Humidity Ratio for Primary Air Connection",
2015 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Name,
2016 : "[kgWater/kgDryAir]",
2017 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).AirLoop.InletHumRat);
2018 0 : SetupEMSInternalVariable(state,
2019 : "Inlet Density for Primary Air Connection",
2020 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Name,
2021 : "[kg/m3]",
2022 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).AirLoop.InletRho);
2023 0 : SetupEMSInternalVariable(state,
2024 : "Inlet Specific Heat for Primary Air Connection",
2025 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Name,
2026 : "[J/kg-C]",
2027 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).AirLoop.InletCp);
2028 :
2029 0 : SetupEMSInternalVariable(state,
2030 : "Remaining Sensible Load to Heating Setpoint",
2031 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Name,
2032 : "[W]",
2033 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).RemainingOutputToHeatingSP);
2034 0 : SetupEMSInternalVariable(state,
2035 : "Remaining Sensible Load to Cooling Setpoint",
2036 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Name,
2037 : "[W]",
2038 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).RemainingOutputToCoolingSP);
2039 0 : SetupEMSInternalVariable(state,
2040 : "Remaining Latent Load to Humidifying Setpoint",
2041 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Name,
2042 : "[kg/s]",
2043 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).RemainingOutputReqToHumidSP);
2044 0 : SetupEMSInternalVariable(state,
2045 : "Remaining Latent Load to Dehumidifying Setpoint",
2046 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Name,
2047 : "[kg/s]",
2048 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).RemainingOutputReqToDehumidSP);
2049 :
2050 0 : SetupEMSActuator(state,
2051 : "Primary Air Connection",
2052 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Name,
2053 : "Inlet Mass Flow Rate",
2054 : "[kg/s]",
2055 0 : state.dataUserDefinedComponents->lDummy_GetUserDefComp,
2056 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).AirLoop.InletMassFlowRate);
2057 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).AirLoop.OutletNodeNum =
2058 0 : NodeInputManager::GetOnlySingleNode(state,
2059 0 : cAlphaArgs(5),
2060 : ErrorsFound,
2061 : DataLoopNode::ConnectionObjectType::AirTerminalSingleDuctUserDefined,
2062 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Name,
2063 : DataLoopNode::NodeFluidType::Air,
2064 : DataLoopNode::ConnectionType::Outlet,
2065 : NodeInputManager::CompFluidStream::Primary,
2066 : DataLoopNode::ObjectIsNotParent,
2067 0 : cAlphaFieldNames(5));
2068 0 : SetupEMSActuator(state,
2069 : "Primary Air Connection",
2070 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Name,
2071 : "Outlet Temperature",
2072 : "[C]",
2073 0 : state.dataUserDefinedComponents->lDummy_GetUserDefComp,
2074 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).AirLoop.OutletTemp);
2075 0 : SetupEMSActuator(state,
2076 : "Primary Air Connection",
2077 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Name,
2078 : "Outlet Humidity Ratio",
2079 : "[kgWater/kgDryAir]",
2080 0 : state.dataUserDefinedComponents->lDummy_GetUserDefComp,
2081 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).AirLoop.OutletHumRat);
2082 0 : SetupEMSActuator(state,
2083 : "Primary Air Connection",
2084 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Name,
2085 : "Outlet Mass Flow Rate",
2086 : "[kg/s]",
2087 0 : state.dataUserDefinedComponents->lDummy_GetUserDefComp,
2088 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).AirLoop.OutletMassFlowRate);
2089 0 : BranchNodeConnections::TestCompSet(state, cCurrentModuleObject, cAlphaArgs(1), cAlphaArgs(4), cAlphaArgs(5), "Air Nodes");
2090 :
2091 0 : int ADUNum = 0;
2092 0 : for (ADUNum = 1; ADUNum <= (int)state.dataDefineEquipment->AirDistUnit.size(); ++ADUNum) {
2093 0 : if (state.dataUserDefinedComponents->UserAirTerminal(CompLoop).AirLoop.OutletNodeNum ==
2094 0 : state.dataDefineEquipment->AirDistUnit(ADUNum).OutletNodeNum) {
2095 : // AirDistUnit(ADUNum)%InletNodeNum = IndUnitIUNum)%InletNodeNum
2096 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).ADUNum = ADUNum;
2097 : }
2098 : }
2099 : // one assumes if there isn't one assigned, it's an error?
2100 0 : if (state.dataUserDefinedComponents->UserAirTerminal(CompLoop).ADUNum == 0) {
2101 0 : ShowSevereError(state,
2102 0 : format("GetUserDefinedComponents: No matching Air Distribution Unit for {} = {}",
2103 : cCurrentModuleObject,
2104 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Name));
2105 0 : ShowContinueError(
2106 : state,
2107 0 : format("...should have outlet node={}",
2108 0 : state.dataLoopNodes->NodeID(state.dataUserDefinedComponents->UserAirTerminal(CompLoop).AirLoop.OutletNodeNum)));
2109 : // ErrorsFound=.TRUE.
2110 : }
2111 :
2112 : // Fill the Zone Equipment data with the inlet node number of this unit.
2113 0 : for (int CtrlZone = 1; CtrlZone <= state.dataGlobal->NumOfZones; ++CtrlZone) {
2114 0 : if (!state.dataZoneEquip->ZoneEquipConfig(CtrlZone).IsControlled) {
2115 0 : continue;
2116 : }
2117 0 : for (int SupAirIn = 1; SupAirIn <= state.dataZoneEquip->ZoneEquipConfig(CtrlZone).NumInletNodes; ++SupAirIn) {
2118 0 : if (state.dataUserDefinedComponents->UserAirTerminal(CompLoop).AirLoop.OutletNodeNum ==
2119 0 : state.dataZoneEquip->ZoneEquipConfig(CtrlZone).InletNode(SupAirIn)) {
2120 0 : if (state.dataZoneEquip->ZoneEquipConfig(CtrlZone).AirDistUnitCool(SupAirIn).OutNode > 0) {
2121 0 : ShowSevereError(state, "Error in connecting a terminal unit to a zone");
2122 0 : ShowContinueError(state,
2123 0 : format("{} already connects to another zone",
2124 0 : state.dataLoopNodes->NodeID(
2125 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).AirLoop.OutletNodeNum)));
2126 0 : ShowContinueError(state,
2127 0 : format("Occurs for terminal unit {} = {}",
2128 : cCurrentModuleObject,
2129 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Name));
2130 0 : ShowContinueError(state, "Check terminal unit node names for errors");
2131 0 : ErrorsFound = true;
2132 : } else {
2133 0 : state.dataZoneEquip->ZoneEquipConfig(CtrlZone).AirDistUnitCool(SupAirIn).InNode =
2134 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).AirLoop.InletNodeNum;
2135 0 : state.dataZoneEquip->ZoneEquipConfig(CtrlZone).AirDistUnitCool(SupAirIn).OutNode =
2136 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).AirLoop.OutletNodeNum;
2137 0 : state.dataDefineEquipment->AirDistUnit(state.dataUserDefinedComponents->UserAirTerminal(CompLoop).ADUNum)
2138 0 : .TermUnitSizingNum = state.dataZoneEquip->ZoneEquipConfig(CtrlZone).AirDistUnitCool(SupAirIn).TermUnitSizingIndex;
2139 0 : state.dataDefineEquipment->AirDistUnit(state.dataUserDefinedComponents->UserAirTerminal(CompLoop).ADUNum).ZoneEqNum =
2140 : CtrlZone;
2141 : }
2142 :
2143 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).ActualCtrlZoneNum = CtrlZone;
2144 : }
2145 : }
2146 : }
2147 :
2148 0 : if (!lAlphaFieldBlanks(6)) {
2149 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).SourceAir.InletNodeNum =
2150 0 : NodeInputManager::GetOnlySingleNode(state,
2151 0 : cAlphaArgs(6),
2152 : ErrorsFound,
2153 : DataLoopNode::ConnectionObjectType::AirTerminalSingleDuctUserDefined,
2154 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Name,
2155 : DataLoopNode::NodeFluidType::Air,
2156 : DataLoopNode::ConnectionType::Inlet,
2157 : NodeInputManager::CompFluidStream::Secondary,
2158 : DataLoopNode::ObjectIsNotParent,
2159 0 : cAlphaFieldNames(6));
2160 : // model input related internal variables
2161 0 : SetupEMSInternalVariable(state,
2162 : "Inlet Temperature for Secondary Air Connection",
2163 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Name,
2164 : "[C]",
2165 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).SourceAir.InletTemp);
2166 :
2167 0 : SetupEMSInternalVariable(state,
2168 : "Inlet Humidity Ratio for Secondary Air Connection",
2169 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Name,
2170 : "[kgWater/kgDryAir]",
2171 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).SourceAir.InletHumRat);
2172 0 : SetupEMSInternalVariable(state,
2173 : "Inlet Density for Secondary Air Connection",
2174 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Name,
2175 : "[kg/m3]",
2176 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).SourceAir.InletRho);
2177 0 : SetupEMSInternalVariable(state,
2178 : "Inlet Specific Heat for Secondary Air Connection",
2179 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Name,
2180 : "[J/kg-C]",
2181 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).SourceAir.InletCp);
2182 0 : SetupEMSActuator(state,
2183 : "Secondary Air Connection",
2184 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Name,
2185 : "Inlet Mass Flow Rate",
2186 : "[kg/s]",
2187 0 : state.dataUserDefinedComponents->lDummy_GetUserDefComp,
2188 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).SourceAir.InletMassFlowRate);
2189 : }
2190 :
2191 0 : if (!lAlphaFieldBlanks(7)) {
2192 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).SourceAir.OutletNodeNum =
2193 0 : NodeInputManager::GetOnlySingleNode(state,
2194 0 : cAlphaArgs(7),
2195 : ErrorsFound,
2196 : DataLoopNode::ConnectionObjectType::AirTerminalSingleDuctUserDefined,
2197 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Name,
2198 : DataLoopNode::NodeFluidType::Air,
2199 : DataLoopNode::ConnectionType::Outlet,
2200 : NodeInputManager::CompFluidStream::Secondary,
2201 : DataLoopNode::ObjectIsNotParent,
2202 0 : cAlphaFieldNames(7));
2203 0 : SetupEMSActuator(state,
2204 : "Secondary Air Connection",
2205 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Name,
2206 : "Outlet Temperature",
2207 : "[C]",
2208 0 : state.dataUserDefinedComponents->lDummy_GetUserDefComp,
2209 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).SourceAir.OutletTemp);
2210 0 : SetupEMSActuator(state,
2211 : "Secondary Air Connection",
2212 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Name,
2213 : "Outlet Humidity Ratio",
2214 : "[kgWater/kgDryAir]",
2215 0 : state.dataUserDefinedComponents->lDummy_GetUserDefComp,
2216 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).SourceAir.OutletHumRat);
2217 0 : SetupEMSActuator(state,
2218 : "Secondary Air Connection",
2219 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Name,
2220 : "Mass Flow Rate",
2221 : "[kg/s]",
2222 0 : state.dataUserDefinedComponents->lDummy_GetUserDefComp,
2223 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).SourceAir.OutletMassFlowRate);
2224 : }
2225 :
2226 0 : if ((state.dataUserDefinedComponents->UserAirTerminal(CompLoop).SourceAir.InletNodeNum > 0) &&
2227 0 : (state.dataUserDefinedComponents->UserAirTerminal(CompLoop).SourceAir.OutletNodeNum > 0)) {
2228 : }
2229 :
2230 0 : int NumPlantConnections = std::floor(rNumericArgs(1));
2231 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).NumPlantConnections = NumPlantConnections;
2232 0 : if ((NumPlantConnections >= 1) && (NumPlantConnections <= 2)) {
2233 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Loop.allocate(NumPlantConnections);
2234 0 : for (int ConnectionLoop = 1; ConnectionLoop <= NumPlantConnections; ++ConnectionLoop) {
2235 0 : int aArgCount = (ConnectionLoop - 1) * 2 + 8;
2236 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Loop(ConnectionLoop).InletNodeNum =
2237 0 : NodeInputManager::GetOnlySingleNode(state,
2238 0 : cAlphaArgs(aArgCount),
2239 : ErrorsFound,
2240 : DataLoopNode::ConnectionObjectType::AirTerminalSingleDuctUserDefined,
2241 0 : cAlphaArgs(1),
2242 : DataLoopNode::NodeFluidType::Water,
2243 : DataLoopNode::ConnectionType::Inlet,
2244 0 : static_cast<NodeInputManager::CompFluidStream>(ConnectionLoop + 2),
2245 : DataLoopNode::ObjectIsNotParent,
2246 0 : cAlphaFieldNames(aArgCount));
2247 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Loop(ConnectionLoop).OutletNodeNum =
2248 0 : NodeInputManager::GetOnlySingleNode(state,
2249 0 : cAlphaArgs(aArgCount + 1),
2250 : ErrorsFound,
2251 : DataLoopNode::ConnectionObjectType::AirTerminalSingleDuctUserDefined,
2252 0 : cAlphaArgs(1),
2253 : DataLoopNode::NodeFluidType::Water,
2254 : DataLoopNode::ConnectionType::Outlet,
2255 0 : static_cast<NodeInputManager::CompFluidStream>(ConnectionLoop + 2),
2256 : DataLoopNode::ObjectIsNotParent,
2257 0 : cAlphaFieldNames(aArgCount + 1));
2258 0 : BranchNodeConnections::TestCompSet(
2259 0 : state, cCurrentModuleObject, cAlphaArgs(1), cAlphaArgs(aArgCount), cAlphaArgs(aArgCount + 1), "Plant Nodes");
2260 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Loop(ConnectionLoop).HowLoadServed = DataPlant::HowMet::NoneDemand;
2261 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Loop(ConnectionLoop).FlowPriority =
2262 : DataPlant::LoopFlowStatus::NeedyAndTurnsLoopOn;
2263 : // Setup Internal Variables
2264 0 : const std::string LoopStr = fmt::to_string(ConnectionLoop);
2265 : // model input related internal variables
2266 0 : SetupEMSInternalVariable(state,
2267 0 : "Inlet Temperature for Plant Connection " + LoopStr,
2268 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Name,
2269 : "[C]",
2270 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Loop(ConnectionLoop).InletTemp);
2271 0 : SetupEMSInternalVariable(state,
2272 0 : "Inlet Mass Flow Rate for Plant Connection " + LoopStr,
2273 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Name,
2274 : "[kg/s]",
2275 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Loop(ConnectionLoop).InletMassFlowRate);
2276 0 : SetupEMSInternalVariable(state,
2277 0 : "Inlet Density for Plant Connection " + LoopStr,
2278 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Name,
2279 : "[kg/m3]",
2280 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Loop(ConnectionLoop).InletRho);
2281 0 : SetupEMSInternalVariable(state,
2282 0 : "Inlet Specific Heat for Plant Connection " + LoopStr,
2283 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Name,
2284 : "[J/kg-C]",
2285 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Loop(ConnectionLoop).InletCp);
2286 : // model results related actuators
2287 0 : SetupEMSActuator(state,
2288 0 : "Plant Connection " + LoopStr,
2289 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Name,
2290 : "Outlet Temperature",
2291 : "[C]",
2292 0 : state.dataUserDefinedComponents->lDummy_GetUserDefComp,
2293 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Loop(ConnectionLoop).OutletTemp);
2294 0 : SetupEMSActuator(state,
2295 0 : "Plant Connection " + LoopStr,
2296 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Name,
2297 : "Mass Flow Rate",
2298 : "[kg/s]",
2299 0 : state.dataUserDefinedComponents->lDummy_GetUserDefComp,
2300 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Loop(ConnectionLoop).MassFlowRateRequest);
2301 : // model initialization and sizing related actuators
2302 0 : SetupEMSActuator(state,
2303 0 : "Plant Connection " + LoopStr,
2304 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Name,
2305 : "Minimum Mass Flow Rate",
2306 : "[kg/s]",
2307 0 : state.dataUserDefinedComponents->lDummy_GetUserDefComp,
2308 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Loop(ConnectionLoop).MassFlowRateMin);
2309 0 : SetupEMSActuator(state,
2310 0 : "Plant Connection " + LoopStr,
2311 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Name,
2312 : "Maximum Mass Flow Rate",
2313 : "[kg/s]",
2314 0 : state.dataUserDefinedComponents->lDummy_GetUserDefComp,
2315 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Loop(ConnectionLoop).MassFlowRateMax);
2316 0 : SetupEMSActuator(state,
2317 0 : "Plant Connection " + LoopStr,
2318 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Name,
2319 : "Design Volume Flow Rate",
2320 : "[m3/s]",
2321 0 : state.dataUserDefinedComponents->lDummy_GetUserDefComp,
2322 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Loop(ConnectionLoop).DesignVolumeFlowRate);
2323 0 : }
2324 : }
2325 :
2326 0 : if (!lAlphaFieldBlanks(12)) {
2327 0 : WaterManager::SetupTankDemandComponent(state,
2328 0 : cAlphaArgs(1),
2329 : cCurrentModuleObject,
2330 0 : cAlphaArgs(12),
2331 : ErrorsFound,
2332 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Water.SupplyTankID,
2333 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Water.SupplyTankDemandARRID);
2334 :
2335 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Water.SuppliedByWaterSystem = true;
2336 0 : SetupEMSActuator(state,
2337 : "Water System",
2338 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Name,
2339 : "Supplied Volume Flow Rate",
2340 : "[m3/s]",
2341 0 : state.dataUserDefinedComponents->lDummy_GetUserDefComp,
2342 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Water.SupplyVdotRequest);
2343 : }
2344 :
2345 0 : if (!lAlphaFieldBlanks(13)) {
2346 0 : WaterManager::SetupTankSupplyComponent(
2347 : state,
2348 0 : cAlphaArgs(1),
2349 : cCurrentModuleObject,
2350 0 : cAlphaArgs(13),
2351 : ErrorsFound,
2352 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Water.CollectionTankID,
2353 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Water.CollectionTankSupplyARRID);
2354 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Water.CollectsToWaterSystem = true;
2355 0 : SetupEMSActuator(state,
2356 : "Water System",
2357 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Name,
2358 : "Collected Volume Flow Rate",
2359 : "[m3/s]",
2360 0 : state.dataUserDefinedComponents->lDummy_GetUserDefComp,
2361 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Water.CollectedVdot);
2362 : }
2363 :
2364 0 : if (!lAlphaFieldBlanks(14)) {
2365 :
2366 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Zone.ZoneNum =
2367 0 : Util::FindItemInList(cAlphaArgs(14), state.dataHeatBal->Zone);
2368 0 : if (state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Zone.ZoneNum == 0) {
2369 0 : ShowSevereError(state,
2370 0 : format("{} = {}: Ambient Zone Name not found = {}", cCurrentModuleObject, cAlphaArgs(1), cAlphaArgs(14)));
2371 0 : ErrorsFound = true;
2372 : } else {
2373 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Zone.DeviceHasInternalGains = true;
2374 0 : SetupZoneInternalGain(state,
2375 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Zone.ZoneNum,
2376 0 : cAlphaArgs(1),
2377 : DataHeatBalance::IntGainType::AirTerminalUserDefined,
2378 0 : &state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Zone.ConvectionGainRate,
2379 0 : &state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Zone.ReturnAirConvectionGainRate,
2380 0 : &state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Zone.ThermalRadiationGainRate,
2381 0 : &state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Zone.LatentGainRate,
2382 0 : &state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Zone.ReturnAirLatentGainRate,
2383 0 : &state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Zone.CarbonDioxideGainRate,
2384 0 : &state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Zone.GenericContamGainRate);
2385 :
2386 0 : SetupEMSActuator(state,
2387 : "Component Zone Internal Gain",
2388 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Name,
2389 : "Sensible Heat Gain Rate",
2390 : "[W]",
2391 0 : state.dataUserDefinedComponents->lDummy_GetUserDefComp,
2392 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Zone.ConvectionGainRate);
2393 0 : SetupEMSActuator(state,
2394 : "Component Zone Internal Gain",
2395 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Name,
2396 : "Return Air Heat Sensible Gain Rate",
2397 : "[W]",
2398 0 : state.dataUserDefinedComponents->lDummy_GetUserDefComp,
2399 0 : state.dataUserDefinedComponents->UserZoneAirHVAC(CompLoop).Zone.ReturnAirConvectionGainRate);
2400 0 : SetupEMSActuator(state,
2401 : "Component Zone Internal Gain",
2402 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Name,
2403 : "Thermal Radiation Heat Gain Rate",
2404 : "[W]",
2405 0 : state.dataUserDefinedComponents->lDummy_GetUserDefComp,
2406 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Zone.ThermalRadiationGainRate);
2407 0 : SetupEMSActuator(state,
2408 : "Component Zone Internal Gain",
2409 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Name,
2410 : "Latent Heat Gain Rate",
2411 : "[W]",
2412 0 : state.dataUserDefinedComponents->lDummy_GetUserDefComp,
2413 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Zone.LatentGainRate);
2414 0 : SetupEMSActuator(state,
2415 : "Component Zone Internal Gain",
2416 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Name,
2417 : "Return Air Latent Heat Gain Rate",
2418 : "[W]",
2419 0 : state.dataUserDefinedComponents->lDummy_GetUserDefComp,
2420 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Zone.ReturnAirLatentGainRate);
2421 0 : SetupEMSActuator(state,
2422 : "Component Zone Internal Gain",
2423 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Name,
2424 : "Carbon Dioxide Gain Rate",
2425 : "[W]",
2426 0 : state.dataUserDefinedComponents->lDummy_GetUserDefComp,
2427 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Zone.CarbonDioxideGainRate);
2428 0 : SetupEMSActuator(state,
2429 : "Component Zone Internal Gain",
2430 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Name,
2431 : "Gaseous Contaminant Gain Rate",
2432 : "[W]",
2433 0 : state.dataUserDefinedComponents->lDummy_GetUserDefComp,
2434 0 : state.dataUserDefinedComponents->UserAirTerminal(CompLoop).Zone.GenericContamGainRate);
2435 : }
2436 : }
2437 : }
2438 : } // NumUserZoneAir > 0
2439 :
2440 1 : if (ErrorsFound) {
2441 0 : ShowFatalError(state, format("GetUserDefinedComponents: Errors found in processing {} input.", cCurrentModuleObject));
2442 : }
2443 1 : }
2444 :
2445 0 : void UserPlantComponentStruct::initialize(EnergyPlusData &state, int LoopNum, Real64 MyLoad)
2446 : {
2447 : // SUBROUTINE INFORMATION:
2448 : // AUTHOR <author>
2449 : // DATE WRITTEN <date_written>
2450 : // MODIFIED na
2451 : // RE-ENGINEERED na
2452 :
2453 : static constexpr std::string_view RoutineName("InitPlantUserComponent");
2454 :
2455 0 : this->oneTimeInit(state);
2456 :
2457 0 : if (LoopNum <= 0 || LoopNum > this->NumPlantConnections) {
2458 0 : return;
2459 : }
2460 :
2461 : // fill internal variable targets
2462 0 : this->Loop(LoopNum).MyLoad = MyLoad;
2463 0 : this->Loop(LoopNum).InletRho = state.dataPlnt->PlantLoop(this->Loop(LoopNum).plantLoc.loopNum)
2464 0 : .glycol->getDensity(state, state.dataLoopNodes->Node(this->Loop(LoopNum).InletNodeNum).Temp, RoutineName);
2465 0 : this->Loop(LoopNum).InletCp =
2466 0 : state.dataPlnt->PlantLoop(this->Loop(LoopNum).plantLoc.loopNum)
2467 0 : .glycol->getSpecificHeat(state, state.dataLoopNodes->Node(this->Loop(LoopNum).InletNodeNum).Temp, RoutineName);
2468 0 : this->Loop(LoopNum).InletMassFlowRate = state.dataLoopNodes->Node(this->Loop(LoopNum).InletNodeNum).MassFlowRate;
2469 0 : this->Loop(LoopNum).InletTemp = state.dataLoopNodes->Node(this->Loop(LoopNum).InletNodeNum).Temp;
2470 0 : if (this->Air.InletNodeNum > 0) {
2471 0 : this->Air.InletRho = Psychrometrics::PsyRhoAirFnPbTdbW(state,
2472 0 : state.dataEnvrn->OutBaroPress,
2473 0 : state.dataLoopNodes->Node(this->Air.InletNodeNum).Temp,
2474 0 : state.dataLoopNodes->Node(this->Air.InletNodeNum).HumRat,
2475 : RoutineName);
2476 0 : this->Air.InletCp = Psychrometrics::PsyCpAirFnW(state.dataLoopNodes->Node(this->Air.InletNodeNum).HumRat);
2477 0 : this->Air.InletTemp = state.dataLoopNodes->Node(this->Air.InletNodeNum).Temp;
2478 0 : this->Air.InletMassFlowRate = state.dataLoopNodes->Node(this->Air.InletNodeNum).MassFlowRate;
2479 0 : this->Air.InletHumRat = state.dataLoopNodes->Node(this->Air.InletNodeNum).HumRat;
2480 : }
2481 : }
2482 :
2483 0 : void UserCoilComponentStruct::initialize(EnergyPlusData &state)
2484 : {
2485 :
2486 : // SUBROUTINE INFORMATION:
2487 : // AUTHOR <author>
2488 : // DATE WRITTEN <date_written>
2489 : // MODIFIED na
2490 : // RE-ENGINEERED na
2491 :
2492 : static constexpr std::string_view RoutineName("InitCoilUserDefined");
2493 :
2494 0 : if (this->myOneTimeFlag) {
2495 0 : if (this->PlantIsConnected) {
2496 0 : bool errFlag = false;
2497 0 : PlantUtilities::ScanPlantLoopsForObject(
2498 0 : state, this->Name, DataPlant::PlantEquipmentType::CoilUserDefined, this->Loop.plantLoc, errFlag);
2499 0 : if (errFlag) {
2500 0 : ShowFatalError(state, "InitPlantUserComponent: Program terminated due to previous condition(s).");
2501 : }
2502 : // set user input for flow priority
2503 0 : DataPlant::CompData::getPlantComponent(state, this->Loop.plantLoc).FlowPriority = this->Loop.FlowPriority;
2504 :
2505 : // set user input for how loads served
2506 0 : DataPlant::CompData::getPlantComponent(state, this->Loop.plantLoc).HowLoadServed = this->Loop.HowLoadServed;
2507 : }
2508 0 : this->myOneTimeFlag = false;
2509 : }
2510 :
2511 : // fill internal variable targets
2512 0 : for (int loop = 1; loop <= this->NumAirConnections; ++loop) {
2513 0 : this->Air(loop).InletRho = Psychrometrics::PsyRhoAirFnPbTdbW(state,
2514 0 : state.dataEnvrn->OutBaroPress,
2515 0 : state.dataLoopNodes->Node(this->Air(loop).InletNodeNum).Temp,
2516 0 : state.dataLoopNodes->Node(this->Air(loop).InletNodeNum).HumRat,
2517 : RoutineName);
2518 :
2519 0 : this->Air(loop).InletCp = Psychrometrics::PsyCpAirFnW(state.dataLoopNodes->Node(this->Air(loop).InletNodeNum).HumRat);
2520 0 : this->Air(loop).InletTemp = state.dataLoopNodes->Node(this->Air(loop).InletNodeNum).Temp;
2521 0 : this->Air(loop).InletMassFlowRate = state.dataLoopNodes->Node(this->Air(loop).InletNodeNum).MassFlowRate;
2522 0 : this->Air(loop).InletHumRat = state.dataLoopNodes->Node(this->Air(loop).InletNodeNum).HumRat;
2523 : }
2524 :
2525 0 : if (this->PlantIsConnected) {
2526 0 : this->Loop.InletRho = state.dataPlnt->PlantLoop(this->Loop.plantLoc.loopNum)
2527 0 : .glycol->getDensity(state, state.dataLoopNodes->Node(this->Loop.InletNodeNum).Temp, RoutineName);
2528 0 : this->Loop.InletCp = state.dataPlnt->PlantLoop(this->Loop.plantLoc.loopNum)
2529 0 : .glycol->getSpecificHeat(state, state.dataLoopNodes->Node(this->Loop.InletNodeNum).Temp, RoutineName);
2530 0 : this->Loop.InletTemp = state.dataLoopNodes->Node(this->Loop.InletNodeNum).Temp;
2531 0 : this->Loop.InletMassFlowRate = state.dataLoopNodes->Node(this->Loop.InletNodeNum).MassFlowRate;
2532 : }
2533 0 : }
2534 :
2535 12363 : void UserZoneHVACForcedAirComponentStruct::initialize(EnergyPlusData &state, int const ZoneNum)
2536 : {
2537 :
2538 : // SUBROUTINE INFORMATION:
2539 : // AUTHOR Brent Griffith
2540 : // DATE WRITTEN Feb. 2012
2541 : // MODIFIED na
2542 : // RE-ENGINEERED na
2543 :
2544 : // PURPOSE OF THIS SUBROUTINE:
2545 : // initialize data for user-defined zone HVAC forced air component model
2546 :
2547 : static constexpr std::string_view RoutineName("InitZoneAirUserDefined");
2548 :
2549 12363 : if (this->myOneTimeFlag) {
2550 3 : if (this->NumPlantConnections > 0) {
2551 0 : for (int loop = 1; loop <= this->NumPlantConnections; ++loop) {
2552 0 : bool errFlag = false;
2553 0 : PlantUtilities::ScanPlantLoopsForObject(state,
2554 : this->Name,
2555 : DataPlant::PlantEquipmentType::ZoneHVACAirUserDefined,
2556 0 : this->Loop(loop).plantLoc,
2557 : errFlag,
2558 : _,
2559 : _,
2560 : _,
2561 0 : this->Loop(loop).InletNodeNum,
2562 0 : ObjexxFCL::Optional_int_const());
2563 0 : if (errFlag) {
2564 0 : ShowFatalError(state, "InitPlantUserComponent: Program terminated due to previous condition(s).");
2565 : }
2566 : // set user input for flow priority
2567 0 : DataPlant::CompData::getPlantComponent(state, this->Loop(loop).plantLoc).FlowPriority = this->Loop(loop).FlowPriority;
2568 :
2569 : // set user input for how loads served
2570 0 : DataPlant::CompData::getPlantComponent(state, this->Loop(loop).plantLoc).HowLoadServed = this->Loop(loop).HowLoadServed;
2571 : }
2572 : }
2573 3 : this->myOneTimeFlag = false;
2574 : }
2575 : // fill internal variable targets
2576 12363 : this->RemainingOutputToHeatingSP = state.dataZoneEnergyDemand->ZoneSysEnergyDemand(ZoneNum).RemainingOutputReqToHeatSP;
2577 12363 : this->RemainingOutputToCoolingSP = state.dataZoneEnergyDemand->ZoneSysEnergyDemand(ZoneNum).RemainingOutputReqToCoolSP;
2578 12363 : this->RemainingOutputReqToDehumidSP = state.dataZoneEnergyDemand->ZoneSysMoistureDemand(ZoneNum).RemainingOutputReqToDehumidSP;
2579 12363 : this->RemainingOutputReqToHumidSP = state.dataZoneEnergyDemand->ZoneSysMoistureDemand(ZoneNum).RemainingOutputReqToHumidSP;
2580 :
2581 12363 : this->ZoneAir.InletRho = Psychrometrics::PsyRhoAirFnPbTdbW(state,
2582 12363 : state.dataEnvrn->OutBaroPress,
2583 12363 : state.dataLoopNodes->Node(this->ZoneAir.InletNodeNum).Temp,
2584 12363 : state.dataLoopNodes->Node(this->ZoneAir.InletNodeNum).HumRat,
2585 : RoutineName);
2586 12363 : this->ZoneAir.InletCp = Psychrometrics::PsyCpAirFnW(state.dataLoopNodes->Node(this->ZoneAir.InletNodeNum).HumRat);
2587 12363 : this->ZoneAir.InletTemp = state.dataLoopNodes->Node(this->ZoneAir.InletNodeNum).Temp;
2588 12363 : this->ZoneAir.InletHumRat = state.dataLoopNodes->Node(this->ZoneAir.InletNodeNum).HumRat;
2589 :
2590 12363 : if (this->SourceAir.InletNodeNum > 0) {
2591 12363 : this->SourceAir.InletRho = Psychrometrics::PsyRhoAirFnPbTdbW(state,
2592 12363 : state.dataEnvrn->OutBaroPress,
2593 12363 : state.dataLoopNodes->Node(this->SourceAir.InletNodeNum).Temp,
2594 12363 : state.dataLoopNodes->Node(this->SourceAir.InletNodeNum).HumRat,
2595 : RoutineName);
2596 12363 : this->SourceAir.InletCp = Psychrometrics::PsyCpAirFnW(state.dataLoopNodes->Node(this->SourceAir.InletNodeNum).HumRat);
2597 12363 : this->SourceAir.InletTemp = state.dataLoopNodes->Node(this->SourceAir.InletNodeNum).Temp;
2598 12363 : this->SourceAir.InletHumRat = state.dataLoopNodes->Node(this->SourceAir.InletNodeNum).HumRat;
2599 : }
2600 :
2601 12363 : if (this->NumPlantConnections > 0) {
2602 0 : for (int loop = 1; loop <= this->NumPlantConnections; ++loop) {
2603 0 : this->Loop(loop).InletRho =
2604 0 : state.dataPlnt->PlantLoop(this->Loop(loop).plantLoc.loopNum)
2605 0 : .glycol->getDensity(state, state.dataLoopNodes->Node(this->Loop(loop).InletNodeNum).Temp, RoutineName);
2606 0 : this->Loop(loop).InletCp =
2607 0 : state.dataPlnt->PlantLoop(this->Loop(loop).plantLoc.loopNum)
2608 0 : .glycol->getSpecificHeat(state, state.dataLoopNodes->Node(this->Loop(loop).InletNodeNum).Temp, RoutineName);
2609 0 : this->Loop(loop).InletTemp = state.dataLoopNodes->Node(this->Loop(loop).InletNodeNum).Temp;
2610 0 : this->Loop(loop).InletMassFlowRate = state.dataLoopNodes->Node(this->Loop(loop).InletNodeNum).MassFlowRate;
2611 : }
2612 : }
2613 12363 : }
2614 :
2615 0 : void UserAirTerminalComponentStruct::initialize(EnergyPlusData &state, int const ZoneNum)
2616 : {
2617 :
2618 : // SUBROUTINE INFORMATION:
2619 : // AUTHOR B. Griffith
2620 : // DATE WRITTEN March 2012
2621 : // MODIFIED na
2622 : // RE-ENGINEERED na
2623 :
2624 : static constexpr std::string_view RoutineName("InitAirTerminalUserDefined");
2625 :
2626 0 : if (this->myOneTimeFlag) {
2627 0 : if (this->NumPlantConnections > 0) {
2628 0 : for (int loop = 1; loop <= this->NumPlantConnections; ++loop) {
2629 0 : bool errFlag = false;
2630 0 : PlantUtilities::ScanPlantLoopsForObject(state,
2631 : this->Name,
2632 : DataPlant::PlantEquipmentType::AirTerminalUserDefined,
2633 0 : this->Loop(loop).plantLoc,
2634 : errFlag,
2635 : _,
2636 : _,
2637 : _,
2638 0 : this->Loop(loop).InletNodeNum,
2639 0 : ObjexxFCL::Optional_int_const());
2640 0 : if (errFlag) {
2641 0 : ShowFatalError(state, "InitPlantUserComponent: Program terminated due to previous condition(s).");
2642 : }
2643 : // set user input for flow priority
2644 0 : DataPlant::CompData::getPlantComponent(state, this->Loop(loop).plantLoc).FlowPriority = this->Loop(loop).FlowPriority;
2645 :
2646 : // set user input for how loads served
2647 0 : DataPlant::CompData::getPlantComponent(state, this->Loop(loop).plantLoc).HowLoadServed = this->Loop(loop).HowLoadServed;
2648 : }
2649 : }
2650 0 : this->myOneTimeFlag = false;
2651 : }
2652 : // fill internal variable targets
2653 0 : this->RemainingOutputToHeatingSP = state.dataZoneEnergyDemand->ZoneSysEnergyDemand(ZoneNum).RemainingOutputReqToHeatSP;
2654 0 : this->RemainingOutputToCoolingSP = state.dataZoneEnergyDemand->ZoneSysEnergyDemand(ZoneNum).RemainingOutputReqToCoolSP;
2655 0 : this->RemainingOutputReqToDehumidSP = state.dataZoneEnergyDemand->ZoneSysMoistureDemand(ZoneNum).RemainingOutputReqToDehumidSP;
2656 0 : this->RemainingOutputReqToHumidSP = state.dataZoneEnergyDemand->ZoneSysMoistureDemand(ZoneNum).RemainingOutputReqToHumidSP;
2657 :
2658 0 : this->AirLoop.InletRho = Psychrometrics::PsyRhoAirFnPbTdbW(state,
2659 0 : state.dataEnvrn->OutBaroPress,
2660 0 : state.dataLoopNodes->Node(this->AirLoop.InletNodeNum).Temp,
2661 0 : state.dataLoopNodes->Node(this->AirLoop.InletNodeNum).HumRat,
2662 : RoutineName);
2663 0 : this->AirLoop.InletCp = Psychrometrics::PsyCpAirFnW(state.dataLoopNodes->Node(this->AirLoop.InletNodeNum).HumRat);
2664 0 : this->AirLoop.InletTemp = state.dataLoopNodes->Node(this->AirLoop.InletNodeNum).Temp;
2665 0 : this->AirLoop.InletHumRat = state.dataLoopNodes->Node(this->AirLoop.InletNodeNum).HumRat;
2666 :
2667 0 : if (this->SourceAir.InletNodeNum > 0) {
2668 0 : this->SourceAir.InletRho = Psychrometrics::PsyRhoAirFnPbTdbW(state,
2669 0 : state.dataEnvrn->OutBaroPress,
2670 0 : state.dataLoopNodes->Node(this->SourceAir.InletNodeNum).Temp,
2671 0 : state.dataLoopNodes->Node(this->SourceAir.InletNodeNum).HumRat,
2672 : RoutineName);
2673 0 : this->SourceAir.InletCp = Psychrometrics::PsyCpAirFnW(state.dataLoopNodes->Node(this->SourceAir.InletNodeNum).HumRat);
2674 0 : this->SourceAir.InletTemp = state.dataLoopNodes->Node(this->SourceAir.InletNodeNum).Temp;
2675 0 : this->SourceAir.InletHumRat = state.dataLoopNodes->Node(this->SourceAir.InletNodeNum).HumRat;
2676 : }
2677 :
2678 0 : if (this->NumPlantConnections > 0) {
2679 0 : for (int loop = 1; loop <= this->NumPlantConnections; ++loop) {
2680 0 : this->Loop(loop).InletRho =
2681 0 : state.dataPlnt->PlantLoop(this->Loop(loop).plantLoc.loopNum)
2682 0 : .glycol->getDensity(state, state.dataLoopNodes->Node(this->Loop(loop).InletNodeNum).Temp, RoutineName);
2683 0 : this->Loop(loop).InletCp =
2684 0 : state.dataPlnt->PlantLoop(this->Loop(loop).plantLoc.loopNum)
2685 0 : .glycol->getSpecificHeat(state, state.dataLoopNodes->Node(this->Loop(loop).InletNodeNum).Temp, RoutineName);
2686 0 : this->Loop(loop).InletTemp = state.dataLoopNodes->Node(this->Loop(loop).InletNodeNum).Temp;
2687 0 : this->Loop(loop).InletMassFlowRate = state.dataLoopNodes->Node(this->Loop(loop).InletNodeNum).MassFlowRate;
2688 : }
2689 : }
2690 0 : }
2691 :
2692 0 : void UserPlantComponentStruct::report(EnergyPlusData &state, int const LoopNum)
2693 : {
2694 :
2695 : // SUBROUTINE INFORMATION:
2696 : // AUTHOR B. Griffith
2697 : // DATE WRITTEN Feb. 2012
2698 : // MODIFIED na
2699 : // RE-ENGINEERED na
2700 :
2701 : // PURPOSE OF THIS SUBROUTINE:
2702 : // report model results
2703 :
2704 : // METHODOLOGY EMPLOYED:
2705 : // copy actuated values to structures elsewhere in program.
2706 :
2707 0 : PlantUtilities::SafeCopyPlantNode(state, this->Loop(LoopNum).InletNodeNum, this->Loop(LoopNum).OutletNodeNum);
2708 :
2709 : // unload Actuators to node data structure
2710 :
2711 0 : state.dataLoopNodes->Node(this->Loop(LoopNum).OutletNodeNum).Temp = this->Loop(LoopNum).OutletTemp;
2712 :
2713 : // make mass flow requests, just this loop
2714 0 : PlantUtilities::SetComponentFlowRate(state,
2715 0 : this->Loop(LoopNum).MassFlowRateRequest,
2716 0 : this->Loop(LoopNum).InletNodeNum,
2717 0 : this->Loop(LoopNum).OutletNodeNum,
2718 0 : this->Loop(LoopNum).plantLoc);
2719 :
2720 0 : if (this->Air.OutletNodeNum > 0) {
2721 0 : state.dataLoopNodes->Node(this->Air.OutletNodeNum).Temp = this->Air.OutletTemp;
2722 0 : state.dataLoopNodes->Node(this->Air.OutletNodeNum).HumRat = this->Air.OutletHumRat;
2723 0 : state.dataLoopNodes->Node(this->Air.OutletNodeNum).MassFlowRate = this->Air.OutletMassFlowRate;
2724 0 : state.dataLoopNodes->Node(this->Air.OutletNodeNum).Enthalpy = Psychrometrics::PsyHFnTdbW(this->Air.OutletTemp, this->Air.OutletHumRat);
2725 : }
2726 :
2727 0 : if (this->Water.SuppliedByWaterSystem) {
2728 0 : state.dataWaterData->WaterStorage(this->Water.SupplyTankID).VdotRequestDemand(this->Water.SupplyTankDemandARRID) =
2729 0 : this->Water.SupplyVdotRequest;
2730 : }
2731 :
2732 0 : if (this->Water.CollectsToWaterSystem) {
2733 0 : state.dataWaterData->WaterStorage(this->Water.CollectionTankID).VdotAvailSupply(this->Water.CollectionTankSupplyARRID) =
2734 0 : this->Water.CollectedVdot;
2735 : }
2736 :
2737 0 : if (this->Loop(LoopNum).HowLoadServed == DataPlant::HowMet::ByNominalCapLowOutLimit) {
2738 0 : DataPlant::CompData::getPlantComponent(state, this->Loop(LoopNum).plantLoc).MinOutletTemp = this->Loop(LoopNum).LowOutTempLimit;
2739 : }
2740 :
2741 0 : if (this->Loop(LoopNum).HowLoadServed == DataPlant::HowMet::ByNominalCapHiOutLimit) {
2742 0 : DataPlant::CompData::getPlantComponent(state, this->Loop(LoopNum).plantLoc).MaxOutletTemp = this->Loop(LoopNum).HiOutTempLimit;
2743 : }
2744 0 : }
2745 0 : void UserPlantComponentStruct::oneTimeInit(EnergyPlusData &state)
2746 : {
2747 :
2748 0 : if (this->myOneTimeFlag) {
2749 : // locate the connections to the plant loops
2750 0 : for (int ConnectionNum = 1; ConnectionNum <= this->NumPlantConnections; ++ConnectionNum) {
2751 0 : bool errFlag = false;
2752 0 : PlantUtilities::ScanPlantLoopsForObject(state,
2753 : this->Name,
2754 : DataPlant::PlantEquipmentType::PlantComponentUserDefined,
2755 0 : this->Loop(ConnectionNum).plantLoc,
2756 : errFlag,
2757 : _,
2758 : _,
2759 : _,
2760 0 : this->Loop(ConnectionNum).InletNodeNum,
2761 0 : ObjexxFCL::Optional_int_const());
2762 0 : if (errFlag) {
2763 0 : ShowFatalError(state, "InitPlantUserComponent: Program terminated due to previous condition(s).");
2764 : }
2765 :
2766 : // set user input for flow priority
2767 0 : DataPlant::CompData::getPlantComponent(state, this->Loop(ConnectionNum).plantLoc).FlowPriority =
2768 0 : this->Loop(ConnectionNum).FlowPriority;
2769 :
2770 : // set user input for how loads served
2771 0 : DataPlant::CompData::getPlantComponent(state, this->Loop(ConnectionNum).plantLoc).HowLoadServed =
2772 0 : this->Loop(ConnectionNum).HowLoadServed;
2773 : }
2774 :
2775 0 : this->myOneTimeFlag = false;
2776 : }
2777 0 : }
2778 :
2779 0 : void UserCoilComponentStruct::report(EnergyPlusData &state)
2780 : {
2781 :
2782 : // SUBROUTINE INFORMATION:
2783 : // AUTHOR B. Griffith
2784 : // DATE WRITTEN Feb. 2012
2785 : // MODIFIED na
2786 : // RE-ENGINEERED na
2787 :
2788 : // PURPOSE OF THIS SUBROUTINE:
2789 : // report model outputs
2790 :
2791 0 : for (int loop = 1; loop <= this->NumAirConnections; ++loop) {
2792 0 : if (this->Air(loop).OutletNodeNum > 0) {
2793 0 : state.dataLoopNodes->Node(this->Air(loop).OutletNodeNum).Temp = this->Air(loop).OutletTemp;
2794 0 : state.dataLoopNodes->Node(this->Air(loop).OutletNodeNum).HumRat = this->Air(loop).OutletHumRat;
2795 0 : state.dataLoopNodes->Node(this->Air(loop).OutletNodeNum).MassFlowRate = this->Air(loop).OutletMassFlowRate;
2796 0 : state.dataLoopNodes->Node(this->Air(loop).OutletNodeNum).Enthalpy =
2797 0 : Psychrometrics::PsyHFnTdbW(this->Air(loop).OutletTemp, this->Air(loop).OutletHumRat);
2798 :
2799 0 : state.dataLoopNodes->Node(this->Air(loop).OutletNodeNum).MassFlowRateMinAvail =
2800 0 : state.dataLoopNodes->Node(this->Air(loop).InletNodeNum).MassFlowRateMinAvail;
2801 0 : state.dataLoopNodes->Node(this->Air(loop).OutletNodeNum).MassFlowRateMaxAvail =
2802 0 : state.dataLoopNodes->Node(this->Air(loop).InletNodeNum).MassFlowRateMaxAvail;
2803 : }
2804 : }
2805 :
2806 0 : if (this->PlantIsConnected) {
2807 : // make mass flow requests
2808 0 : PlantUtilities::SetComponentFlowRate(
2809 0 : state, this->Loop.MassFlowRateRequest, this->Loop.InletNodeNum, this->Loop.OutletNodeNum, this->Loop.plantLoc);
2810 0 : PlantUtilities::SafeCopyPlantNode(state, this->Loop.InletNodeNum, this->Loop.OutletNodeNum);
2811 : // unload Actuators to node data structure
2812 0 : state.dataLoopNodes->Node(this->Loop.OutletNodeNum).Temp = this->Loop.OutletTemp;
2813 : }
2814 :
2815 0 : if (this->Water.SuppliedByWaterSystem) {
2816 0 : state.dataWaterData->WaterStorage(this->Water.SupplyTankID).VdotRequestDemand(this->Water.SupplyTankDemandARRID) =
2817 0 : this->Water.SupplyVdotRequest;
2818 : }
2819 :
2820 0 : if (this->Water.CollectsToWaterSystem) {
2821 0 : state.dataWaterData->WaterStorage(this->Water.CollectionTankID).VdotAvailSupply(this->Water.CollectionTankSupplyARRID) =
2822 0 : this->Water.CollectedVdot;
2823 : }
2824 0 : }
2825 :
2826 12291 : void UserZoneHVACForcedAirComponentStruct::report(EnergyPlusData &state)
2827 : {
2828 :
2829 : // SUBROUTINE INFORMATION:
2830 : // AUTHOR B. Griffith
2831 : // DATE WRITTEN Feb. 2012
2832 : // MODIFIED na
2833 : // RE-ENGINEERED na
2834 :
2835 : // PURPOSE OF THIS SUBROUTINE:
2836 : // report model outputs
2837 :
2838 12291 : state.dataLoopNodes->Node(this->ZoneAir.InletNodeNum).MassFlowRate = this->ZoneAir.InletMassFlowRate;
2839 :
2840 12291 : state.dataLoopNodes->Node(this->ZoneAir.OutletNodeNum).Temp = this->ZoneAir.OutletTemp;
2841 12291 : state.dataLoopNodes->Node(this->ZoneAir.OutletNodeNum).HumRat = this->ZoneAir.OutletHumRat;
2842 12291 : state.dataLoopNodes->Node(this->ZoneAir.OutletNodeNum).MassFlowRate = this->ZoneAir.OutletMassFlowRate;
2843 12291 : state.dataLoopNodes->Node(this->ZoneAir.OutletNodeNum).Enthalpy =
2844 12291 : Psychrometrics::PsyHFnTdbW(this->ZoneAir.OutletTemp, this->ZoneAir.OutletHumRat);
2845 :
2846 12291 : if (this->SourceAir.OutletNodeNum > 0) {
2847 12291 : state.dataLoopNodes->Node(this->SourceAir.OutletNodeNum).Temp = this->SourceAir.OutletTemp;
2848 12291 : state.dataLoopNodes->Node(this->SourceAir.OutletNodeNum).HumRat = this->SourceAir.OutletHumRat;
2849 12291 : state.dataLoopNodes->Node(this->SourceAir.OutletNodeNum).MassFlowRate = this->SourceAir.OutletMassFlowRate;
2850 12291 : state.dataLoopNodes->Node(this->SourceAir.OutletNodeNum).Enthalpy =
2851 12291 : Psychrometrics::PsyHFnTdbW(this->SourceAir.OutletTemp, this->SourceAir.OutletHumRat);
2852 : }
2853 :
2854 12291 : if (this->NumPlantConnections > 0) {
2855 0 : for (int loop = 1; loop <= this->NumPlantConnections; ++loop) {
2856 : // make mass flow requests
2857 0 : PlantUtilities::SetComponentFlowRate(state,
2858 0 : this->Loop(loop).MassFlowRateRequest,
2859 0 : this->Loop(loop).InletNodeNum,
2860 0 : this->Loop(loop).OutletNodeNum,
2861 0 : this->Loop(loop).plantLoc);
2862 0 : PlantUtilities::SafeCopyPlantNode(state, this->Loop(loop).InletNodeNum, this->Loop(loop).OutletNodeNum);
2863 : // unload Actuators to node data structure
2864 0 : state.dataLoopNodes->Node(this->Loop(loop).OutletNodeNum).Temp = this->Loop(loop).OutletTemp;
2865 : }
2866 : }
2867 :
2868 12291 : if (this->Water.SuppliedByWaterSystem) {
2869 0 : state.dataWaterData->WaterStorage(this->Water.SupplyTankID).VdotRequestDemand(this->Water.SupplyTankDemandARRID) =
2870 0 : this->Water.SupplyVdotRequest;
2871 : }
2872 :
2873 12291 : if (this->Water.CollectsToWaterSystem) {
2874 0 : state.dataWaterData->WaterStorage(this->Water.CollectionTankID).VdotAvailSupply(this->Water.CollectionTankSupplyARRID) =
2875 0 : this->Water.CollectedVdot;
2876 : }
2877 12291 : }
2878 :
2879 0 : void UserAirTerminalComponentStruct::report(EnergyPlusData &state)
2880 : {
2881 :
2882 : // SUBROUTINE INFORMATION:
2883 : // AUTHOR B. Griffith
2884 : // DATE WRITTEN March 2012
2885 : // MODIFIED na
2886 : // RE-ENGINEERED na
2887 :
2888 0 : state.dataLoopNodes->Node(this->AirLoop.InletNodeNum).MassFlowRate = this->AirLoop.InletMassFlowRate;
2889 :
2890 0 : state.dataLoopNodes->Node(this->AirLoop.OutletNodeNum).Temp = this->AirLoop.OutletTemp;
2891 0 : state.dataLoopNodes->Node(this->AirLoop.OutletNodeNum).HumRat = this->AirLoop.OutletHumRat;
2892 0 : state.dataLoopNodes->Node(this->AirLoop.OutletNodeNum).MassFlowRate = this->AirLoop.OutletMassFlowRate;
2893 0 : state.dataLoopNodes->Node(this->AirLoop.OutletNodeNum).Enthalpy =
2894 0 : Psychrometrics::PsyHFnTdbW(this->AirLoop.OutletTemp, this->AirLoop.OutletHumRat);
2895 0 : if (this->SourceAir.OutletNodeNum > 0) {
2896 0 : state.dataLoopNodes->Node(this->SourceAir.OutletNodeNum).Temp = this->SourceAir.OutletTemp;
2897 0 : state.dataLoopNodes->Node(this->SourceAir.OutletNodeNum).HumRat = this->SourceAir.OutletHumRat;
2898 0 : state.dataLoopNodes->Node(this->SourceAir.OutletNodeNum).MassFlowRate = this->SourceAir.OutletMassFlowRate;
2899 0 : state.dataLoopNodes->Node(this->SourceAir.OutletNodeNum).Enthalpy =
2900 0 : Psychrometrics::PsyHFnTdbW(this->SourceAir.OutletTemp, this->SourceAir.OutletHumRat);
2901 : }
2902 :
2903 0 : if (this->NumPlantConnections > 0) {
2904 0 : for (int loop = 1; loop <= this->NumPlantConnections; ++loop) {
2905 : // make mass flow requests
2906 0 : PlantUtilities::SetComponentFlowRate(state,
2907 0 : this->Loop(loop).MassFlowRateRequest,
2908 0 : this->Loop(loop).InletNodeNum,
2909 0 : this->Loop(loop).OutletNodeNum,
2910 0 : this->Loop(loop).plantLoc);
2911 0 : PlantUtilities::SafeCopyPlantNode(state, this->Loop(loop).InletNodeNum, this->Loop(loop).OutletNodeNum);
2912 : // unload Actuators to node data structure
2913 0 : state.dataLoopNodes->Node(this->Loop(loop).OutletNodeNum).Temp = this->Loop(loop).OutletTemp;
2914 : }
2915 : }
2916 :
2917 0 : if (this->Water.SuppliedByWaterSystem) {
2918 0 : state.dataWaterData->WaterStorage(this->Water.SupplyTankID).VdotRequestDemand(this->Water.SupplyTankDemandARRID) =
2919 0 : this->Water.SupplyVdotRequest;
2920 : }
2921 :
2922 0 : if (this->Water.CollectsToWaterSystem) {
2923 0 : state.dataWaterData->WaterStorage(this->Water.CollectionTankID).VdotAvailSupply(this->Water.CollectionTankSupplyARRID) =
2924 0 : this->Water.CollectedVdot;
2925 : }
2926 0 : }
2927 :
2928 0 : void GetUserDefinedCoilIndex(
2929 : EnergyPlusData &state, std::string const &CoilName, int &CoilIndex, bool &ErrorsFound, std::string const &CurrentModuleObject)
2930 : {
2931 :
2932 : // SUBROUTINE INFORMATION:
2933 : // AUTHOR Richard Raustad
2934 : // DATE WRITTEN August 2013
2935 : // MODIFIED na
2936 : // RE-ENGINEERED na
2937 :
2938 : // PURPOSE OF THIS SUBROUTINE:
2939 : // This subroutine sets an index for a given user defined Cooling Coil -- issues error message if that
2940 : // coil is not a legal user defined Cooling Coil.
2941 :
2942 : // Obtains and allocates TESCoil related parameters from input file
2943 0 : if (state.dataUserDefinedComponents->GetInput) { // First time subroutine has been called, get input data
2944 0 : GetUserDefinedComponents(state);
2945 0 : state.dataUserDefinedComponents->GetInput = false; // Set logic flag to disallow getting the input data on future calls to this subroutine
2946 : }
2947 :
2948 0 : if (state.dataUserDefinedComponents->NumUserCoils > 0) {
2949 0 : CoilIndex = Util::FindItem(CoilName, state.dataUserDefinedComponents->UserCoil, state.dataUserDefinedComponents->NumUserCoils);
2950 : } else {
2951 0 : CoilIndex = 0;
2952 : }
2953 :
2954 0 : if (CoilIndex == 0) {
2955 0 : ShowSevereError(state, format("{}, GetUserDefinedCoilIndex: User Defined Cooling Coil not found={}", CurrentModuleObject, CoilName));
2956 0 : ErrorsFound = true;
2957 : }
2958 0 : }
2959 :
2960 0 : void GetUserDefinedCoilAirInletNode(
2961 : EnergyPlusData &state, std::string const &CoilName, int &CoilAirInletNode, bool &ErrorsFound, std::string const &CurrentModuleObject)
2962 : {
2963 :
2964 : // SUBROUTINE INFORMATION:
2965 : // AUTHOR Richard Raustad
2966 : // DATE WRITTEN July 2015
2967 : // MODIFIED na
2968 : // RE-ENGINEERED na
2969 :
2970 : // PURPOSE OF THIS SUBROUTINE:
2971 : // This subroutine gets a given user defined Cooling Coil's air inlet node -- issues error message if that
2972 : // coil is not a legal user defined Cooling Coil and sets air node to 0, otherwise, returns inlet air node number.
2973 :
2974 : int CoilIndex;
2975 :
2976 : // Obtains and allocates TESCoil related parameters from input file
2977 0 : if (state.dataUserDefinedComponents->GetInput) { // First time subroutine has been called, get input data
2978 0 : GetUserDefinedComponents(state);
2979 0 : state.dataUserDefinedComponents->GetInput = false; // Set logic flag to disallow getting the input data on future calls to this subroutine
2980 : }
2981 :
2982 0 : if (state.dataUserDefinedComponents->NumUserCoils > 0) {
2983 0 : CoilIndex = Util::FindItem(CoilName, state.dataUserDefinedComponents->UserCoil, state.dataUserDefinedComponents->NumUserCoils);
2984 : } else {
2985 0 : CoilIndex = 0;
2986 : }
2987 :
2988 0 : if (CoilIndex == 0) {
2989 0 : ShowSevereError(state, format("{}, GetTESCoilIndex: TES Cooling Coil not found={}", CurrentModuleObject, CoilName));
2990 0 : ErrorsFound = true;
2991 0 : CoilAirInletNode = 0;
2992 : } else {
2993 0 : CoilAirInletNode = state.dataUserDefinedComponents->UserCoil(CoilIndex).Air(1).InletNodeNum;
2994 : }
2995 0 : }
2996 :
2997 0 : void GetUserDefinedCoilAirOutletNode(
2998 : EnergyPlusData &state, std::string const &CoilName, int &CoilAirOutletNode, bool &ErrorsFound, std::string const &CurrentModuleObject)
2999 : {
3000 :
3001 : // SUBROUTINE INFORMATION:
3002 : // AUTHOR Richard Raustad
3003 : // DATE WRITTEN July 2015
3004 : // MODIFIED na
3005 : // RE-ENGINEERED na
3006 :
3007 : // PURPOSE OF THIS SUBROUTINE:
3008 : // This subroutine gets a given user defined Cooling Coil's air outlet node -- issues error message if that
3009 : // coil is not a legal user defined Cooling Coil and sets air node to 0, otherwise, returns outlet air node number.
3010 :
3011 : int CoilIndex;
3012 :
3013 : // Obtains and allocates TESCoil related parameters from input file
3014 0 : if (state.dataUserDefinedComponents->GetInput) { // First time subroutine has been called, get input data
3015 0 : GetUserDefinedComponents(state);
3016 0 : state.dataUserDefinedComponents->GetInput = false; // Set logic flag to disallow getting the input data on future calls to this subroutine
3017 : }
3018 :
3019 0 : if (state.dataUserDefinedComponents->NumUserCoils > 0) {
3020 0 : CoilIndex = Util::FindItem(CoilName, state.dataUserDefinedComponents->UserCoil, state.dataUserDefinedComponents->NumUserCoils);
3021 : } else {
3022 0 : CoilIndex = 0;
3023 : }
3024 :
3025 0 : if (CoilIndex == 0) {
3026 0 : ShowSevereError(state, format("{}, GetTESCoilIndex: TES Cooling Coil not found={}", CurrentModuleObject, CoilName));
3027 0 : ErrorsFound = true;
3028 0 : CoilAirOutletNode = 0;
3029 : } else {
3030 0 : CoilAirOutletNode = state.dataUserDefinedComponents->UserCoil(CoilIndex).Air(1).OutletNodeNum;
3031 : }
3032 0 : }
3033 :
3034 : } // namespace UserDefinedComponents
3035 :
3036 : } // namespace EnergyPlus
|