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