LCOV - code coverage report
Current view: top level - EnergyPlus - UserDefinedComponents.cc (source / functions) Coverage Total Hit
Test: lcov.output.filtered Lines: 20.4 % 1618 330
Test Date: 2025-05-22 16:09:37 Functions: 23.8 % 21 5

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

Generated by: LCOV version 2.0-1