LCOV - code coverage report
Current view: top level - EnergyPlus - ZoneAirLoopEquipmentManager.cc (source / functions) Coverage Total Hit
Test: lcov.output.filtered Lines: 89.0 % 335 298
Test Date: 2025-06-02 07:23:51 Functions: 100.0 % 5 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              : // ObjexxFCL Headers
      49              : #include <ObjexxFCL/Array1D.hh>
      50              : 
      51              : // EnergyPlus Headers
      52              : #include <EnergyPlus/AirTerminalUnit.hh>
      53              : #include <EnergyPlus/BranchNodeConnections.hh>
      54              : #include <EnergyPlus/Data/EnergyPlusData.hh>
      55              : #include <EnergyPlus/DataAirLoop.hh>
      56              : #include <EnergyPlus/DataDefineEquip.hh>
      57              : #include <EnergyPlus/DataHeatBalance.hh>
      58              : #include <EnergyPlus/DataLoopNode.hh>
      59              : #include <EnergyPlus/DataSizing.hh>
      60              : #include <EnergyPlus/DataZoneEquipment.hh>
      61              : #include <EnergyPlus/DualDuct.hh>
      62              : #include <EnergyPlus/GeneralRoutines.hh>
      63              : #include <EnergyPlus/HVACCooledBeam.hh>
      64              : #include <EnergyPlus/HVACFourPipeBeam.hh>
      65              : #include <EnergyPlus/HVACSingleDuctInduc.hh>
      66              : #include <EnergyPlus/InputProcessing/InputProcessor.hh>
      67              : #include <EnergyPlus/NodeInputManager.hh>
      68              : #include <EnergyPlus/OutputProcessor.hh>
      69              : #include <EnergyPlus/PoweredInductionUnits.hh>
      70              : #include <EnergyPlus/Psychrometrics.hh>
      71              : #include <EnergyPlus/SingleDuct.hh>
      72              : #include <EnergyPlus/UserDefinedComponents.hh>
      73              : #include <EnergyPlus/UtilityRoutines.hh>
      74              : #include <EnergyPlus/ZoneAirLoopEquipmentManager.hh>
      75              : 
      76              : namespace EnergyPlus {
      77              : 
      78              : namespace ZoneAirLoopEquipmentManager {
      79              :     // Module containing the routines dealing with the ZoneAirLoopEquipmentManager
      80              : 
      81              :     // MODULE INFORMATION:
      82              :     //       AUTHOR         Russ Taylor
      83              :     //       DATE WRITTEN   May 1997
      84              : 
      85              :     using namespace DataDefineEquip;
      86              : 
      87              :     // constexpr std::array<std::string_view, static_cast<int>(ZnAirLoopEquipType::Num)> ZnAirLoopEquipTypeNames = {
      88              :     //     "AirTerminal:DualDuct:ConstantVolume",
      89              :     //     "AirTerminal:DualDuct:VAV",
      90              :     //     "AirTerminal:SingleDuct:VAV:Reheat",
      91              :     //     "AirTerminal:SingleDuct:VAV:NoReheat",
      92              :     //     "AirTerminal:SingleDuct:ConstantVolume:Reheat",
      93              :     //     "AirTerminal:SingleDuct:ConstantVolume:NoReheat",
      94              :     //     "AirTerminal:SingleDuct:SeriesPIU:Reheat",
      95              :     //     "AirTerminal:SingleDuct:ParallelPIU:Reheat",
      96              :     //     "AirTerminal:SingleDuct:ConstantVolume:FourPipeInduction",
      97              :     //     "AirTerminal:SingleDuct:VAV:Reheat:VariableSpeedFan",
      98              :     //     "AirTerminal:SingleDuct:VAV:HeatAndCool:Reheat",
      99              :     //     "AirTerminal:SingleDuct:VAV:HeatAndCool:NoReheat",
     100              :     //     "AirTerminal:SingleDuct:ConstantVolume:CooledBeam",
     101              :     //     "AirTerminal:DualDuct:VAV:OutdoorAir",
     102              :     //     "AirTerminal:SingleDuct:UserDefined",
     103              :     //     "AirTerminal:SingleDuct:Mixer",
     104              :     //     "AirTerminal:SingleDuct:ConstantVolume:FourPipeBeam"};
     105              : 
     106              :     constexpr std::array<std::string_view, static_cast<int>(ZnAirLoopEquipType::Num)> ZnAirLoopEquipTypeNamesUC = {
     107              :         "AIRTERMINAL:DUALDUCT:CONSTANTVOLUME",
     108              :         "AIRTERMINAL:DUALDUCT:VAV",
     109              :         "AIRTERMINAL:SINGLEDUCT:VAV:REHEAT",
     110              :         "AIRTERMINAL:SINGLEDUCT:VAV:NOREHEAT",
     111              :         "AIRTERMINAL:SINGLEDUCT:CONSTANTVOLUME:REHEAT",
     112              :         "AIRTERMINAL:SINGLEDUCT:CONSTANTVOLUME:NOREHEAT",
     113              :         "AIRTERMINAL:SINGLEDUCT:SERIESPIU:REHEAT",
     114              :         "AIRTERMINAL:SINGLEDUCT:PARALLELPIU:REHEAT",
     115              :         "AIRTERMINAL:SINGLEDUCT:CONSTANTVOLUME:FOURPIPEINDUCTION",
     116              :         "AIRTERMINAL:SINGLEDUCT:VAV:REHEAT:VARIABLESPEEDFAN",
     117              :         "AIRTERMINAL:SINGLEDUCT:VAV:HEATANDCOOL:REHEAT",
     118              :         "AIRTERMINAL:SINGLEDUCT:VAV:HEATANDCOOL:NOREHEAT",
     119              :         "AIRTERMINAL:SINGLEDUCT:CONSTANTVOLUME:COOLEDBEAM",
     120              :         "AIRTERMINAL:DUALDUCT:VAV:OUTDOORAIR",
     121              :         "AIRTERMINAL:SINGLEDUCT:USERDEFINED",
     122              :         "AIRTERMINAL:SINGLEDUCT:MIXER",
     123              :         "AIRTERMINAL:SINGLEDUCT:CONSTANTVOLUME:FOURPIPEBEAM"};
     124              : 
     125     38668215 :     void ManageZoneAirLoopEquipment(EnergyPlusData &state,
     126              :                                     std::string const &ZoneAirLoopEquipName,
     127              :                                     bool const FirstHVACIteration,
     128              :                                     Real64 &SysOutputProvided,
     129              :                                     Real64 &NonAirSysOutput,
     130              :                                     Real64 &LatOutputProvided, // Latent add/removal supplied by air dist unit (kg/s), dehumid = negative
     131              :                                     int const ControlledZoneNum,
     132              :                                     int &CompIndex)
     133              :     {
     134              :         // SUBROUTINE INFORMATION:
     135              :         //       AUTHOR         Russ Taylor
     136              :         //       DATE WRITTEN   May 1997
     137              :         //       MODIFIED       Don Shirey, Aug 2009 (LatOutputProvided)
     138              : 
     139              :         // PURPOSE OF THIS SUBROUTINE:
     140              :         // Calls the zone thermal control simulations and the interfaces
     141              :         // (water-air, refrigerant-air, steam-air, electric-electric,
     142              :         // water-water, etc)
     143              : 
     144              :         int AirDistUnitNum;
     145              : 
     146              :         // Beginning of Code
     147              : 
     148              :         // make sure the input data is read in only once
     149     38668215 :         if (state.dataZoneAirLoopEquipmentManager->GetAirDistUnitsFlag) {
     150          541 :             GetZoneAirLoopEquipment(state);
     151          541 :             state.dataZoneAirLoopEquipmentManager->GetAirDistUnitsFlag = false;
     152              :         }
     153              : 
     154              :         // Find the correct Zone Air Distribution Unit Equipment
     155     38668215 :         if (CompIndex == 0) {
     156         3806 :             AirDistUnitNum = Util::FindItemInList(ZoneAirLoopEquipName, state.dataDefineEquipment->AirDistUnit);
     157         3806 :             if (AirDistUnitNum == 0) {
     158            0 :                 ShowFatalError(state, format("ManageZoneAirLoopEquipment: Unit not found={}", ZoneAirLoopEquipName));
     159              :             }
     160         3806 :             CompIndex = AirDistUnitNum;
     161              :         } else {
     162     38664409 :             AirDistUnitNum = CompIndex;
     163     38664409 :             if (AirDistUnitNum > (int)state.dataDefineEquipment->AirDistUnit.size() || AirDistUnitNum < 1) {
     164            0 :                 ShowFatalError(state,
     165            0 :                                format("ManageZoneAirLoopEquipment:  Invalid CompIndex passed={}, Number of Units={}, Entered Unit name={}",
     166              :                                       AirDistUnitNum,
     167            0 :                                       (int)state.dataDefineEquipment->AirDistUnit.size(),
     168              :                                       ZoneAirLoopEquipName));
     169              :             }
     170     38664409 :             if (ZoneAirLoopEquipName != state.dataDefineEquipment->AirDistUnit(AirDistUnitNum).Name) {
     171            0 :                 ShowFatalError(state,
     172            0 :                                format("ManageZoneAirLoopEquipment: Invalid CompIndex passed={}, Unit name={}, stored Unit Name for that index={}",
     173              :                                       AirDistUnitNum,
     174              :                                       ZoneAirLoopEquipName,
     175            0 :                                       state.dataDefineEquipment->AirDistUnit(AirDistUnitNum).Name));
     176              :             }
     177              :         }
     178     38668215 :         state.dataSize->CurTermUnitSizingNum = state.dataDefineEquipment->AirDistUnit(AirDistUnitNum).TermUnitSizingNum;
     179     38668215 :         InitZoneAirLoopEquipment(state, AirDistUnitNum, ControlledZoneNum);
     180     38668215 :         InitZoneAirLoopEquipmentTimeStep(state, AirDistUnitNum);
     181              : 
     182     38668215 :         SimZoneAirLoopEquipment(state, AirDistUnitNum, SysOutputProvided, NonAirSysOutput, LatOutputProvided, FirstHVACIteration, ControlledZoneNum);
     183              : 
     184              :         // Call one-time init to fill termunit sizing and other data for the ADU - can't do this until the actual terminal unit nodes have been
     185              :         // matched to zone euqip config nodes
     186     38668215 :         InitZoneAirLoopEquipment(state, AirDistUnitNum, ControlledZoneNum);
     187     38668215 :     }
     188              : 
     189          584 :     void GetZoneAirLoopEquipment(EnergyPlusData &state)
     190              :     {
     191              : 
     192              :         // SUBROUTINE INFORMATION:
     193              :         //       AUTHOR         Russ Taylor
     194              :         //       DATE WRITTEN   June 1997
     195              :         //       MODIFIED       na
     196              :         //       RE-ENGINEERED  na
     197              : 
     198              :         // PURPOSE OF THIS SUBROUTINE:
     199              :         // Get all the system related equipment which may be attached to
     200              :         // a zone
     201              : 
     202              :         // METHODOLOGY EMPLOYED:
     203              :         // Needs description, as appropriate.
     204              : 
     205              :         // REFERENCES:
     206              :         // na
     207              : 
     208              :         // Using/Aliasing
     209              :         using NodeInputManager::GetOnlySingleNode;
     210              :         using namespace DataLoopNode;
     211              :         using BranchNodeConnections::SetUpCompSets;
     212              :         using DualDuct::GetDualDuctOutdoorAirRecircUse;
     213              : 
     214              :         // SUBROUTINE PARAMETER DEFINITIONS:
     215              :         static constexpr std::string_view RoutineName("GetZoneAirLoopEquipment: ");   // include trailing blank space
     216         1752 :         static std::string const CurrentModuleObject("ZoneHVAC:AirDistributionUnit"); // Object type for getting and error messages
     217              : 
     218              :         // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
     219          584 :         bool ErrorsFound(false); // If errors detected in input
     220          584 :         Array1D_string AlphArray(5);
     221          584 :         Array1D<Real64> NumArray(2);
     222          584 :         Array1D_string cAlphaFields(5);   // Alpha field names
     223          584 :         Array1D_string cNumericFields(2); // Numeric field names
     224          584 :         Array1D_bool lAlphaBlanks(5);     // Logical array, alpha field input BLANK = .TRUE.
     225          584 :         Array1D_bool lNumericBlanks(2);   // Logical array, numeric field input BLANK = .TRUE.
     226              : 
     227          584 :         int NumAirDistUnits = state.dataInputProcessing->inputProcessor->getNumObjectsFound(state, CurrentModuleObject);
     228              : 
     229          584 :         state.dataDefineEquipment->AirDistUnit.allocate(NumAirDistUnits);
     230              : 
     231          584 :         if (NumAirDistUnits > 0) {
     232              :             int NumAlphas;
     233              :             int NumNums;
     234              :             int IOStat;
     235              :             bool IsNotOK; // Flag to verify name
     236              : 
     237         4353 :             for (int AirDistUnitNum = 1; AirDistUnitNum <= NumAirDistUnits; ++AirDistUnitNum) {
     238         3806 :                 auto &airDistUnit = state.dataDefineEquipment->AirDistUnit(AirDistUnitNum);
     239         3806 :                 state.dataInputProcessing->inputProcessor->getObjectItem(state,
     240              :                                                                          CurrentModuleObject,
     241              :                                                                          AirDistUnitNum,
     242              :                                                                          AlphArray,
     243              :                                                                          NumAlphas,
     244              :                                                                          NumArray,
     245              :                                                                          NumNums,
     246              :                                                                          IOStat,
     247              :                                                                          lNumericBlanks,
     248              :                                                                          lAlphaBlanks,
     249              :                                                                          cAlphaFields,
     250              :                                                                          cNumericFields); //  data for one zone
     251         3806 :                 Util::IsNameEmpty(state, AlphArray(1), CurrentModuleObject, ErrorsFound);
     252              : 
     253         3806 :                 airDistUnit.Name = AlphArray(1);
     254              :                 // Input Outlet Node Num
     255         3806 :                 airDistUnit.OutletNodeNum = GetOnlySingleNode(state,
     256         3806 :                                                               AlphArray(2),
     257              :                                                               ErrorsFound,
     258              :                                                               DataLoopNode::ConnectionObjectType::ZoneHVACAirDistributionUnit,
     259         3806 :                                                               AlphArray(1),
     260              :                                                               DataLoopNode::NodeFluidType::Air,
     261              :                                                               DataLoopNode::ConnectionType::Outlet,
     262              :                                                               NodeInputManager::CompFluidStream::Primary,
     263              :                                                               ObjectIsParent);
     264         3806 :                 airDistUnit.InletNodeNum = 0;
     265         3806 :                 airDistUnit.NumComponents = 1;
     266         3806 :                 int AirDistCompUnitNum = 1;
     267              :                 // Load the air Distribution Unit Equip and Name
     268         3806 :                 airDistUnit.EquipType(AirDistCompUnitNum) = AlphArray(3);
     269         3806 :                 airDistUnit.EquipName(AirDistCompUnitNum) = AlphArray(4);
     270         3806 :                 ValidateComponent(state, AlphArray(3), AlphArray(4), IsNotOK, CurrentModuleObject);
     271         3806 :                 if (IsNotOK) {
     272            0 :                     ShowContinueError(state, format("In {} = {}", CurrentModuleObject, AlphArray(1)));
     273            0 :                     ErrorsFound = true;
     274              :                 }
     275         3806 :                 airDistUnit.UpStreamLeakFrac = NumArray(1);
     276         3806 :                 airDistUnit.DownStreamLeakFrac = NumArray(2);
     277         3806 :                 if (airDistUnit.DownStreamLeakFrac <= 0.0) {
     278         3756 :                     airDistUnit.LeakLoadMult = 1.0;
     279           50 :                 } else if (airDistUnit.DownStreamLeakFrac < 1.0 && airDistUnit.DownStreamLeakFrac > 0.0) {
     280           50 :                     airDistUnit.LeakLoadMult = 1.0 / (1.0 - airDistUnit.DownStreamLeakFrac);
     281              :                 } else {
     282            0 :                     ShowSevereError(state, format("Error found in {} = {}", CurrentModuleObject, airDistUnit.Name));
     283            0 :                     ShowContinueError(state, format("{} must be less than 1.0", cNumericFields(2)));
     284            0 :                     ErrorsFound = true;
     285              :                 }
     286         3806 :                 if (airDistUnit.UpStreamLeakFrac > 0.0) {
     287           50 :                     airDistUnit.UpStreamLeak = true;
     288              :                 } else {
     289         3756 :                     airDistUnit.UpStreamLeak = false;
     290              :                 }
     291         3806 :                 if (airDistUnit.DownStreamLeakFrac > 0.0) {
     292           50 :                     airDistUnit.DownStreamLeak = true;
     293              :                 } else {
     294         3756 :                     airDistUnit.DownStreamLeak = false;
     295              :                 }
     296              : 
     297              :                 // DesignSpecification:AirTerminal:Sizing name
     298         3806 :                 airDistUnit.AirTerminalSizingSpecIndex = 0;
     299         3806 :                 if (!lAlphaBlanks(5)) {
     300           40 :                     airDistUnit.AirTerminalSizingSpecIndex = Util::FindItemInList(AlphArray(5), state.dataSize->AirTerminalSizingSpec);
     301           40 :                     if (airDistUnit.AirTerminalSizingSpecIndex == 0) {
     302            0 :                         ShowSevereError(state, format("{} = {} not found.", cAlphaFields(5), AlphArray(5)));
     303            0 :                         ShowContinueError(state, format("Occurs in {} = {}", CurrentModuleObject, airDistUnit.Name));
     304            0 :                         ErrorsFound = true;
     305              :                     }
     306              :                 }
     307              : 
     308         3806 :                 const std::string typeNameUC = Util::makeUPPER(airDistUnit.EquipType(AirDistCompUnitNum));
     309         3806 :                 airDistUnit.EquipTypeEnum(AirDistCompUnitNum) = static_cast<ZnAirLoopEquipType>(getEnumValue(ZnAirLoopEquipTypeNamesUC, typeNameUC));
     310              :                 // Validate EquipType for Air Distribution Unit
     311         3806 :                 switch (airDistUnit.EquipTypeEnum(AirDistCompUnitNum)) {
     312          177 :                 case DataDefineEquip::ZnAirLoopEquipType::DualDuctConstVolume:
     313              :                 case DataDefineEquip::ZnAirLoopEquipType::DualDuctVAV:
     314              :                 case DataDefineEquip::ZnAirLoopEquipType::DualDuctVAVOutdoorAir:
     315              :                 case DataDefineEquip::ZnAirLoopEquipType::SingleDuct_SeriesPIU_Reheat:
     316              :                 case DataDefineEquip::ZnAirLoopEquipType::SingleDuct_ParallelPIU_Reheat:
     317              :                 case DataDefineEquip::ZnAirLoopEquipType::SingleDuct_ConstVol_4PipeInduc:
     318              :                 case DataDefineEquip::ZnAirLoopEquipType::SingleDuctVAVReheatVSFan:
     319              :                 case DataDefineEquip::ZnAirLoopEquipType::SingleDuctConstVolCooledBeam:
     320              :                 case DataDefineEquip::ZnAirLoopEquipType::SingleDuctUserDefined:
     321              :                 case DataDefineEquip::ZnAirLoopEquipType::SingleDuctATMixer:
     322          177 :                     if (airDistUnit.UpStreamLeak || airDistUnit.DownStreamLeak) {
     323            0 :                         ShowSevereError(state, format("Error found in {} = {}", CurrentModuleObject, airDistUnit.Name));
     324            0 :                         ShowContinueError(state,
     325            0 :                                           format("Simple duct leakage model not available for {} = {}",
     326              :                                                  cAlphaFields(3),
     327              :                                                  airDistUnit.EquipType(AirDistCompUnitNum)));
     328            0 :                         ErrorsFound = true;
     329              :                     }
     330          177 :                     break;
     331           30 :                 case DataDefineEquip::ZnAirLoopEquipType::SingleDuctConstVolFourPipeBeam:
     332           30 :                     airDistUnit.airTerminalPtr = FourPipeBeam::HVACFourPipeBeam::fourPipeBeamFactory(state, airDistUnit.EquipName(1));
     333           30 :                     if (airDistUnit.UpStreamLeak || airDistUnit.DownStreamLeak) {
     334            0 :                         ShowSevereError(state, format("Error found in {} = {}", CurrentModuleObject, airDistUnit.Name));
     335            0 :                         ShowContinueError(state,
     336            0 :                                           format("Simple duct leakage model not available for {} = {}",
     337              :                                                  cAlphaFields(3),
     338              :                                                  airDistUnit.EquipType(AirDistCompUnitNum)));
     339            0 :                         ErrorsFound = true;
     340              :                     }
     341           30 :                     break;
     342         1133 :                 case DataDefineEquip::ZnAirLoopEquipType::SingleDuctConstVolReheat:
     343              :                 case DataDefineEquip::ZnAirLoopEquipType::SingleDuctConstVolNoReheat:
     344         1133 :                     break;
     345         2466 :                 case DataDefineEquip::ZnAirLoopEquipType::SingleDuctVAVReheat:
     346              :                 case DataDefineEquip::ZnAirLoopEquipType::SingleDuctVAVNoReheat:
     347              :                 case DataDefineEquip::ZnAirLoopEquipType::SingleDuctCBVAVReheat:
     348              :                 case DataDefineEquip::ZnAirLoopEquipType::SingleDuctCBVAVNoReheat:
     349         2466 :                     airDistUnit.IsConstLeakageRate = true;
     350         2466 :                     break;
     351            0 :                 default:
     352            0 :                     ShowSevereError(state, format("Error found in {} = {}", CurrentModuleObject, airDistUnit.Name));
     353            0 :                     ShowContinueError(state, format("Invalid {} = {}", cAlphaFields(3), airDistUnit.EquipType(AirDistCompUnitNum)));
     354            0 :                     ErrorsFound = true;
     355            0 :                     break;
     356              :                 } // end switch
     357              : 
     358              :                 // Set up component set for air terminal unit
     359         7592 :                 if ((airDistUnit.EquipTypeEnum(AirDistCompUnitNum) == DataDefineEquip::ZnAirLoopEquipType::DualDuctConstVolume) ||
     360         3786 :                     (airDistUnit.EquipTypeEnum(AirDistCompUnitNum) == DataDefineEquip::ZnAirLoopEquipType::DualDuctVAV)) {
     361              :                     //  For dual duct units, set up two component sets, one for heat and one for cool
     362           69 :                     SetUpCompSets(state,
     363              :                                   CurrentModuleObject,
     364              :                                   airDistUnit.Name,
     365           46 :                                   airDistUnit.EquipType(AirDistCompUnitNum) + ":HEAT",
     366           23 :                                   airDistUnit.EquipName(AirDistCompUnitNum),
     367              :                                   "UNDEFINED",
     368           23 :                                   AlphArray(2));
     369           69 :                     SetUpCompSets(state,
     370              :                                   CurrentModuleObject,
     371              :                                   airDistUnit.Name,
     372           46 :                                   airDistUnit.EquipType(AirDistCompUnitNum) + ":COOL",
     373           23 :                                   airDistUnit.EquipName(AirDistCompUnitNum),
     374              :                                   "UNDEFINED",
     375           23 :                                   AlphArray(2));
     376              :                     //  For dual duct units with decoupled OA and RA, set up two component sets, one for OA (Outdoor Air)
     377              :                     //  and one for RA (Recirculated Air)
     378         3783 :                 } else if (airDistUnit.EquipTypeEnum(AirDistCompUnitNum) == DataDefineEquip::ZnAirLoopEquipType::DualDuctVAVOutdoorAir) {
     379           33 :                     SetUpCompSets(state,
     380              :                                   CurrentModuleObject,
     381              :                                   airDistUnit.Name,
     382           22 :                                   airDistUnit.EquipType(AirDistCompUnitNum) + ":OutdoorAir",
     383           11 :                                   airDistUnit.EquipName(AirDistCompUnitNum),
     384              :                                   "UNDEFINED",
     385           11 :                                   AlphArray(2));
     386              :                     bool DualDuctRecircIsUsed; // local temporary for deciding if recirc side used by dual duct terminal
     387           22 :                     GetDualDuctOutdoorAirRecircUse(
     388           11 :                         state, airDistUnit.EquipType(AirDistCompUnitNum), airDistUnit.EquipName(AirDistCompUnitNum), DualDuctRecircIsUsed);
     389           11 :                     if (DualDuctRecircIsUsed) {
     390           18 :                         SetUpCompSets(state,
     391              :                                       CurrentModuleObject,
     392              :                                       airDistUnit.Name,
     393           12 :                                       airDistUnit.EquipType(AirDistCompUnitNum) + ":RecirculatedAir",
     394            6 :                                       airDistUnit.EquipName(AirDistCompUnitNum),
     395              :                                       "UNDEFINED",
     396            6 :                                       AlphArray(2));
     397              :                     }
     398              :                 } else {
     399        11316 :                     SetUpCompSets(state,
     400              :                                   CurrentModuleObject,
     401              :                                   airDistUnit.Name,
     402         3772 :                                   airDistUnit.EquipType(AirDistCompUnitNum),
     403         3772 :                                   airDistUnit.EquipName(AirDistCompUnitNum),
     404              :                                   "UNDEFINED",
     405         3772 :                                   AlphArray(2));
     406              :                 }
     407              : 
     408         3806 :             } // End of Air Dist Do Loop
     409         4353 :             for (int AirDistUnitNum = 1; AirDistUnitNum <= (int)state.dataDefineEquipment->AirDistUnit.size(); ++AirDistUnitNum) {
     410         3806 :                 auto &airDistUnit = state.dataDefineEquipment->AirDistUnit(AirDistUnitNum);
     411         7612 :                 SetupOutputVariable(state,
     412              :                                     "Zone Air Terminal Sensible Heating Energy",
     413              :                                     Constant::Units::J,
     414         3806 :                                     airDistUnit.HeatGain,
     415              :                                     OutputProcessor::TimeStepType::System,
     416              :                                     OutputProcessor::StoreType::Sum,
     417         3806 :                                     airDistUnit.Name);
     418         7612 :                 SetupOutputVariable(state,
     419              :                                     "Zone Air Terminal Sensible Cooling Energy",
     420              :                                     Constant::Units::J,
     421         3806 :                                     airDistUnit.CoolGain,
     422              :                                     OutputProcessor::TimeStepType::System,
     423              :                                     OutputProcessor::StoreType::Sum,
     424         3806 :                                     airDistUnit.Name);
     425         7612 :                 SetupOutputVariable(state,
     426              :                                     "Zone Air Terminal Sensible Heating Rate",
     427              :                                     Constant::Units::W,
     428         3806 :                                     airDistUnit.HeatRate,
     429              :                                     OutputProcessor::TimeStepType::System,
     430              :                                     OutputProcessor::StoreType::Average,
     431         3806 :                                     airDistUnit.Name);
     432         7612 :                 SetupOutputVariable(state,
     433              :                                     "Zone Air Terminal Sensible Cooling Rate",
     434              :                                     Constant::Units::W,
     435         3806 :                                     airDistUnit.CoolRate,
     436              :                                     OutputProcessor::TimeStepType::System,
     437              :                                     OutputProcessor::StoreType::Average,
     438         3806 :                                     airDistUnit.Name);
     439              :             }
     440              :         }
     441          584 :         if (ErrorsFound) {
     442            0 :             ShowFatalError(state, format("{}Errors found in getting {} Input", RoutineName, CurrentModuleObject));
     443              :         }
     444          584 :     }
     445              : 
     446     77336430 :     void InitZoneAirLoopEquipment(EnergyPlusData &state, int const AirDistUnitNum, int const ControlledZoneNum)
     447              :     {
     448              :         // SUBROUTINE INFORMATION:
     449              :         //       AUTHOR         Russ Taylor
     450              :         //       DATE WRITTEN   Nov 1997
     451              : 
     452              :         // PURPOSE OF THIS SUBROUTINE:
     453              :         // This subroutine is left for Module format consistency -- not needed in this module.
     454              : 
     455              :         // Do the Begin Simulation initializations
     456     77336430 :         if (!state.dataZoneAirLoopEquipmentManager->InitAirDistUnitsFlag) {
     457     77329236 :             return;
     458              :         }
     459        11625 :         if (state.dataDefineEquipment->AirDistUnit(AirDistUnitNum).EachOnceFlag &&
     460         4431 :             (state.dataDefineEquipment->AirDistUnit(AirDistUnitNum).TermUnitSizingNum > 0)) {
     461              : 
     462              :             {
     463         3806 :                 auto &thisADU = state.dataDefineEquipment->AirDistUnit(AirDistUnitNum);
     464              :                 {
     465         3806 :                     auto &thisZoneEqConfig(state.dataZoneEquip->ZoneEquipConfig(ControlledZoneNum));
     466         3806 :                     thisADU.ZoneNum = ControlledZoneNum;
     467         7995 :                     for (int inletNum = 1; inletNum <= thisZoneEqConfig.NumInletNodes; ++inletNum) {
     468         4189 :                         if (thisZoneEqConfig.InletNode(inletNum) == thisADU.OutletNodeNum) {
     469         3771 :                             thisZoneEqConfig.InletNodeADUNum(inletNum) = AirDistUnitNum;
     470              :                         }
     471              :                     }
     472              :                 }
     473              : 
     474              :                 // Fill TermUnitSizing with specs from DesignSpecification:AirTerminal:Sizing
     475              :                 {
     476         3806 :                     auto &thisTermUnitSizingData(state.dataSize->TermUnitSizing(thisADU.TermUnitSizingNum));
     477         3806 :                     thisTermUnitSizingData.ADUName = thisADU.Name;
     478         3806 :                     if (thisADU.AirTerminalSizingSpecIndex > 0) {
     479              :                         {
     480           40 :                             auto const &thisAirTermSizingSpec(state.dataSize->AirTerminalSizingSpec(thisADU.AirTerminalSizingSpecIndex));
     481           40 :                             thisTermUnitSizingData.SpecDesCoolSATRatio = thisAirTermSizingSpec.DesCoolSATRatio;
     482           40 :                             thisTermUnitSizingData.SpecDesHeatSATRatio = thisAirTermSizingSpec.DesHeatSATRatio;
     483           40 :                             thisTermUnitSizingData.SpecDesSensCoolingFrac = thisAirTermSizingSpec.DesSensCoolingFrac;
     484           40 :                             thisTermUnitSizingData.SpecDesSensHeatingFrac = thisAirTermSizingSpec.DesSensHeatingFrac;
     485           40 :                             thisTermUnitSizingData.SpecMinOAFrac = thisAirTermSizingSpec.MinOAFrac;
     486              :                         }
     487              :                     }
     488              :                 }
     489              :             }
     490              : 
     491         7612 :             if (state.dataDefineEquipment->AirDistUnit(AirDistUnitNum).ZoneNum != 0 &&
     492         3806 :                 state.dataHeatBal->Zone(state.dataDefineEquipment->AirDistUnit(AirDistUnitNum).ZoneNum).HasAdjustedReturnTempByITE) {
     493            8 :                 for (int AirDistCompNum = 1; AirDistCompNum <= state.dataDefineEquipment->AirDistUnit(AirDistUnitNum).NumComponents;
     494              :                      ++AirDistCompNum) {
     495            4 :                     if (state.dataDefineEquipment->AirDistUnit(AirDistUnitNum).EquipTypeEnum(AirDistCompNum) !=
     496            8 :                             DataDefineEquip::ZnAirLoopEquipType::SingleDuctVAVReheat &&
     497            4 :                         state.dataDefineEquipment->AirDistUnit(AirDistUnitNum).EquipTypeEnum(AirDistCompNum) !=
     498              :                             DataDefineEquip::ZnAirLoopEquipType::SingleDuctVAVNoReheat) {
     499            0 :                         ShowSevereError(state,
     500              :                                         "The FlowControlWithApproachTemperatures only works with ITE zones with single duct VAV terminal unit.");
     501            0 :                         ShowContinueError(state, "The return air temperature of the ITE will not be overwritten.");
     502            0 :                         ShowFatalError(state, "Preceding condition causes termination.");
     503              :                     }
     504              :                 }
     505              :             }
     506         3806 :             state.dataDefineEquipment->AirDistUnit(AirDistUnitNum).EachOnceFlag = false;
     507         3806 :             ++state.dataZoneAirLoopEquipmentManager->numADUInitialized;
     508         3806 :             if (state.dataZoneAirLoopEquipmentManager->numADUInitialized == (int)state.dataDefineEquipment->AirDistUnit.size()) {
     509              :                 // If all ADUs are initialized, set InitAirDistUnitsFlag to false
     510          547 :                 state.dataZoneAirLoopEquipmentManager->InitAirDistUnitsFlag = false;
     511              :             }
     512              :         }
     513              :     }
     514              : 
     515     38668215 :     void InitZoneAirLoopEquipmentTimeStep(EnergyPlusData &state, int const AirDistUnitNum)
     516              :     {
     517     38668215 :         auto &airDistUnit = state.dataDefineEquipment->AirDistUnit(AirDistUnitNum);
     518              :         // every time step
     519     38668215 :         airDistUnit.MassFlowRateDnStrLk = 0.0;
     520     38668215 :         airDistUnit.MassFlowRateUpStrLk = 0.0;
     521     38668215 :         airDistUnit.MassFlowRateTU = 0.0;
     522     38668215 :         airDistUnit.MassFlowRateZSup = 0.0;
     523     38668215 :         airDistUnit.MassFlowRateSup = 0.0;
     524     38668215 :         airDistUnit.HeatRate = 0.0;
     525     38668215 :         airDistUnit.CoolRate = 0.0;
     526     38668215 :         airDistUnit.HeatGain = 0.0;
     527     38668215 :         airDistUnit.CoolGain = 0.0;
     528     38668215 :     }
     529              : 
     530     38668215 :     void SimZoneAirLoopEquipment(EnergyPlusData &state,
     531              :                                  int const AirDistUnitNum,
     532              :                                  Real64 &SysOutputProvided,
     533              :                                  Real64 &NonAirSysOutput,
     534              :                                  Real64 &LatOutputProvided, // Latent add/removal provided by this unit (kg/s), dehumidify = negative
     535              :                                  bool const FirstHVACIteration,
     536              :                                  int const ControlledZoneNum)
     537              :     {
     538              :         // SUBROUTINE INFORMATION:
     539              :         //       AUTHOR         Russ Taylor
     540              :         //       DATE WRITTEN   May 1997
     541              :         //       MODIFIED       Don Shirey, Aug 2009 (LatOutputProvided)
     542              : 
     543              :         // PURPOSE OF THIS SUBROUTINE:
     544              :         // Simulates primary system air supplied to a zone and calculates
     545              :         // airflow requirements
     546              : 
     547              :         using DualDuct::SimulateDualDuct;
     548              :         using HVACCooledBeam::SimCoolBeam;
     549              :         using HVACSingleDuctInduc::SimIndUnit;
     550              :         using PoweredInductionUnits::SimPIU;
     551              :         using Psychrometrics::PsyCpAirFnW;
     552              :         using SingleDuct::GetATMixers;
     553              :         using SingleDuct::SimulateSingleDuct;
     554              :         using UserDefinedComponents::SimAirTerminalUserDefined;
     555              : 
     556              :         bool ProvideSysOutput;
     557              :         int AirDistCompNum;
     558     38668215 :         int AirLoopNum(0);                  // index of air loop
     559              :         Real64 MassFlowRateMaxAvail;        // max avail mass flow rate excluding leaks [kg/s]
     560              :         Real64 MassFlowRateMinAvail;        // min avail mass flow rate excluding leaks [kg/s]
     561              :         Real64 MassFlowRateUpStreamLeakMax; // max upstream leak flow rate [kg/s]
     562     38668215 :         Real64 DesFlowRatio(0.0);           // ratio of system to sum of zones design flow rate
     563     38668215 :         Real64 SpecHumOut(0.0);             // Specific humidity ratio of outlet air (kg moisture / kg moist air)
     564     38668215 :         Real64 SpecHumIn(0.0);              // Specific humidity ratio of inlet air (kg moisture / kg moist air)
     565              : 
     566     38668215 :         auto &controlledZoneAirNode = state.dataZoneEquip->ZoneEquipConfig(ControlledZoneNum).ZoneNode;
     567              : 
     568     38668215 :         ProvideSysOutput = true;
     569     77336430 :         for (AirDistCompNum = 1; AirDistCompNum <= state.dataDefineEquipment->AirDistUnit(AirDistUnitNum).NumComponents; ++AirDistCompNum) {
     570     38668215 :             NonAirSysOutput = 0.0;
     571              : 
     572     38668215 :             auto &airDistUnit = state.dataDefineEquipment->AirDistUnit(AirDistUnitNum);
     573     38668215 :             int InNodeNum = airDistUnit.InletNodeNum;
     574     38668215 :             int OutNodeNum = airDistUnit.OutletNodeNum;
     575     38668215 :             MassFlowRateMaxAvail = 0.0;
     576     38668215 :             MassFlowRateMinAvail = 0.0;
     577              :             // check for no plenum
     578              :             // set the max and min avail flow rates taking into acount the upstream leak
     579     38668215 :             if (airDistUnit.UpStreamLeak) {
     580       242380 :                 if (InNodeNum > 0) {
     581       242370 :                     MassFlowRateMaxAvail = state.dataLoopNodes->Node(InNodeNum).MassFlowRateMaxAvail;
     582       242370 :                     MassFlowRateMinAvail = state.dataLoopNodes->Node(InNodeNum).MassFlowRateMinAvail;
     583       242370 :                     if (airDistUnit.IsConstLeakageRate) {
     584       192428 :                         AirLoopNum = airDistUnit.AirLoopNum;
     585       192428 :                         if (AirLoopNum > 0) {
     586       192365 :                             DesFlowRatio = state.dataAirLoop->AirLoopFlow(AirLoopNum).SysToZoneDesFlowRatio;
     587              :                         } else {
     588           63 :                             DesFlowRatio = 1.0;
     589              :                         }
     590              :                         MassFlowRateUpStreamLeakMax =
     591       192428 :                             max(airDistUnit.UpStreamLeakFrac * state.dataLoopNodes->Node(InNodeNum).MassFlowRateMax * DesFlowRatio, 0.0);
     592              :                     } else {
     593        49942 :                         MassFlowRateUpStreamLeakMax = max(airDistUnit.UpStreamLeakFrac * MassFlowRateMaxAvail, 0.0);
     594              :                     }
     595       242370 :                     if (MassFlowRateMaxAvail > MassFlowRateUpStreamLeakMax) {
     596       241930 :                         airDistUnit.MassFlowRateUpStrLk = MassFlowRateUpStreamLeakMax;
     597       241930 :                         state.dataLoopNodes->Node(InNodeNum).MassFlowRateMaxAvail = MassFlowRateMaxAvail - MassFlowRateUpStreamLeakMax;
     598              :                     } else {
     599          440 :                         airDistUnit.MassFlowRateUpStrLk = MassFlowRateMaxAvail;
     600          440 :                         state.dataLoopNodes->Node(InNodeNum).MassFlowRateMaxAvail = 0.0;
     601              :                     }
     602       242370 :                     state.dataLoopNodes->Node(InNodeNum).MassFlowRateMinAvail = max(0.0, MassFlowRateMinAvail - airDistUnit.MassFlowRateUpStrLk);
     603              :                 }
     604              :             }
     605              : 
     606     38668215 :             switch (airDistUnit.EquipTypeEnum(AirDistCompNum)) {
     607       122091 :             case DataDefineEquip::ZnAirLoopEquipType::DualDuctConstVolume: {
     608       244182 :                 SimulateDualDuct(state,
     609       122091 :                                  airDistUnit.EquipName(AirDistCompNum),
     610              :                                  FirstHVACIteration,
     611              :                                  ControlledZoneNum,
     612              :                                  controlledZoneAirNode,
     613              :                                  airDistUnit.EquipIndex(AirDistCompNum));
     614       122091 :             } break;
     615        16275 :             case DataDefineEquip::ZnAirLoopEquipType::DualDuctVAV: {
     616        32550 :                 SimulateDualDuct(state,
     617        16275 :                                  airDistUnit.EquipName(AirDistCompNum),
     618              :                                  FirstHVACIteration,
     619              :                                  ControlledZoneNum,
     620              :                                  controlledZoneAirNode,
     621              :                                  airDistUnit.EquipIndex(AirDistCompNum));
     622        16275 :             } break;
     623        67628 :             case DataDefineEquip::ZnAirLoopEquipType::DualDuctVAVOutdoorAir: {
     624       135256 :                 SimulateDualDuct(state,
     625        67628 :                                  airDistUnit.EquipName(AirDistCompNum),
     626              :                                  FirstHVACIteration,
     627              :                                  ControlledZoneNum,
     628              :                                  controlledZoneAirNode,
     629              :                                  airDistUnit.EquipIndex(AirDistCompNum));
     630        67628 :             } break;
     631     24716468 :             case DataDefineEquip::ZnAirLoopEquipType::SingleDuctVAVReheat: {
     632     49432936 :                 SimulateSingleDuct(state,
     633     24716468 :                                    airDistUnit.EquipName(AirDistCompNum),
     634              :                                    FirstHVACIteration,
     635              :                                    ControlledZoneNum,
     636              :                                    controlledZoneAirNode,
     637              :                                    airDistUnit.EquipIndex(AirDistCompNum));
     638     24716468 :             } break;
     639        46050 :             case DataDefineEquip::ZnAirLoopEquipType::SingleDuctCBVAVReheat: {
     640        92100 :                 SimulateSingleDuct(state,
     641        46050 :                                    airDistUnit.EquipName(AirDistCompNum),
     642              :                                    FirstHVACIteration,
     643              :                                    ControlledZoneNum,
     644              :                                    controlledZoneAirNode,
     645              :                                    airDistUnit.EquipIndex(AirDistCompNum));
     646        46050 :             } break;
     647      2306223 :             case DataDefineEquip::ZnAirLoopEquipType::SingleDuctVAVNoReheat: {
     648      4612446 :                 SimulateSingleDuct(state,
     649      2306223 :                                    airDistUnit.EquipName(AirDistCompNum),
     650              :                                    FirstHVACIteration,
     651              :                                    ControlledZoneNum,
     652              :                                    controlledZoneAirNode,
     653              :                                    airDistUnit.EquipIndex(AirDistCompNum));
     654      2306223 :             } break;
     655        21224 :             case DataDefineEquip::ZnAirLoopEquipType::SingleDuctCBVAVNoReheat: {
     656        42448 :                 SimulateSingleDuct(state,
     657        21224 :                                    airDistUnit.EquipName(AirDistCompNum),
     658              :                                    FirstHVACIteration,
     659              :                                    ControlledZoneNum,
     660              :                                    controlledZoneAirNode,
     661              :                                    airDistUnit.EquipIndex(AirDistCompNum));
     662        21224 :             } break;
     663      1656582 :             case DataDefineEquip::ZnAirLoopEquipType::SingleDuctConstVolReheat: {
     664      3313164 :                 SimulateSingleDuct(state,
     665      1656582 :                                    airDistUnit.EquipName(AirDistCompNum),
     666              :                                    FirstHVACIteration,
     667              :                                    ControlledZoneNum,
     668              :                                    controlledZoneAirNode,
     669              :                                    airDistUnit.EquipIndex(AirDistCompNum));
     670      1656582 :             } break;
     671      8544703 :             case DataDefineEquip::ZnAirLoopEquipType::SingleDuctConstVolNoReheat: {
     672     17089406 :                 SimulateSingleDuct(state,
     673      8544703 :                                    airDistUnit.EquipName(AirDistCompNum),
     674              :                                    FirstHVACIteration,
     675              :                                    ControlledZoneNum,
     676              :                                    controlledZoneAirNode,
     677              :                                    airDistUnit.EquipIndex(AirDistCompNum));
     678      8544703 :             } break;
     679       286787 :             case DataDefineEquip::ZnAirLoopEquipType::SingleDuct_SeriesPIU_Reheat: {
     680       573574 :                 SimPIU(state,
     681       286787 :                        airDistUnit.EquipName(AirDistCompNum),
     682              :                        FirstHVACIteration,
     683              :                        ControlledZoneNum,
     684              :                        controlledZoneAirNode,
     685              :                        airDistUnit.EquipIndex(AirDistCompNum));
     686       286787 :             } break;
     687        21558 :             case DataDefineEquip::ZnAirLoopEquipType::SingleDuct_ParallelPIU_Reheat: {
     688        43116 :                 SimPIU(state,
     689        21558 :                        airDistUnit.EquipName(AirDistCompNum),
     690              :                        FirstHVACIteration,
     691              :                        ControlledZoneNum,
     692              :                        controlledZoneAirNode,
     693              :                        airDistUnit.EquipIndex(AirDistCompNum));
     694        21558 :             } break;
     695        11976 :             case DataDefineEquip::ZnAirLoopEquipType::SingleDuct_ConstVol_4PipeInduc: {
     696        23952 :                 SimIndUnit(state,
     697        11976 :                            airDistUnit.EquipName(AirDistCompNum),
     698              :                            FirstHVACIteration,
     699              :                            ControlledZoneNum,
     700              :                            controlledZoneAirNode,
     701              :                            airDistUnit.EquipIndex(AirDistCompNum));
     702        11976 :             } break;
     703        30864 :             case DataDefineEquip::ZnAirLoopEquipType::SingleDuctVAVReheatVSFan: {
     704        61728 :                 SimulateSingleDuct(state,
     705        30864 :                                    airDistUnit.EquipName(AirDistCompNum),
     706              :                                    FirstHVACIteration,
     707              :                                    ControlledZoneNum,
     708              :                                    controlledZoneAirNode,
     709              :                                    airDistUnit.EquipIndex(AirDistCompNum));
     710        30864 :             } break;
     711        36725 :             case DataDefineEquip::ZnAirLoopEquipType::SingleDuctConstVolCooledBeam: {
     712        73450 :                 SimCoolBeam(state,
     713        36725 :                             airDistUnit.EquipName(AirDistCompNum),
     714              :                             FirstHVACIteration,
     715              :                             ControlledZoneNum,
     716              :                             controlledZoneAirNode,
     717              :                             airDistUnit.EquipIndex(AirDistCompNum),
     718              :                             NonAirSysOutput);
     719        36725 :             } break;
     720       428235 :             case DataDefineEquip::ZnAirLoopEquipType::SingleDuctConstVolFourPipeBeam: {
     721       428235 :                 airDistUnit.airTerminalPtr->simulate(state, FirstHVACIteration, NonAirSysOutput);
     722       428235 :             } break;
     723       119360 :             case DataDefineEquip::ZnAirLoopEquipType::SingleDuctUserDefined: {
     724       238720 :                 SimAirTerminalUserDefined(state,
     725       119360 :                                           airDistUnit.EquipName(AirDistCompNum),
     726              :                                           FirstHVACIteration,
     727              :                                           ControlledZoneNum,
     728              :                                           controlledZoneAirNode,
     729              :                                           airDistUnit.EquipIndex(AirDistCompNum));
     730       119360 :             } break;
     731       235466 :             case DataDefineEquip::ZnAirLoopEquipType::SingleDuctATMixer: {
     732       235466 :                 GetATMixers(state); // Needed here if mixer used only with unitarysystem which gets its input late
     733       235466 :                 ProvideSysOutput = false;
     734       235466 :             } break;
     735            0 :             default: {
     736            0 :                 ShowSevereError(state, format("Error found in ZoneHVAC:AirDistributionUnit={}", airDistUnit.Name));
     737            0 :                 ShowContinueError(state, format("Invalid Component={}", airDistUnit.EquipType(AirDistCompNum)));
     738            0 :                 ShowFatalError(state, "Preceding condition causes termination.");
     739            0 :             } break;
     740              :             }
     741              : 
     742              :             // do leak mass flow calcs
     743     38668215 :             if (InNodeNum > 0) { // InNodeNum is not always known when this is called, eg FPIU
     744     38536321 :                 InNodeNum = airDistUnit.InletNodeNum;
     745     38536321 :                 if (airDistUnit.UpStreamLeak) {
     746       242370 :                     state.dataLoopNodes->Node(InNodeNum).MassFlowRateMaxAvail = MassFlowRateMaxAvail;
     747       242370 :                     state.dataLoopNodes->Node(InNodeNum).MassFlowRateMinAvail = MassFlowRateMinAvail;
     748              :                 }
     749     38536321 :                 if ((airDistUnit.UpStreamLeak || airDistUnit.DownStreamLeak) && MassFlowRateMaxAvail > 0.0) {
     750       241930 :                     airDistUnit.MassFlowRateTU = state.dataLoopNodes->Node(InNodeNum).MassFlowRate;
     751       241930 :                     airDistUnit.MassFlowRateZSup = airDistUnit.MassFlowRateTU * (1.0 - airDistUnit.DownStreamLeakFrac);
     752       241930 :                     airDistUnit.MassFlowRateDnStrLk = airDistUnit.MassFlowRateTU * airDistUnit.DownStreamLeakFrac;
     753       241930 :                     airDistUnit.MassFlowRateSup = airDistUnit.MassFlowRateTU + airDistUnit.MassFlowRateUpStrLk;
     754       241930 :                     state.dataLoopNodes->Node(InNodeNum).MassFlowRate = airDistUnit.MassFlowRateSup;
     755       241930 :                     state.dataLoopNodes->Node(OutNodeNum).MassFlowRate = airDistUnit.MassFlowRateZSup;
     756       241930 :                     state.dataLoopNodes->Node(OutNodeNum).MassFlowRateMaxAvail =
     757       241930 :                         max(0.0, MassFlowRateMaxAvail - airDistUnit.MassFlowRateDnStrLk - airDistUnit.MassFlowRateUpStrLk);
     758       241930 :                     state.dataLoopNodes->Node(OutNodeNum).MassFlowRateMinAvail =
     759       241930 :                         max(0.0, MassFlowRateMinAvail - airDistUnit.MassFlowRateDnStrLk - airDistUnit.MassFlowRateUpStrLk);
     760       241930 :                     airDistUnit.MaxAvailDelta = MassFlowRateMaxAvail - state.dataLoopNodes->Node(OutNodeNum).MassFlowRateMaxAvail;
     761       241930 :                     airDistUnit.MinAvailDelta = MassFlowRateMinAvail - state.dataLoopNodes->Node(OutNodeNum).MassFlowRateMinAvail;
     762              :                 } else {
     763              :                     // if no leaks, or a terminal unit type not supported for leaks
     764     38294391 :                     DataDefineEquip::ZnAirLoopEquipType termUnitType = airDistUnit.EquipTypeEnum(AirDistCompNum);
     765     38294391 :                     if ((termUnitType == DataDefineEquip::ZnAirLoopEquipType::DualDuctConstVolume) ||
     766     38156032 :                         (termUnitType == DataDefineEquip::ZnAirLoopEquipType::DualDuctVAV) ||
     767              :                         (termUnitType == DataDefineEquip::ZnAirLoopEquipType::DualDuctVAVOutdoorAir)) {
     768              :                         // Use ADU outlet node flow for dual duct terminal units (which don't support leaks)
     769       205986 :                         airDistUnit.MassFlowRateTU = state.dataLoopNodes->Node(OutNodeNum).MassFlowRate;
     770       205986 :                         airDistUnit.MassFlowRateZSup = state.dataLoopNodes->Node(OutNodeNum).MassFlowRate;
     771       205986 :                         airDistUnit.MassFlowRateSup = state.dataLoopNodes->Node(OutNodeNum).MassFlowRate;
     772              :                     } else {
     773     38088405 :                         airDistUnit.MassFlowRateTU = state.dataLoopNodes->Node(InNodeNum).MassFlowRate;
     774     38088405 :                         airDistUnit.MassFlowRateZSup = state.dataLoopNodes->Node(InNodeNum).MassFlowRate;
     775     38088405 :                         airDistUnit.MassFlowRateSup = state.dataLoopNodes->Node(InNodeNum).MassFlowRate;
     776              :                     }
     777              :                 }
     778              :             }
     779              :         }
     780     38668215 :         if (ProvideSysOutput) {
     781     38432749 :             int OutletNodeNum = state.dataDefineEquipment->AirDistUnit(AirDistUnitNum).OutletNodeNum;
     782     38432749 :             SpecHumOut = state.dataLoopNodes->Node(OutletNodeNum).HumRat;
     783     38432749 :             SpecHumIn = state.dataLoopNodes->Node(controlledZoneAirNode).HumRat;
     784              :             // Sign convention: SysOutputProvided <0 Zone is cooled
     785              :             //                  SysOutputProvided >0 Zone is heated
     786     38432749 :             SysOutputProvided = state.dataLoopNodes->Node(OutletNodeNum).MassFlowRate *
     787     38432749 :                                 Psychrometrics::PsyDeltaHSenFnTdb2W2Tdb1W1(state.dataLoopNodes->Node(OutletNodeNum).Temp,
     788              :                                                                            SpecHumOut,
     789     38432749 :                                                                            state.dataLoopNodes->Node(controlledZoneAirNode).Temp,
     790              :                                                                            SpecHumIn); // sensible {W};
     791              :             // Sign convention: LatOutputProvided <0 Zone is dehumidified
     792              :             //                  LatOutputProvided >0 Zone is humidified
     793              :             // CR9155 Remove specific humidity calculations
     794     38432749 :             LatOutputProvided =
     795     38432749 :                 state.dataLoopNodes->Node(OutletNodeNum).MassFlowRate * (SpecHumOut - SpecHumIn); // Latent rate (kg/s), dehumid = negative
     796              :         } else {
     797       235466 :             SysOutputProvided = 0.0;
     798       235466 :             LatOutputProvided = 0.0;
     799              :         }
     800     38668215 :     }
     801              : 
     802              : } // namespace ZoneAirLoopEquipmentManager
     803              : 
     804              : } // namespace EnergyPlus
        

Generated by: LCOV version 2.0-1