LCOV - code coverage report
Current view: top level - EnergyPlus - UserDefinedComponents.cc (source / functions) Coverage Total Hit
Test: lcov.output.filtered Lines: 59.9 % 1634 979
Test Date: 2025-06-02 07:23:51 Functions: 85.7 % 21 18

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

Generated by: LCOV version 2.0-1