LCOV - code coverage report
Current view: top level - EnergyPlus - SystemReports.cc (source / functions) Hit Total Coverage
Test: lcov.output.filtered Lines: 2262 2778 81.4 %
Date: 2024-08-24 18:31:18 Functions: 19 22 86.4 %

          Line data    Source code
       1             : // EnergyPlus, Copyright (c) 1996-2024, The Board of Trustees of the University of Illinois,
       2             : // The Regents of the University of California, through Lawrence Berkeley National Laboratory
       3             : // (subject to receipt of any required approvals from the U.S. Dept. of Energy), Oak Ridge
       4             : // National Laboratory, managed by UT-Battelle, Alliance for Sustainable Energy, LLC, and other
       5             : // contributors. All rights reserved.
       6             : //
       7             : // NOTICE: This Software was developed under funding from the U.S. Department of Energy and the
       8             : // U.S. Government consequently retains certain rights. As such, the U.S. Government has been
       9             : // granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable,
      10             : // worldwide license in the Software to reproduce, distribute copies to the public, prepare
      11             : // derivative works, and perform publicly and display publicly, and to permit others to do so.
      12             : //
      13             : // Redistribution and use in source and binary forms, with or without modification, are permitted
      14             : // provided that the following conditions are met:
      15             : //
      16             : // (1) Redistributions of source code must retain the above copyright notice, this list of
      17             : //     conditions and the following disclaimer.
      18             : //
      19             : // (2) Redistributions in binary form must reproduce the above copyright notice, this list of
      20             : //     conditions and the following disclaimer in the documentation and/or other materials
      21             : //     provided with the distribution.
      22             : //
      23             : // (3) Neither the name of the University of California, Lawrence Berkeley National Laboratory,
      24             : //     the University of Illinois, U.S. Dept. of Energy nor the names of its contributors may be
      25             : //     used to endorse or promote products derived from this software without specific prior
      26             : //     written permission.
      27             : //
      28             : // (4) Use of EnergyPlus(TM) Name. If Licensee (i) distributes the software in stand-alone form
      29             : //     without changes from the version obtained under this License, or (ii) Licensee makes a
      30             : //     reference solely to the software portion of its product, Licensee must refer to the
      31             : //     software as "EnergyPlus version X" software, where "X" is the version number Licensee
      32             : //     obtained under this License and may not use a different name for the software. Except as
      33             : //     specifically required in this Section (4), Licensee shall not use in a company name, a
      34             : //     product name, in advertising, publicity, or other promotional activities any name, trade
      35             : //     name, trademark, logo, or other designation of "EnergyPlus", "E+", "e+" or confusingly
      36             : //     similar designation, without the U.S. Department of Energy's prior written consent.
      37             : //
      38             : // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
      39             : // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
      40             : // AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
      41             : // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
      42             : // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
      43             : // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
      44             : // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
      45             : // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
      46             : // POSSIBILITY OF SUCH DAMAGE.
      47             : 
      48             : // C++ Headers
      49             : #include <algorithm>
      50             : #include <cassert>
      51             : #include <cmath>
      52             : #include <string>
      53             : #include <unordered_map>
      54             : 
      55             : // ObjexxFCL Headers
      56             : #include <ObjexxFCL/Array.functions.hh>
      57             : #include <ObjexxFCL/Fmath.hh>
      58             : 
      59             : // EnergyPlus Headers
      60             : #include <EnergyPlus/BranchNodeConnections.hh>
      61             : #include <EnergyPlus/Data/EnergyPlusData.hh>
      62             : #include <EnergyPlus/DataAirLoop.hh>
      63             : #include <EnergyPlus/DataAirSystems.hh>
      64             : #include <EnergyPlus/DataDefineEquip.hh>
      65             : #include <EnergyPlus/DataEnvironment.hh>
      66             : #include <EnergyPlus/DataGlobalConstants.hh>
      67             : #include <EnergyPlus/DataHVACGlobals.hh>
      68             : #include <EnergyPlus/DataHeatBalance.hh>
      69             : #include <EnergyPlus/DataLoopNode.hh>
      70             : #include <EnergyPlus/DataSizing.hh>
      71             : #include <EnergyPlus/DataZoneEnergyDemands.hh>
      72             : #include <EnergyPlus/DataZoneEquipment.hh>
      73             : #include <EnergyPlus/DualDuct.hh>
      74             : #include <EnergyPlus/FanCoilUnits.hh>
      75             : #include <EnergyPlus/HVACCooledBeam.hh>
      76             : #include <EnergyPlus/HVACFourPipeBeam.hh>
      77             : #include <EnergyPlus/HVACSingleDuctInduc.hh>
      78             : #include <EnergyPlus/HVACStandAloneERV.hh>
      79             : #include <EnergyPlus/HVACVariableRefrigerantFlow.hh>
      80             : #include <EnergyPlus/HybridUnitaryAirConditioners.hh>
      81             : #include <EnergyPlus/MixedAir.hh>
      82             : #include <EnergyPlus/OutdoorAirUnit.hh>
      83             : #include <EnergyPlus/OutputProcessor.hh>
      84             : #include <EnergyPlus/OutputReportPredefined.hh>
      85             : #include <EnergyPlus/Plant/DataPlant.hh>
      86             : #include <EnergyPlus/PoweredInductionUnits.hh>
      87             : #include <EnergyPlus/Psychrometrics.hh>
      88             : #include <EnergyPlus/PurchasedAirManager.hh>
      89             : #include <EnergyPlus/SystemReports.hh>
      90             : #include <EnergyPlus/UnitVentilator.hh>
      91             : #include <EnergyPlus/UtilityRoutines.hh>
      92             : #include <EnergyPlus/WindowAC.hh>
      93             : #include <EnergyPlus/ZoneTempPredictorCorrector.hh>
      94             : 
      95             : namespace EnergyPlus::SystemReports {
      96             : 
      97             : // Module containing the routines dealing with Mechanical Ventilation Loads and Energy Reporting (Outside Air)
      98             : 
      99             : // MODULE INFORMATION:
     100             : //       AUTHOR         Mike Witte, Linda Lawrie, Dan Fisher
     101             : //       DATE WRITTEN   Apr-Jul 2005
     102             : //       MODIFIED       22Aug2010 Craig Wray - added Fan:ComponentModel
     103             : 
     104             : // PURPOSE OF THIS MODULE:
     105             : // This module embodies the scheme(s) for reporting ventilation loads and energy use.
     106             : 
     107             : // Using/Aliasing
     108             : using namespace DataLoopNode;
     109             : using namespace DataAirLoop;
     110             : using namespace DataPlant;
     111             : using namespace DataZoneEquipment;
     112             : using namespace DataAirSystems;
     113             : 
     114             : // Functions
     115             : 
     116      615229 : void InitEnergyReports(EnergyPlusData &state)
     117             : {
     118             : 
     119             :     // SUBROUTINE INFORMATION:
     120             :     //       AUTHOR         Dan Fisher
     121             :     //       DATE WRITTEN   April 2005
     122             : 
     123             :     // PURPOSE OF THIS SUBROUTINE:
     124             :     // Initializes the energy components of the data structures
     125             : 
     126             :     // METHODOLOGY EMPLOYED:
     127             :     // Once all compsets have been established (second iteration) find all components
     128             :     // subcomponents, etc.
     129             : 
     130      615229 :     int constexpr EnergyTransfer(1);
     131             : 
     132      615229 :     if (!state.dataSysRpts->VentReportStructureCreated) return;
     133             : 
     134      615229 :     if (state.dataSysRpts->OneTimeFlag_InitEnergyReports) {
     135             : 
     136             :         // ***I think we need to preprocess the main components on the branch to get them in order***
     137             :         // This needs to be done before we start in on the component loop
     138             :         // GetChildrenData will put all of the subcomponents in order for us
     139             : 
     140        5838 :         for (int CtrlZoneNum = 1; CtrlZoneNum <= state.dataGlobal->NumOfZones; ++CtrlZoneNum) {
     141        5044 :             auto &thisZoneEquipConfig = state.dataZoneEquip->ZoneEquipConfig(CtrlZoneNum);
     142        5044 :             if (!thisZoneEquipConfig.IsControlled) continue;
     143        4309 :             thisZoneEquipConfig.EquipListIndex = Util::FindItemInList(thisZoneEquipConfig.EquipListName, state.dataZoneEquip->ZoneEquipList);
     144        4309 :             auto &thisZoneEquipList = state.dataZoneEquip->ZoneEquipList(thisZoneEquipConfig.EquipListIndex);
     145        8772 :             for (int ZoneInletNodeNum = 1; ZoneInletNodeNum <= thisZoneEquipConfig.NumInletNodes; ++ZoneInletNodeNum) {
     146        4463 :                 int AirLoopNum = thisZoneEquipConfig.InletNodeAirLoopNum(ZoneInletNodeNum);
     147        9762 :                 for (int CompNum = 1; CompNum <= thisZoneEquipList.NumOfEquipTypes; ++CompNum) {
     148       10561 :                     for (int NodeCount = 1; NodeCount <= thisZoneEquipList.EquipData(CompNum).NumOutlets; ++NodeCount) {
     149        5262 :                         if (thisZoneEquipList.EquipData(CompNum).OutletNodeNums(NodeCount) ==
     150        5262 :                             thisZoneEquipConfig.AirDistUnitCool(ZoneInletNodeNum).OutNode) {
     151        3654 :                             thisZoneEquipConfig.AirDistUnitCool(ZoneInletNodeNum).AirDistUnitIndex = CompNum;
     152        3654 :                             if (thisZoneEquipConfig.AirDistUnitCool(ZoneInletNodeNum).SupplyAirPathExists) {
     153       22812 :                                 for (int SAPNum = 1; SAPNum <= state.dataZoneEquip->NumSupplyAirPaths; ++SAPNum) {
     154      123153 :                                     for (int SAPOutNode = 1; SAPOutNode <= state.dataZoneEquip->SupplyAirPath(SAPNum).NumOutletNodes; ++SAPOutNode) {
     155      103991 :                                         if (thisZoneEquipConfig.AirDistUnitCool(ZoneInletNodeNum).InNode ==
     156      103991 :                                             state.dataZoneEquip->SupplyAirPath(SAPNum).OutletNode(SAPOutNode)) {
     157        3650 :                                             thisZoneEquipConfig.AirDistUnitCool(ZoneInletNodeNum).SupplyAirPathIndex = SAPNum;
     158        3650 :                                             thisZoneEquipConfig.AirDistUnitCool(ZoneInletNodeNum).SupplyAirPathOutNodeIndex = SAPOutNode;
     159        7329 :                                             for (int OutNum = 1; OutNum <= state.dataAirLoop->AirToZoneNodeInfo(AirLoopNum).NumSupplyNodes;
     160             :                                                  ++OutNum) {
     161        3679 :                                                 if (state.dataAirLoop->AirToZoneNodeInfo(AirLoopNum).ZoneEquipSupplyNodeNum(OutNum) ==
     162        3679 :                                                     state.dataZoneEquip->SupplyAirPath(SAPNum).InletNodeNum) {
     163        3650 :                                                     thisZoneEquipConfig.AirDistUnitCool(ZoneInletNodeNum).SupplyBranchIndex =
     164        3650 :                                                         state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum).OutletBranchNum[OutNum - 1];
     165        3650 :                                                     if (state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum).Splitter.Exists) {
     166         141 :                                                         for (int MainBranchNum = 1;
     167         141 :                                                              MainBranchNum <= state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum).NumBranches;
     168             :                                                              ++MainBranchNum) {
     169         107 :                                                             if (state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum)
     170         107 :                                                                     .Branch(MainBranchNum)
     171         214 :                                                                     .NodeNumOut ==
     172         107 :                                                                 state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum).Splitter.NodeNumIn) {
     173          34 :                                                                 thisZoneEquipConfig.AirDistUnitCool(ZoneInletNodeNum).MainBranchIndex = MainBranchNum;
     174             :                                                             }
     175             :                                                         }
     176             :                                                     } else { // no splitter
     177        3616 :                                                         thisZoneEquipConfig.AirDistUnitCool(ZoneInletNodeNum).MainBranchIndex =
     178        3616 :                                                             thisZoneEquipConfig.AirDistUnitCool(ZoneInletNodeNum).SupplyBranchIndex;
     179             :                                                     }
     180             :                                                 }
     181             :                                             }
     182             :                                         }
     183             :                                     }
     184             :                                 }
     185             :                             } else { // no supply air path
     186           4 :                                 if (AirLoopNum > 0) {
     187           8 :                                     for (int NodeIndex = 1; NodeIndex <= state.dataAirLoop->AirToZoneNodeInfo(AirLoopNum).NumSupplyNodes;
     188             :                                          ++NodeIndex) {
     189           4 :                                         if (state.dataAirLoop->AirToZoneNodeInfo(AirLoopNum).ZoneEquipSupplyNodeNum(NodeIndex) ==
     190           4 :                                             thisZoneEquipConfig.AirDistUnitCool(ZoneInletNodeNum).InNode) {
     191           8 :                                             for (int BranchNum = 1; BranchNum <= state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum).NumBranches;
     192             :                                                  ++BranchNum) {
     193           4 :                                                 if (state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum).Branch(BranchNum).NodeNumOut ==
     194           4 :                                                     state.dataAirLoop->AirToZoneNodeInfo(AirLoopNum).AirLoopSupplyNodeNum(NodeIndex)) {
     195           4 :                                                     thisZoneEquipConfig.AirDistUnitCool(ZoneInletNodeNum).SupplyBranchIndex = BranchNum;
     196           4 :                                                     if (state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum).Splitter.Exists) {
     197           0 :                                                         for (int MainBranchNum = 1;
     198           0 :                                                              MainBranchNum <= state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum).NumBranches;
     199             :                                                              ++MainBranchNum) {
     200           0 :                                                             if (state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum)
     201           0 :                                                                     .Branch(MainBranchNum)
     202           0 :                                                                     .NodeNumOut ==
     203           0 :                                                                 state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum).Splitter.NodeNumIn) {
     204           0 :                                                                 thisZoneEquipConfig.AirDistUnitCool(ZoneInletNodeNum).MainBranchIndex = MainBranchNum;
     205             :                                                             }
     206             :                                                         }
     207             :                                                     } else { // no splitter
     208           4 :                                                         thisZoneEquipConfig.AirDistUnitCool(ZoneInletNodeNum).MainBranchIndex =
     209           4 :                                                             thisZoneEquipConfig.AirDistUnitCool(ZoneInletNodeNum).SupplyAirPathIndex;
     210             :                                                     }
     211             :                                                 }
     212             :                                             }
     213             :                                         }
     214             :                                     }
     215             :                                 }
     216             :                             }
     217             :                         }
     218        5262 :                         if (thisZoneEquipList.EquipData(CompNum).OutletNodeNums(NodeCount) ==
     219        5262 :                             thisZoneEquipConfig.AirDistUnitHeat(ZoneInletNodeNum).OutNode) {
     220         123 :                             thisZoneEquipConfig.AirDistUnitHeat(ZoneInletNodeNum).AirDistUnitIndex = CompNum;
     221         123 :                             if (thisZoneEquipConfig.AirDistUnitHeat(ZoneInletNodeNum).SupplyAirPathExists) {
     222          93 :                                 for (int SAPNum = 1; SAPNum <= state.dataZoneEquip->NumSupplyAirPaths; ++SAPNum) {
     223         324 :                                     for (int SAPOutNode = 1; SAPOutNode <= state.dataZoneEquip->SupplyAirPath(SAPNum).NumOutletNodes; ++SAPOutNode) {
     224         260 :                                         if (thisZoneEquipConfig.AirDistUnitHeat(ZoneInletNodeNum).InNode ==
     225         260 :                                             state.dataZoneEquip->SupplyAirPath(SAPNum).OutletNode(SAPOutNode)) {
     226          29 :                                             thisZoneEquipConfig.AirDistUnitHeat(ZoneInletNodeNum).SupplyAirPathIndex = SAPNum;
     227          29 :                                             thisZoneEquipConfig.AirDistUnitHeat(ZoneInletNodeNum).SupplyAirPathOutNodeIndex = SAPOutNode;
     228          87 :                                             for (int OutNum = 1; OutNum <= state.dataAirLoop->AirToZoneNodeInfo(AirLoopNum).NumSupplyNodes;
     229             :                                                  ++OutNum) {
     230          58 :                                                 if (state.dataAirLoop->AirToZoneNodeInfo(AirLoopNum).ZoneEquipSupplyNodeNum(OutNum) ==
     231          58 :                                                     state.dataZoneEquip->SupplyAirPath(SAPNum).InletNodeNum) {
     232          29 :                                                     thisZoneEquipConfig.AirDistUnitHeat(ZoneInletNodeNum).SupplyBranchIndex =
     233          29 :                                                         state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum).OutletBranchNum[OutNum - 1];
     234          29 :                                                     if (state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum).Splitter.Exists) {
     235         116 :                                                         for (int MainBranchNum = 1;
     236         116 :                                                              MainBranchNum <= state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum).NumBranches;
     237             :                                                              ++MainBranchNum) {
     238          87 :                                                             if (state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum)
     239          87 :                                                                     .Branch(MainBranchNum)
     240         174 :                                                                     .NodeNumOut ==
     241          87 :                                                                 state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum).Splitter.NodeNumIn) {
     242          29 :                                                                 thisZoneEquipConfig.AirDistUnitHeat(ZoneInletNodeNum).MainBranchIndex = MainBranchNum;
     243             :                                                             }
     244             :                                                         }
     245             :                                                     } else { // no splitter
     246           0 :                                                         thisZoneEquipConfig.AirDistUnitHeat(ZoneInletNodeNum).MainBranchIndex =
     247           0 :                                                             thisZoneEquipConfig.AirDistUnitHeat(ZoneInletNodeNum).SupplyBranchIndex;
     248             :                                                     }
     249             :                                                 }
     250             :                                             }
     251             :                                         }
     252             :                                     }
     253             :                                 }
     254             :                             } else { // no supply air path
     255          94 :                                 if (AirLoopNum > 0) {
     256         188 :                                     for (int NodeIndex = 1; NodeIndex <= state.dataAirLoop->AirToZoneNodeInfo(AirLoopNum).NumSupplyNodes;
     257             :                                          ++NodeIndex) {
     258          94 :                                         if (state.dataAirLoop->AirToZoneNodeInfo(AirLoopNum).ZoneEquipSupplyNodeNum(NodeIndex) ==
     259          94 :                                             thisZoneEquipConfig.AirDistUnitHeat(ZoneInletNodeNum).InNode) {
     260           0 :                                             for (int BranchNum = 1; BranchNum <= state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum).NumBranches;
     261             :                                                  ++BranchNum) {
     262           0 :                                                 if (state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum).Branch(BranchNum).NodeNumOut ==
     263           0 :                                                     state.dataAirLoop->AirToZoneNodeInfo(AirLoopNum).AirLoopSupplyNodeNum(NodeIndex)) {
     264           0 :                                                     thisZoneEquipConfig.AirDistUnitHeat(ZoneInletNodeNum).SupplyBranchIndex = BranchNum;
     265           0 :                                                     if (state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum).Splitter.Exists) {
     266           0 :                                                         for (int MainBranchNum = 1;
     267           0 :                                                              MainBranchNum <= state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum).NumBranches;
     268             :                                                              ++MainBranchNum) {
     269           0 :                                                             if (state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum)
     270           0 :                                                                     .Branch(MainBranchNum)
     271           0 :                                                                     .NodeNumOut ==
     272           0 :                                                                 state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum).Splitter.NodeNumIn) {
     273           0 :                                                                 thisZoneEquipConfig.AirDistUnitHeat(ZoneInletNodeNum).MainBranchIndex = MainBranchNum;
     274             :                                                             }
     275             :                                                         }
     276             :                                                     } else { // no splitter
     277           0 :                                                         thisZoneEquipConfig.AirDistUnitHeat(ZoneInletNodeNum).MainBranchIndex =
     278           0 :                                                             thisZoneEquipConfig.AirDistUnitHeat(ZoneInletNodeNum).SupplyAirPathIndex;
     279             :                                                     }
     280             :                                                 }
     281             :                                             }
     282             :                                         }
     283             :                                     }
     284             :                                 }
     285             :                             }
     286             :                         }
     287             :                     }
     288             :                 }
     289             :             }
     290             :         }
     291             : 
     292        5838 :         for (int CtrlZoneNum = 1; CtrlZoneNum <= state.dataGlobal->NumOfZones; ++CtrlZoneNum) {
     293        5044 :             auto &thisZoneEquipConfig = state.dataZoneEquip->ZoneEquipConfig(CtrlZoneNum);
     294        5044 :             if (!thisZoneEquipConfig.IsControlled) continue;
     295        4309 :             thisZoneEquipConfig.EquipListIndex = Util::FindItemInList(thisZoneEquipConfig.EquipListName, state.dataZoneEquip->ZoneEquipList);
     296        4309 :             int ListNum = thisZoneEquipConfig.EquipListIndex;
     297             :             // loop over the zone supply air path inlet nodes
     298        8772 :             for (int ZoneInletNodeNum = 1; ZoneInletNodeNum <= thisZoneEquipConfig.NumInletNodes; ++ZoneInletNodeNum) {
     299        4463 :                 int AirLoopNum = thisZoneEquipConfig.InletNodeAirLoopNum(ZoneInletNodeNum);
     300             : 
     301             :                 // 1. Find HVAC component plant loop connections
     302        4463 :                 int MainBranchNum = thisZoneEquipConfig.AirDistUnitHeat(ZoneInletNodeNum).MainBranchIndex;
     303        4463 :                 MainBranchNum = max(MainBranchNum, thisZoneEquipConfig.AirDistUnitCool(ZoneInletNodeNum).MainBranchIndex);
     304        4463 :                 if (MainBranchNum > 0) MatchPlantSys(state, AirLoopNum, MainBranchNum);
     305        4463 :                 int SupplyCoolBranchNum = thisZoneEquipConfig.AirDistUnitCool(ZoneInletNodeNum).SupplyBranchIndex;
     306        4463 :                 if (SupplyCoolBranchNum > 0 && (SupplyCoolBranchNum != MainBranchNum)) MatchPlantSys(state, AirLoopNum, SupplyCoolBranchNum);
     307        4463 :                 int SupplyHeatBranchNum = thisZoneEquipConfig.AirDistUnitHeat(ZoneInletNodeNum).SupplyBranchIndex;
     308        4463 :                 if (SupplyHeatBranchNum > 0 && (SupplyHeatBranchNum != MainBranchNum)) MatchPlantSys(state, AirLoopNum, SupplyHeatBranchNum);
     309             : 
     310        4463 :                 int AirDistUnitNum = thisZoneEquipConfig.AirDistUnitCool(ZoneInletNodeNum).AirDistUnitIndex;
     311        4463 :                 AirDistUnitNum = max(AirDistUnitNum, thisZoneEquipConfig.AirDistUnitHeat(ZoneInletNodeNum).AirDistUnitIndex);
     312        4463 :                 if (ListNum > 0 && AirDistUnitNum > 0) {
     313        3654 :                     auto &thisZoneEquipList = state.dataZoneEquip->ZoneEquipList(ListNum);
     314        3654 :                     for (int VarNum = 1; VarNum <= thisZoneEquipList.EquipData(AirDistUnitNum).NumMeteredVars; ++VarNum) {
     315          30 :                         if (thisZoneEquipList.EquipData(AirDistUnitNum).MeteredVar(VarNum).resource == Constant::eResource::EnergyTransfer) {
     316          30 :                             thisZoneEquipList.EquipData(AirDistUnitNum).EnergyTransComp = EnergyTransfer;
     317          30 :                             const std::string &CompType = thisZoneEquipList.EquipData(AirDistUnitNum).TypeOf;
     318          30 :                             const std::string &CompName = thisZoneEquipList.EquipData(AirDistUnitNum).Name;
     319          30 :                             int Idx = 0;
     320          30 :                             int MatchLoop = 0;
     321          30 :                             int MatchLoopType = 0;
     322          30 :                             int MatchBranch = 0;
     323          30 :                             int MatchComp = 0;
     324          30 :                             bool MatchFound = false;
     325          30 :                             FindDemandSideMatch(state, CompType, CompName, MatchFound, MatchLoopType, MatchLoop, MatchBranch, MatchComp);
     326          30 :                             if (MatchFound)
     327           0 :                                 UpdateZoneCompPtrArray(state, Idx, ListNum, AirDistUnitNum, MatchLoopType, MatchLoop, MatchBranch, MatchComp);
     328          30 :                             thisZoneEquipList.EquipData(AirDistUnitNum).ZoneEqToPlantPtr = Idx;
     329          30 :                             break;
     330             :                         }
     331             :                     }
     332        7337 :                     for (int SubEquipNum = 1; SubEquipNum <= thisZoneEquipList.EquipData(AirDistUnitNum).NumSubEquip; ++SubEquipNum) {
     333        3683 :                         for (int VarNum = 1; VarNum <= thisZoneEquipList.EquipData(AirDistUnitNum).SubEquipData(SubEquipNum).NumMeteredVars;
     334             :                              ++VarNum) {
     335          35 :                             if (thisZoneEquipList.EquipData(AirDistUnitNum).SubEquipData(SubEquipNum).MeteredVar(VarNum).resource ==
     336             :                                 Constant::eResource::EnergyTransfer) {
     337          35 :                                 thisZoneEquipList.EquipData(AirDistUnitNum).SubEquipData(SubEquipNum).EnergyTransComp = EnergyTransfer;
     338          35 :                                 const std::string &CompType = thisZoneEquipList.EquipData(AirDistUnitNum).SubEquipData(SubEquipNum).TypeOf;
     339          35 :                                 const std::string &CompName = thisZoneEquipList.EquipData(AirDistUnitNum).SubEquipData(SubEquipNum).Name;
     340          35 :                                 int Idx = 0;
     341          35 :                                 int MatchLoop = 0;
     342          35 :                                 int MatchLoopType = 0;
     343          35 :                                 int MatchBranch = 0;
     344          35 :                                 int MatchComp = 0;
     345          35 :                                 bool MatchFound = false;
     346          35 :                                 FindDemandSideMatch(state, CompType, CompName, MatchFound, MatchLoopType, MatchLoop, MatchBranch, MatchComp);
     347          35 :                                 if (MatchFound)
     348          35 :                                     UpdateZoneSubCompPtrArray(
     349             :                                         state, Idx, ListNum, AirDistUnitNum, SubEquipNum, MatchLoopType, MatchLoop, MatchBranch, MatchComp);
     350          35 :                                 thisZoneEquipList.EquipData(AirDistUnitNum).SubEquipData(SubEquipNum).ZoneEqToPlantPtr = Idx;
     351          35 :                                 break;
     352             :                             }
     353             :                         }
     354        6332 :                         for (int SubSubEquipNum = 1;
     355        6332 :                              SubSubEquipNum <= thisZoneEquipList.EquipData(AirDistUnitNum).SubEquipData(SubEquipNum).NumSubSubEquip;
     356             :                              ++SubSubEquipNum) {
     357        2714 :                             for (int VarNum = 1;
     358        2714 :                                  VarNum <=
     359        2714 :                                  thisZoneEquipList.EquipData(AirDistUnitNum).SubEquipData(SubEquipNum).SubSubEquipData(SubSubEquipNum).NumMeteredVars;
     360             :                                  ++VarNum) {
     361        2649 :                                 if (thisZoneEquipList.EquipData(AirDistUnitNum)
     362        2649 :                                         .SubEquipData(SubEquipNum)
     363        2649 :                                         .SubSubEquipData(SubSubEquipNum)
     364        2649 :                                         .MeteredVar(VarNum)
     365        2649 :                                         .resource == Constant::eResource::EnergyTransfer) {
     366        2584 :                                     thisZoneEquipList.EquipData(AirDistUnitNum)
     367        2584 :                                         .SubEquipData(SubEquipNum)
     368        2584 :                                         .SubSubEquipData(SubSubEquipNum)
     369        2584 :                                         .EnergyTransComp = EnergyTransfer;
     370             :                                     const std::string &CompType =
     371        2584 :                                         thisZoneEquipList.EquipData(AirDistUnitNum).SubEquipData(SubEquipNum).SubSubEquipData(SubSubEquipNum).TypeOf;
     372             :                                     const std::string &CompName =
     373        2584 :                                         thisZoneEquipList.EquipData(AirDistUnitNum).SubEquipData(SubEquipNum).SubSubEquipData(SubSubEquipNum).Name;
     374        2584 :                                     int Idx = 0;
     375        2584 :                                     int MatchLoop = 0;
     376        2584 :                                     int MatchLoopType = 0;
     377        2584 :                                     int MatchBranch = 0;
     378        2584 :                                     int MatchComp = 0;
     379        2584 :                                     bool MatchFound = false;
     380        2584 :                                     FindDemandSideMatch(state, CompType, CompName, MatchFound, MatchLoopType, MatchLoop, MatchBranch, MatchComp);
     381        2584 :                                     if (MatchFound)
     382        2216 :                                         UpdateZoneSubSubCompPtrArray(state,
     383             :                                                                      Idx,
     384             :                                                                      ListNum,
     385             :                                                                      AirDistUnitNum,
     386             :                                                                      SubEquipNum,
     387             :                                                                      SubSubEquipNum,
     388             :                                                                      MatchLoopType,
     389             :                                                                      MatchLoop,
     390             :                                                                      MatchBranch,
     391             :                                                                      MatchComp);
     392        5168 :                                     thisZoneEquipList.EquipData(AirDistUnitNum)
     393        2584 :                                         .SubEquipData(SubEquipNum)
     394        2584 :                                         .SubSubEquipData(SubSubEquipNum)
     395        2584 :                                         .ZoneEqToPlantPtr = Idx;
     396        2584 :                                     break;
     397             :                                 }
     398             :                             }
     399             :                         }
     400             :                     }
     401             :                 }
     402             : 
     403        4463 :                 int EquipNum = 0;
     404        4463 :                 int SubEquipNum = 0;
     405        4463 :                 int SubSubEquipNum = 0;
     406        4463 :                 int CompNum = 0;
     407        4463 :                 int SubCompNum = 0;
     408        4463 :                 int SubSubCompNum = 0;
     409             :                 // Eliminate duplicates in the connection arrays
     410        4463 :                 if (allocated(state.dataAirSystemsData->ZoneCompToPlant)) {
     411           0 :                     EquipNum = isize(state.dataAirSystemsData->ZoneCompToPlant);
     412             :                 }
     413        4463 :                 if (allocated(state.dataAirSystemsData->ZoneSubCompToPlant)) {
     414          35 :                     SubEquipNum = isize(state.dataAirSystemsData->ZoneSubCompToPlant);
     415             :                 }
     416        4463 :                 if (allocated(state.dataAirSystemsData->ZoneSubSubCompToPlant)) {
     417        2476 :                     SubSubEquipNum = isize(state.dataAirSystemsData->ZoneSubSubCompToPlant);
     418             :                 }
     419        4463 :                 if (allocated(state.dataAirSystemsData->AirSysCompToPlant)) {
     420        2585 :                     CompNum = isize(state.dataAirSystemsData->AirSysCompToPlant);
     421             :                 }
     422        4463 :                 if (allocated(state.dataAirSystemsData->AirSysSubCompToPlant)) {
     423           0 :                     SubCompNum = isize(state.dataAirSystemsData->AirSysSubCompToPlant);
     424             :                 }
     425        4463 :                 if (allocated(state.dataAirSystemsData->AirSysSubSubCompToPlant)) {
     426           0 :                     SubSubCompNum = isize(state.dataAirSystemsData->AirSysSubSubCompToPlant);
     427             :                 }
     428             : 
     429        4463 :                 if (EquipNum > 0) {
     430           0 :                     int ArrayCount = 0;
     431           0 :                     for (int i = 1; i <= EquipNum; ++i) {
     432           0 :                         auto const &zi = state.dataAirSystemsData->ZoneCompToPlant(i);
     433           0 :                         bool duplicate(false);
     434           0 :                         for (int j = 1; j <= ArrayCount; ++j) {
     435           0 :                             auto const &zj = state.dataAirSystemsData->ZoneCompToPlant(j);
     436           0 :                             if ((zi.ZoneEqListNum == zj.ZoneEqListNum) && (zi.ZoneEqCompNum == zj.ZoneEqCompNum)) { // Duplicate
     437           0 :                                 duplicate = true;
     438           0 :                                 break;
     439             :                             }
     440             :                         }
     441           0 :                         if (!duplicate) {
     442           0 :                             ++ArrayCount;
     443           0 :                             if (i > ArrayCount) { // Copy to lower position
     444           0 :                                 auto &za = state.dataAirSystemsData->ZoneCompToPlant(ArrayCount);
     445           0 :                                 za.ZoneEqListNum = zi.ZoneEqListNum;
     446           0 :                                 za.ZoneEqCompNum = zi.ZoneEqCompNum;
     447           0 :                                 za.PlantLoopType = zi.PlantLoopType;
     448           0 :                                 za.PlantLoopNum = zi.PlantLoopNum;
     449           0 :                                 za.PlantLoopBranch = zi.PlantLoopBranch;
     450           0 :                                 za.PlantLoopComp = zi.PlantLoopComp;
     451           0 :                                 za.FirstDemandSidePtr = zi.FirstDemandSidePtr;
     452           0 :                                 za.LastDemandSidePtr = zi.LastDemandSidePtr;
     453             :                             }
     454             :                         }
     455             :                     }
     456           0 :                     for (int i = ArrayCount + 1; i <= EquipNum; ++i) { // Zero the now-unused entries
     457           0 :                         auto &zi = state.dataAirSystemsData->ZoneCompToPlant(i);
     458           0 :                         zi.ZoneEqListNum = 0;
     459           0 :                         zi.ZoneEqCompNum = 0;
     460           0 :                         zi.PlantLoopType = 0;
     461           0 :                         zi.PlantLoopNum = 0;
     462           0 :                         zi.PlantLoopBranch = 0;
     463           0 :                         zi.PlantLoopComp = 0;
     464           0 :                         zi.FirstDemandSidePtr = 0;
     465           0 :                         zi.LastDemandSidePtr = 0;
     466             :                     }
     467             :                 }
     468             : 
     469        4463 :                 if (SubEquipNum > 0) {
     470          35 :                     int ArrayCount = 0;
     471        3535 :                     for (int i = 1; i <= SubEquipNum; ++i) {
     472        3500 :                         auto const &zi = state.dataAirSystemsData->ZoneSubCompToPlant(i);
     473        3500 :                         bool duplicate(false);
     474       27605 :                         for (int j = 1; j <= ArrayCount; ++j) {
     475       27315 :                             auto const &zj = state.dataAirSystemsData->ZoneSubCompToPlant(j);
     476       27315 :                             if ((zi.ZoneEqListNum == zj.ZoneEqListNum) && (zi.ZoneEqCompNum == zj.ZoneEqCompNum) &&
     477        3210 :                                 (zi.ZoneEqSubCompNum == zj.ZoneEqSubCompNum)) { // Duplicate
     478        3210 :                                 duplicate = true;
     479        3210 :                                 break;
     480             :                             }
     481             :                         }
     482        3500 :                         if (!duplicate) {
     483         290 :                             ++ArrayCount;
     484         290 :                             if (i > ArrayCount) { // Copy to lower position
     485           0 :                                 auto &za = state.dataAirSystemsData->ZoneSubCompToPlant(ArrayCount);
     486           0 :                                 za.ZoneEqListNum = zi.ZoneEqListNum;
     487           0 :                                 za.ZoneEqCompNum = zi.ZoneEqCompNum;
     488           0 :                                 za.ZoneEqSubCompNum = zi.ZoneEqSubCompNum;
     489           0 :                                 za.PlantLoopType = zi.PlantLoopType;
     490           0 :                                 za.PlantLoopNum = zi.PlantLoopNum;
     491           0 :                                 za.PlantLoopBranch = zi.PlantLoopBranch;
     492           0 :                                 za.PlantLoopComp = zi.PlantLoopComp;
     493           0 :                                 za.FirstDemandSidePtr = zi.FirstDemandSidePtr;
     494           0 :                                 za.LastDemandSidePtr = zi.LastDemandSidePtr;
     495             :                             }
     496             :                         }
     497             :                     }
     498        3245 :                     for (int i = ArrayCount + 1; i <= SubEquipNum; ++i) { // Zero the now-unused entries
     499        3210 :                         auto &zi = state.dataAirSystemsData->ZoneSubCompToPlant(i);
     500        3210 :                         zi.ZoneEqListNum = 0;
     501        3210 :                         zi.ZoneEqCompNum = 0;
     502        3210 :                         zi.ZoneEqSubCompNum = 0;
     503        3210 :                         zi.PlantLoopType = 0;
     504        3210 :                         zi.PlantLoopNum = 0;
     505        3210 :                         zi.PlantLoopBranch = 0;
     506        3210 :                         zi.PlantLoopComp = 0;
     507        3210 :                         zi.FirstDemandSidePtr = 0;
     508        3210 :                         zi.LastDemandSidePtr = 0;
     509             :                     }
     510             :                 }
     511             : 
     512        4463 :                 if (SubSubEquipNum > 0) {
     513        2476 :                     int ArrayCount = 0;
     514      256276 :                     for (int i = 1; i <= SubSubEquipNum; ++i) {
     515      253800 :                         auto const &zi = state.dataAirSystemsData->ZoneSubSubCompToPlant(i);
     516      253800 :                         bool duplicate(false);
     517     4082826 :                         for (int j = 1; j <= ArrayCount; ++j) {
     518     4037816 :                             auto const &zj = state.dataAirSystemsData->ZoneSubSubCompToPlant(j);
     519     4037816 :                             if ((zi.ZoneEqListNum == zj.ZoneEqListNum) && (zi.ZoneEqCompNum == zj.ZoneEqCompNum) &&
     520      208804 :                                 (zi.ZoneEqSubCompNum == zj.ZoneEqSubCompNum) && (zi.ZoneEqSubSubCompNum == zj.ZoneEqSubSubCompNum)) { // Duplicate
     521      208790 :                                 duplicate = true;
     522      208790 :                                 break;
     523             :                             }
     524             :                         }
     525      253800 :                         if (!duplicate) {
     526       45010 :                             ++ArrayCount;
     527       45010 :                             if (i > ArrayCount) { // Copy to lower position
     528           0 :                                 auto &za = state.dataAirSystemsData->ZoneSubSubCompToPlant(ArrayCount);
     529           0 :                                 za.ZoneEqListNum = zi.ZoneEqListNum;
     530           0 :                                 za.ZoneEqCompNum = zi.ZoneEqCompNum;
     531           0 :                                 za.ZoneEqSubCompNum = zi.ZoneEqSubCompNum;
     532           0 :                                 za.ZoneEqSubSubCompNum = zi.ZoneEqSubSubCompNum;
     533           0 :                                 za.PlantLoopType = zi.PlantLoopType;
     534           0 :                                 za.PlantLoopNum = zi.PlantLoopNum;
     535           0 :                                 za.PlantLoopBranch = zi.PlantLoopBranch;
     536           0 :                                 za.PlantLoopComp = zi.PlantLoopComp;
     537           0 :                                 za.FirstDemandSidePtr = zi.FirstDemandSidePtr;
     538           0 :                                 za.LastDemandSidePtr = zi.LastDemandSidePtr;
     539             :                             }
     540             :                         }
     541             :                     }
     542      211266 :                     for (int i = ArrayCount + 1; i <= SubSubEquipNum; ++i) { // Zero the now-unused entries
     543      208790 :                         auto &zi = state.dataAirSystemsData->ZoneSubSubCompToPlant(i);
     544      208790 :                         zi.ZoneEqListNum = 0;
     545      208790 :                         zi.ZoneEqCompNum = 0;
     546      208790 :                         zi.ZoneEqSubCompNum = 0;
     547      208790 :                         zi.ZoneEqSubSubCompNum = 0;
     548      208790 :                         zi.PlantLoopType = 0;
     549      208790 :                         zi.PlantLoopNum = 0;
     550      208790 :                         zi.PlantLoopBranch = 0;
     551      208790 :                         zi.PlantLoopComp = 0;
     552      208790 :                         zi.FirstDemandSidePtr = 0;
     553      208790 :                         zi.LastDemandSidePtr = 0;
     554             :                     }
     555             :                 }
     556             : 
     557        4463 :                 if (CompNum > 0) {
     558        2585 :                     int ArrayCount = 0;
     559      384385 :                     for (int i = 1; i <= CompNum; ++i) {
     560      381800 :                         auto const &ai = state.dataAirSystemsData->AirSysCompToPlant(i);
     561      381800 :                         bool duplicate(false);
     562     2764530 :                         for (int j = 1; j <= ArrayCount; ++j) {
     563     2747439 :                             auto const &aj = state.dataAirSystemsData->AirSysCompToPlant(j);
     564     2747439 :                             if ((ai.AirLoopNum == aj.AirLoopNum) && (ai.AirLoopBranch == aj.AirLoopBranch) &&
     565      388098 :                                 (ai.AirLoopComp == aj.AirLoopComp)) { // Duplicate
     566      364709 :                                 duplicate = true;
     567      364709 :                                 break;
     568             :                             }
     569             :                         }
     570      381800 :                         if (!duplicate) {
     571       17091 :                             ++ArrayCount;
     572       17091 :                             if (i > ArrayCount) { // Copy to lower position
     573         405 :                                 auto &aa = state.dataAirSystemsData->AirSysCompToPlant(ArrayCount);
     574         405 :                                 aa.AirLoopNum = ai.AirLoopNum;
     575         405 :                                 aa.AirLoopBranch = ai.AirLoopBranch;
     576         405 :                                 aa.AirLoopComp = ai.AirLoopComp;
     577         405 :                                 aa.PlantLoopType = ai.PlantLoopType;
     578         405 :                                 aa.PlantLoopNum = ai.PlantLoopNum;
     579         405 :                                 aa.PlantLoopBranch = ai.PlantLoopBranch;
     580         405 :                                 aa.PlantLoopComp = ai.PlantLoopComp;
     581         405 :                                 aa.FirstDemandSidePtr = ai.FirstDemandSidePtr;
     582         405 :                                 aa.LastDemandSidePtr = ai.LastDemandSidePtr;
     583             :                             }
     584             :                         }
     585             :                     }
     586      367294 :                     for (int i = ArrayCount + 1; i <= CompNum; ++i) { // Zero the now-unused entries
     587      364709 :                         auto &ai = state.dataAirSystemsData->AirSysCompToPlant(i);
     588      364709 :                         ai.AirLoopNum = 0;
     589      364709 :                         ai.AirLoopBranch = 0;
     590      364709 :                         ai.AirLoopComp = 0;
     591      364709 :                         ai.PlantLoopType = 0;
     592      364709 :                         ai.PlantLoopNum = 0;
     593      364709 :                         ai.PlantLoopBranch = 0;
     594      364709 :                         ai.PlantLoopComp = 0;
     595      364709 :                         ai.FirstDemandSidePtr = 0;
     596      364709 :                         ai.LastDemandSidePtr = 0;
     597             :                     }
     598             :                 }
     599             : 
     600        4463 :                 if (SubCompNum > 0) {
     601           0 :                     int ArrayCount = 0;
     602           0 :                     for (int i = 1; i <= SubCompNum; ++i) {
     603           0 :                         auto const &ai = state.dataAirSystemsData->AirSysSubCompToPlant(i);
     604           0 :                         bool duplicate(false);
     605           0 :                         for (int j = 1; j <= ArrayCount; ++j) {
     606           0 :                             auto const &aj = state.dataAirSystemsData->AirSysSubCompToPlant(j);
     607           0 :                             if ((ai.AirLoopNum == aj.AirLoopNum) && (ai.AirLoopBranch == aj.AirLoopBranch) && (ai.AirLoopComp == aj.AirLoopComp) &&
     608           0 :                                 (ai.AirLoopSubComp == aj.AirLoopSubComp)) { // Duplicate
     609           0 :                                 duplicate = true;
     610           0 :                                 break;
     611             :                             }
     612             :                         }
     613           0 :                         if (!duplicate) {
     614           0 :                             ++ArrayCount;
     615           0 :                             if (i > ArrayCount) { // Copy to lower position
     616           0 :                                 auto &aa = state.dataAirSystemsData->AirSysSubCompToPlant(ArrayCount);
     617           0 :                                 aa.AirLoopNum = ai.AirLoopNum;
     618           0 :                                 aa.AirLoopBranch = ai.AirLoopBranch;
     619           0 :                                 aa.AirLoopComp = ai.AirLoopComp;
     620           0 :                                 aa.AirLoopSubComp = ai.AirLoopSubComp;
     621           0 :                                 aa.PlantLoopType = ai.PlantLoopType;
     622           0 :                                 aa.PlantLoopNum = ai.PlantLoopNum;
     623           0 :                                 aa.PlantLoopBranch = ai.PlantLoopBranch;
     624           0 :                                 aa.PlantLoopComp = ai.PlantLoopComp;
     625           0 :                                 aa.FirstDemandSidePtr = ai.FirstDemandSidePtr;
     626           0 :                                 aa.LastDemandSidePtr = ai.LastDemandSidePtr;
     627             :                             }
     628             :                         }
     629             :                     }
     630           0 :                     for (int i = ArrayCount + 1; i <= SubCompNum; ++i) { // Zero the now-unused entries
     631           0 :                         auto &ai = state.dataAirSystemsData->AirSysSubCompToPlant(i);
     632           0 :                         ai.AirLoopNum = 0;
     633           0 :                         ai.AirLoopBranch = 0;
     634           0 :                         ai.AirLoopComp = 0;
     635           0 :                         ai.AirLoopSubComp = 0;
     636           0 :                         ai.PlantLoopType = 0;
     637           0 :                         ai.PlantLoopNum = 0;
     638           0 :                         ai.PlantLoopBranch = 0;
     639           0 :                         ai.PlantLoopComp = 0;
     640           0 :                         ai.FirstDemandSidePtr = 0;
     641           0 :                         ai.LastDemandSidePtr = 0;
     642             :                     }
     643             :                 }
     644             : 
     645        4463 :                 if (SubSubCompNum > 0) {
     646           0 :                     int ArrayCount = 0;
     647           0 :                     for (int i = 1; i <= SubCompNum; ++i) {
     648           0 :                         auto const &ai = state.dataAirSystemsData->AirSysSubSubCompToPlant(i);
     649           0 :                         bool duplicate = false;
     650           0 :                         for (int j = 1; j <= ArrayCount; ++j) {
     651           0 :                             auto const &aj = state.dataAirSystemsData->AirSysSubSubCompToPlant(j);
     652           0 :                             if ((ai.AirLoopNum == aj.AirLoopNum) && (ai.AirLoopBranch == aj.AirLoopBranch) && (ai.AirLoopComp == aj.AirLoopComp) &&
     653           0 :                                 (ai.AirLoopSubComp == aj.AirLoopSubComp) && (ai.AirLoopSubSubComp == aj.AirLoopSubSubComp)) { // Duplicate
     654           0 :                                 duplicate = true;
     655           0 :                                 break;
     656             :                             }
     657             :                         }
     658           0 :                         if (!duplicate) {
     659           0 :                             ++ArrayCount;
     660           0 :                             if (i > ArrayCount) { // Copy to lower position
     661           0 :                                 auto &aa = state.dataAirSystemsData->AirSysSubSubCompToPlant(ArrayCount);
     662           0 :                                 aa.AirLoopNum = ai.AirLoopNum;
     663           0 :                                 aa.AirLoopBranch = ai.AirLoopBranch;
     664           0 :                                 aa.AirLoopComp = ai.AirLoopComp;
     665           0 :                                 aa.AirLoopSubComp = ai.AirLoopSubComp;
     666           0 :                                 aa.AirLoopSubSubComp = ai.AirLoopSubSubComp;
     667           0 :                                 aa.PlantLoopType = ai.PlantLoopType;
     668           0 :                                 aa.PlantLoopNum = ai.PlantLoopNum;
     669           0 :                                 aa.PlantLoopBranch = ai.PlantLoopBranch;
     670           0 :                                 aa.PlantLoopComp = ai.PlantLoopComp;
     671           0 :                                 aa.FirstDemandSidePtr = ai.FirstDemandSidePtr;
     672           0 :                                 aa.LastDemandSidePtr = ai.LastDemandSidePtr;
     673             :                             }
     674             :                         }
     675             :                     }
     676           0 :                     for (int i = ArrayCount + 1; i <= SubCompNum; ++i) { // Zero the now-unused entries
     677           0 :                         auto &ai = state.dataAirSystemsData->AirSysSubSubCompToPlant(i);
     678           0 :                         ai.AirLoopNum = 0;
     679           0 :                         ai.AirLoopBranch = 0;
     680           0 :                         ai.AirLoopComp = 0;
     681           0 :                         ai.AirLoopSubComp = 0;
     682           0 :                         ai.AirLoopSubSubComp = 0;
     683           0 :                         ai.PlantLoopType = 0;
     684           0 :                         ai.PlantLoopNum = 0;
     685           0 :                         ai.PlantLoopBranch = 0;
     686           0 :                         ai.PlantLoopComp = 0;
     687           0 :                         ai.FirstDemandSidePtr = 0;
     688           0 :                         ai.LastDemandSidePtr = 0;
     689             :                     }
     690             :                 }
     691             : 
     692             :                 // 2. Find Supply Side loop for every demand side component
     693             :                 // The demand side components only need to know what supply side loop
     694             :                 // they are connected to.  The input and plant data structure will
     695             :                 // force the loop numbers to be the same.
     696             : 
     697             :                 // 3. Find Demand Side Component Corresponding to Supply Side Component
     698       12672 :                 for (int PlantLoopNum = 1; PlantLoopNum <= state.dataHVACGlobal->NumPlantLoops; ++PlantLoopNum) {
     699       41963 :                     for (int BranchNum = 1;
     700       41963 :                          BranchNum <= state.dataPlnt->VentRepPlant[static_cast<int>(LoopSideLocation::Supply)](PlantLoopNum).TotalBranches;
     701             :                          ++BranchNum) {
     702       33754 :                         for (CompNum = 1;
     703       68295 :                              CompNum <=
     704       68295 :                              state.dataPlnt->VentRepPlant[static_cast<int>(LoopSideLocation::Supply)](PlantLoopNum).Branch(BranchNum).TotalComponents;
     705             :                              ++CompNum) {
     706             :                             {
     707       34541 :                                 auto &thisVentRepComp = state.dataPlnt->VentRepPlant[static_cast<int>(LoopSideLocation::Supply)](PlantLoopNum)
     708       34541 :                                                             .Branch(BranchNum)
     709       34541 :                                                             .Comp(CompNum);
     710       34541 :                                 const std::string &CompType = thisVentRepComp.TypeOf;
     711       34541 :                                 const std::string &CompName = thisVentRepComp.Name;
     712       34541 :                                 int MatchLoop = 0;
     713       34541 :                                 int MatchLoopType = 0;
     714       34541 :                                 int MatchBranch = 0;
     715       34541 :                                 int MatchComp = 0;
     716       34541 :                                 bool MatchFound = false;
     717       34541 :                                 FindDemandSideMatch(state, CompType, CompName, MatchFound, MatchLoopType, MatchLoop, MatchBranch, MatchComp);
     718       34541 :                                 thisVentRepComp.ConnectPlant.LoopType = MatchLoopType;
     719       34541 :                                 thisVentRepComp.ConnectPlant.LoopNum = MatchLoop;
     720       34541 :                                 thisVentRepComp.ConnectPlant.BranchNum = MatchBranch;
     721       34541 :                                 thisVentRepComp.ConnectPlant.CompNum = MatchComp;
     722             :                             }
     723             :                         }
     724             :                     }
     725             :                 }
     726             : 
     727        6178 :                 for (int PlantLoopNum = 1; PlantLoopNum <= state.dataHVACGlobal->NumCondLoops; ++PlantLoopNum) {
     728        8769 :                     for (int BranchNum = 1;
     729        8769 :                          BranchNum <= state.dataPlnt->VentRepCond[static_cast<int>(LoopSideLocation::Supply)](PlantLoopNum).TotalBranches;
     730             :                          ++BranchNum) {
     731        7054 :                         for (CompNum = 1;
     732       14166 :                              CompNum <=
     733       14166 :                              state.dataPlnt->VentRepCond[static_cast<int>(LoopSideLocation::Supply)](PlantLoopNum).Branch(BranchNum).TotalComponents;
     734             :                              ++CompNum) {
     735             :                             {
     736        7112 :                                 auto &thisVentRepComp = state.dataPlnt->VentRepCond[static_cast<int>(LoopSideLocation::Supply)](PlantLoopNum)
     737        7112 :                                                             .Branch(BranchNum)
     738        7112 :                                                             .Comp(CompNum);
     739        7112 :                                 const std::string &CompType = thisVentRepComp.TypeOf;
     740        7112 :                                 const std::string &CompName = thisVentRepComp.Name;
     741        7112 :                                 int MatchLoop = 0;
     742        7112 :                                 int MatchLoopType = 0;
     743        7112 :                                 int MatchBranch = 0;
     744        7112 :                                 int MatchComp = 0;
     745        7112 :                                 bool MatchFound = false;
     746        7112 :                                 FindDemandSideMatch(state, CompType, CompName, MatchFound, MatchLoopType, MatchLoop, MatchBranch, MatchComp);
     747        7112 :                                 thisVentRepComp.ConnectPlant.LoopType = MatchLoopType;
     748        7112 :                                 thisVentRepComp.ConnectPlant.LoopNum = MatchLoop;
     749        7112 :                                 thisVentRepComp.ConnectPlant.BranchNum = MatchBranch;
     750        7112 :                                 thisVentRepComp.ConnectPlant.CompNum = MatchComp;
     751             :                             }
     752             :                         }
     753             :                     }
     754             :                 }
     755             :             }
     756             :         } // Controlled Zone Loop
     757             : 
     758             :         // 4.  Now Load all of the plant supply/demand side connections in a single array with pointers from the
     759             :         //    connection arrays (ZoneCompToPlant, ZoneSubCompToPlant, ZoneSubSubCompToPlant, AirSysCompToPlant, etc.)
     760         794 :         int NumZoneConnectComps = 0;
     761         794 :         int NumZoneConnectSubComps = 0;
     762         794 :         int NumZoneConnectSubSubComps = 0;
     763         794 :         int NumAirSysConnectComps = 0;
     764         794 :         int NumAirSysConnectSubComps = 0;
     765         794 :         int NumAirSysConnectSubSubComps = 0;
     766         794 :         if (allocated(state.dataAirSystemsData->ZoneCompToPlant)) {
     767           0 :             NumZoneConnectComps = isize(state.dataAirSystemsData->ZoneCompToPlant);
     768             :         }
     769         794 :         if (allocated(state.dataAirSystemsData->ZoneSubCompToPlant)) {
     770           3 :             NumZoneConnectSubComps = isize(state.dataAirSystemsData->ZoneSubCompToPlant);
     771             :         }
     772         794 :         if (allocated(state.dataAirSystemsData->ZoneSubSubCompToPlant)) {
     773         269 :             NumZoneConnectSubSubComps = isize(state.dataAirSystemsData->ZoneSubSubCompToPlant);
     774             :         }
     775         794 :         if (allocated(state.dataAirSystemsData->AirSysCompToPlant)) {
     776         292 :             NumAirSysConnectComps = isize(state.dataAirSystemsData->AirSysCompToPlant);
     777             :         }
     778         794 :         if (allocated(state.dataAirSystemsData->AirSysSubCompToPlant)) {
     779           0 :             NumAirSysConnectSubComps = isize(state.dataAirSystemsData->AirSysSubCompToPlant);
     780             :         }
     781         794 :         if (allocated(state.dataAirSystemsData->AirSysSubSubCompToPlant)) {
     782           0 :             NumAirSysConnectSubSubComps = isize(state.dataAirSystemsData->AirSysSubSubCompToPlant);
     783             :         }
     784         794 :         state.dataSysRpts->OneTimeFlag_InitEnergyReports = false;
     785             : 
     786         794 :         int ArrayCount = 0;
     787         794 :         for (int CompNum = 1; CompNum <= NumZoneConnectComps; ++CompNum) {
     788           0 :             int LoopType = state.dataAirSystemsData->ZoneCompToPlant(CompNum).PlantLoopType;
     789           0 :             int LoopNum = state.dataAirSystemsData->ZoneCompToPlant(CompNum).PlantLoopNum;
     790           0 :             int FirstIndex = ArrayCount + 1;
     791           0 :             int LoopCount = 1;
     792           0 :             bool ConnectionFlag = false;
     793             : 
     794           0 :             if (LoopType > 0 && LoopNum > 0) {
     795           0 :                 FindFirstLastPtr(state, LoopType, LoopNum, ArrayCount, LoopCount, ConnectionFlag);
     796             :             }
     797             : 
     798           0 :             int LastIndex = ArrayCount;
     799           0 :             if (FirstIndex > LastIndex) FirstIndex = LastIndex;
     800           0 :             if (ConnectionFlag) {
     801           0 :                 state.dataAirSystemsData->ZoneCompToPlant(CompNum).FirstDemandSidePtr = FirstIndex;
     802           0 :                 state.dataAirSystemsData->ZoneCompToPlant(CompNum).LastDemandSidePtr = LastIndex;
     803             :             }
     804             :         }
     805             : 
     806        1094 :         for (int SubCompNum = 1; SubCompNum <= NumZoneConnectSubComps; ++SubCompNum) {
     807         300 :             int LoopType = state.dataAirSystemsData->ZoneSubCompToPlant(SubCompNum).PlantLoopType;
     808         300 :             int LoopNum = state.dataAirSystemsData->ZoneSubCompToPlant(SubCompNum).PlantLoopNum;
     809         300 :             int FirstIndex = ArrayCount + 1;
     810         300 :             int LoopCount = 1;
     811             : 
     812         300 :             bool ConnectionFlag = false;
     813         300 :             if (LoopType > 0 && LoopNum > 0) {
     814          35 :                 FindFirstLastPtr(state, LoopType, LoopNum, ArrayCount, LoopCount, ConnectionFlag);
     815             :             }
     816             : 
     817         300 :             int LastIndex = ArrayCount;
     818         300 :             if (FirstIndex > LastIndex) FirstIndex = LastIndex;
     819         300 :             if (ConnectionFlag) {
     820           0 :                 state.dataAirSystemsData->ZoneSubCompToPlant(SubCompNum).FirstDemandSidePtr = FirstIndex;
     821           0 :                 state.dataAirSystemsData->ZoneSubCompToPlant(SubCompNum).LastDemandSidePtr = LastIndex;
     822             :             }
     823             :         }
     824             : 
     825       27894 :         for (int SubSubCompNum = 1; SubSubCompNum <= NumZoneConnectSubSubComps; ++SubSubCompNum) {
     826       27100 :             int LoopType = state.dataAirSystemsData->ZoneSubSubCompToPlant(SubSubCompNum).PlantLoopType;
     827       27100 :             int LoopNum = state.dataAirSystemsData->ZoneSubSubCompToPlant(SubSubCompNum).PlantLoopNum;
     828       27100 :             int FirstIndex = ArrayCount + 1;
     829       27100 :             int LoopCount = 1;
     830       27100 :             bool ConnectionFlag = false;
     831             : 
     832       27100 :             if (LoopType > 0 && LoopNum > 0) {
     833        2216 :                 FindFirstLastPtr(state, LoopType, LoopNum, ArrayCount, LoopCount, ConnectionFlag);
     834             :             }
     835             : 
     836       27100 :             int LastIndex = ArrayCount;
     837       27100 :             if (FirstIndex > LastIndex) FirstIndex = LastIndex;
     838       27100 :             if (ConnectionFlag) {
     839           0 :                 state.dataAirSystemsData->ZoneSubSubCompToPlant(SubSubCompNum).FirstDemandSidePtr = FirstIndex;
     840           0 :                 state.dataAirSystemsData->ZoneSubSubCompToPlant(SubSubCompNum).LastDemandSidePtr = LastIndex;
     841             :             }
     842             :         }
     843       31894 :         for (int CompNum = 1; CompNum <= NumAirSysConnectComps; ++CompNum) {
     844       31100 :             int LoopType = state.dataAirSystemsData->AirSysCompToPlant(CompNum).PlantLoopType;
     845       31100 :             int LoopNum = state.dataAirSystemsData->AirSysCompToPlant(CompNum).PlantLoopNum;
     846       31100 :             int FirstIndex = ArrayCount + 1;
     847       31100 :             int LoopCount = 1;
     848       31100 :             bool ConnectionFlag = false;
     849             : 
     850       31100 :             if (LoopType > 0 && LoopNum > 0) {
     851         802 :                 FindFirstLastPtr(state, LoopType, LoopNum, ArrayCount, LoopCount, ConnectionFlag);
     852             :             }
     853             : 
     854       31100 :             int LastIndex = ArrayCount;
     855       31100 :             if (FirstIndex > LastIndex) FirstIndex = LastIndex;
     856       31100 :             if (ConnectionFlag) {
     857           0 :                 state.dataAirSystemsData->AirSysCompToPlant(CompNum).FirstDemandSidePtr = FirstIndex;
     858           0 :                 state.dataAirSystemsData->AirSysCompToPlant(CompNum).LastDemandSidePtr = LastIndex;
     859             :             }
     860             :         }
     861             : 
     862         794 :         for (int SubCompNum = 1; SubCompNum <= NumAirSysConnectSubComps; ++SubCompNum) {
     863           0 :             int LoopType = state.dataAirSystemsData->AirSysSubCompToPlant(SubCompNum).PlantLoopType;
     864           0 :             int LoopNum = state.dataAirSystemsData->AirSysSubCompToPlant(SubCompNum).PlantLoopNum;
     865           0 :             int FirstIndex = ArrayCount + 1;
     866           0 :             int LoopCount = 1;
     867           0 :             bool ConnectionFlag = false;
     868             : 
     869           0 :             if (LoopType > 0 && LoopNum > 0) {
     870           0 :                 FindFirstLastPtr(state, LoopType, LoopNum, ArrayCount, LoopCount, ConnectionFlag);
     871             :             }
     872             : 
     873           0 :             int LastIndex = ArrayCount;
     874           0 :             if (FirstIndex > LastIndex) FirstIndex = LastIndex;
     875           0 :             if (ConnectionFlag) {
     876           0 :                 state.dataAirSystemsData->AirSysSubCompToPlant(SubCompNum).FirstDemandSidePtr = FirstIndex;
     877           0 :                 state.dataAirSystemsData->AirSysSubCompToPlant(SubCompNum).LastDemandSidePtr = LastIndex;
     878             :             }
     879             :         }
     880             : 
     881         794 :         for (int SubSubCompNum = 1; SubSubCompNum <= NumAirSysConnectSubSubComps; ++SubSubCompNum) {
     882           0 :             int LoopType = state.dataAirSystemsData->AirSysSubSubCompToPlant(SubSubCompNum).PlantLoopType;
     883           0 :             int LoopNum = state.dataAirSystemsData->AirSysSubSubCompToPlant(SubSubCompNum).PlantLoopNum;
     884           0 :             int FirstIndex = ArrayCount + 1;
     885           0 :             int LoopCount = 1;
     886           0 :             bool ConnectionFlag = false;
     887             : 
     888           0 :             if (LoopType > 0 && LoopNum > 0) {
     889           0 :                 FindFirstLastPtr(state, LoopType, LoopNum, ArrayCount, LoopCount, ConnectionFlag);
     890             :             }
     891             : 
     892           0 :             int LastIndex = ArrayCount;
     893           0 :             if (FirstIndex > LastIndex) FirstIndex = LastIndex;
     894           0 :             if (ConnectionFlag) {
     895           0 :                 state.dataAirSystemsData->AirSysSubSubCompToPlant(SubSubCompNum).FirstDemandSidePtr = FirstIndex;
     896           0 :                 state.dataAirSystemsData->AirSysSubSubCompToPlant(SubSubCompNum).LastDemandSidePtr = LastIndex;
     897             :             }
     898             :         }
     899             : 
     900         794 :         reportAirLoopToplogy(state);
     901             : 
     902         794 :         reportZoneEquipmentToplogy(state);
     903             : 
     904         794 :         reportAirDistributionUnits(state);
     905             : 
     906         794 :         state.dataSysRpts->OneTimeFlag_InitEnergyReports = false;
     907             :     }
     908             : 
     909             :     // On every iteration, load the air loop energy data
     910     1462657 :     for (int AirLoopNum = 1; AirLoopNum <= state.dataHVACGlobal->NumPrimaryAirSys; ++AirLoopNum) {
     911      847428 :         auto &pas = state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum);
     912     1705116 :         for (int BranchNum = 1; BranchNum <= pas.NumBranches; ++BranchNum) {
     913      857688 :             auto &pasBranch = pas.Branch(BranchNum);
     914     3349339 :             for (int CompNum = 1; CompNum <= pasBranch.TotalComponents; ++CompNum) {
     915     2491651 :                 auto &pasBranchComp = pasBranch.Comp(CompNum);
     916     5212486 :                 for (int VarNum = 1; VarNum <= pasBranchComp.NumMeteredVars; ++VarNum) {
     917     2720835 :                     auto &pasBranchCompMeter = pasBranchComp.MeteredVar(VarNum);
     918     2720835 :                     OutputProcessor::VariableType VarType = pasBranchCompMeter.varType;
     919     2720835 :                     int VarIndex = pasBranchCompMeter.num;
     920     2720835 :                     pasBranchCompMeter.curMeterReading = GetInternalVariableValue(state, VarType, VarIndex);
     921             :                 }
     922     5095003 :                 for (int SubCompNum = 1; SubCompNum <= pasBranchComp.NumSubComps; ++SubCompNum) {
     923     2603352 :                     auto &pasBranchSubComp = pasBranchComp.SubComp(SubCompNum);
     924     7087683 :                     for (int VarNum = 1; VarNum <= pasBranchSubComp.NumMeteredVars; ++VarNum) {
     925     4484331 :                         auto &pasBranchSubCompMeter = pasBranchSubComp.MeteredVar(VarNum);
     926     4484331 :                         OutputProcessor::VariableType VarType = pasBranchSubCompMeter.varType;
     927     4484331 :                         int VarIndex = pasBranchSubCompMeter.num;
     928     4484331 :                         pasBranchSubCompMeter.curMeterReading = GetInternalVariableValue(state, VarType, VarIndex);
     929             :                     }
     930     2615512 :                     for (int SubSubCompNum = 1; SubSubCompNum <= pasBranchSubComp.NumSubSubComps; ++SubSubCompNum) {
     931       12160 :                         auto &pasBranchSubSubComp = pasBranchSubComp.SubSubComp(SubSubCompNum);
     932       47215 :                         for (int VarNum = 1; VarNum <= pasBranchSubSubComp.NumMeteredVars; ++VarNum) {
     933       35055 :                             auto &pasBranchSubSubCompMeter = pasBranchSubSubComp.MeteredVar(VarNum);
     934       35055 :                             OutputProcessor::VariableType VarType = pasBranchSubSubCompMeter.varType;
     935       35055 :                             int VarIndex = pasBranchSubSubCompMeter.num;
     936       35055 :                             pasBranchSubSubCompMeter.curMeterReading = GetInternalVariableValue(state, VarType, VarIndex);
     937             :                         }
     938             :                     }
     939             :                 }
     940             :             }
     941             :         }
     942             :     }
     943             : 
     944             :     // On every iteration, load the zone equipment energy data
     945     4001607 :     for (int ListNum = 1; ListNum <= state.dataGlobal->NumOfZones; ++ListNum) {
     946     3386378 :         if (!state.dataZoneEquip->ZoneEquipConfig(ListNum).IsControlled) continue;
     947     2913258 :         auto &zel = state.dataZoneEquip->ZoneEquipList(ListNum);
     948     6023115 :         for (int CompNum = 1; CompNum <= zel.NumOfEquipTypes; ++CompNum) {
     949     3109857 :             auto &zelEquipData = zel.EquipData(CompNum);
     950     4502183 :             for (int VarNum = 1; VarNum <= zelEquipData.NumMeteredVars; ++VarNum) {
     951     1392326 :                 auto &zelEquipDataMeter = zelEquipData.MeteredVar(VarNum);
     952     1392326 :                 OutputProcessor::VariableType VarType = zelEquipDataMeter.varType;
     953     1392326 :                 int VarIndex = zelEquipDataMeter.num;
     954     1392326 :                 zelEquipDataMeter.curMeterReading = GetInternalVariableValue(state, VarType, VarIndex);
     955             :             }
     956     6124627 :             for (int SubCompNum = 1; SubCompNum <= zelEquipData.NumSubEquip; ++SubCompNum) {
     957     3014770 :                 auto &zelSubEquipData = zelEquipData.SubEquipData(SubCompNum);
     958     4227855 :                 for (int VarNum = 1; VarNum <= zelSubEquipData.NumMeteredVars; ++VarNum) {
     959     1213085 :                     auto &zelSubEquipDataMeter = zelSubEquipData.MeteredVar(VarNum);
     960     1213085 :                     OutputProcessor::VariableType VarType = zelSubEquipDataMeter.varType;
     961     1213085 :                     int VarIndex = zelSubEquipDataMeter.num;
     962     1213085 :                     zelSubEquipDataMeter.curMeterReading = GetInternalVariableValue(state, VarType, VarIndex);
     963             :                 }
     964     4630029 :                 for (int SubSubCompNum = 1; SubSubCompNum <= zelSubEquipData.NumSubSubEquip; ++SubSubCompNum) {
     965     1615259 :                     auto &zelSubSubEquipData = zelSubEquipData.SubSubEquipData(SubSubCompNum);
     966     4903332 :                     for (int VarNum = 1; VarNum <= zelSubSubEquipData.NumMeteredVars; ++VarNum) {
     967     3288073 :                         auto &zelSubSubEquipDataMeter = zelSubSubEquipData.MeteredVar(VarNum);
     968     3288073 :                         OutputProcessor::VariableType VarType = zelSubSubEquipDataMeter.varType;
     969     3288073 :                         int VarIndex = zelSubSubEquipDataMeter.num;
     970     3288073 :                         zelSubSubEquipDataMeter.curMeterReading = GetInternalVariableValue(state, VarType, VarIndex); // Sankar Corrected zone array
     971             :                     }
     972             :                 }
     973             :             }
     974             :         }
     975             :     }
     976             : 
     977             :     // On every iteration, load the Plant Supply Side Data and load the Plant Demand Side Data
     978     1845687 :     for (LoopSideLocation LoopSide : DataPlant::LoopSideKeys) {
     979     2301842 :         for (int PlantLoopNum = 1; PlantLoopNum <= state.dataHVACGlobal->NumPlantLoops; ++PlantLoopNum) {
     980     1071384 :             auto &vrp = state.dataPlnt->VentRepPlant[static_cast<int>(LoopSide)](PlantLoopNum);
     981     7744985 :             for (int BranchNum = 1; BranchNum <= vrp.TotalBranches; ++BranchNum) {
     982     6673601 :                 auto &vrpBranch = vrp.Branch(BranchNum);
     983    13363572 :                 for (int CompNum = 1; CompNum <= vrpBranch.TotalComponents; ++CompNum) {
     984     6689971 :                     auto &vrpBranchComp = vrpBranch.Comp(CompNum);
     985    15934474 :                     for (int VarNum = 1; VarNum <= vrpBranchComp.NumMeteredVars; ++VarNum) {
     986     9244503 :                         auto &vrpBranchCompMeter = vrpBranchComp.MeteredVar(VarNum);
     987     9244503 :                         OutputProcessor::VariableType VarType = vrpBranchCompMeter.varType;
     988     9244503 :                         int VarIndex = vrpBranchCompMeter.num;
     989     9244503 :                         vrpBranchCompMeter.curMeterReading = GetInternalVariableValue(state, VarType, VarIndex);
     990             :                     }
     991             :                 }
     992             :             }
     993             :         }
     994             : 
     995             :         // On every iteration, load the Condenser Supply Side Data and load the Condenser Demand Side Data
     996     1440586 :         for (int PlantLoopNum = 1; PlantLoopNum <= state.dataHVACGlobal->NumCondLoops; ++PlantLoopNum) {
     997      210128 :             auto &vrc = state.dataPlnt->VentRepCond[static_cast<int>(LoopSide)](PlantLoopNum);
     998     1143276 :             for (int BranchNum = 1; BranchNum <= vrc.TotalBranches; ++BranchNum) {
     999      933148 :                 auto &vrcBranch = vrc.Branch(BranchNum);
    1000     1875558 :                 for (int CompNum = 1; CompNum <= vrcBranch.TotalComponents; ++CompNum) {
    1001      942410 :                     auto &vrcBranchComp = vrcBranch.Comp(CompNum);
    1002     1964308 :                     for (int VarNum = 1; VarNum <= vrcBranchComp.NumMeteredVars; ++VarNum) {
    1003     1021898 :                         auto &vrcBranchCompMeter = vrcBranchComp.MeteredVar(VarNum);
    1004     1021898 :                         OutputProcessor::VariableType VarType = vrcBranchCompMeter.varType;
    1005     1021898 :                         int VarIndex = vrcBranchCompMeter.num;
    1006     1021898 :                         vrcBranchCompMeter.curMeterReading = GetInternalVariableValue(state, VarType, VarIndex);
    1007             :                     }
    1008             :                 }
    1009             :             }
    1010             :         }
    1011             :     }
    1012             :     // initialize energy report variables
    1013             : }
    1014             : 
    1015        3053 : void FindFirstLastPtr(EnergyPlusData &state, int &LoopType, int &LoopNum, int &ArrayCount, int &LoopCount, bool &ConnectionFlag)
    1016             : {
    1017             :     // SUBROUTINE INFORMATION:
    1018             :     //       AUTHOR         Dan Fisher
    1019             :     //       DATE WRITTEN   July 2005
    1020             :     //       MODIFIED
    1021             :     //       RE-ENGINEERED  na
    1022             : 
    1023             :     // PURPOSE OF THIS SUBROUTINE:
    1024             :     // Initializes the energy components of the data structures
    1025             : 
    1026             :     // METHODOLOGY EMPLOYED:
    1027             :     // Once all compsets have been established (second iteration) find all components
    1028             :     // subcomponents, etc.
    1029             : 
    1030             :     int DemandSideLoopNum;
    1031             :     int DemandSideBranchNum;
    1032             :     int DemandSideCompNum;
    1033             :     int SupplySideCompNum;
    1034             :     int DemandSideLoopType;
    1035             :     bool found;
    1036             : 
    1037             :     // Object Data
    1038        3053 :     auto &LoopStack = state.dataSysRpts->LoopStack;
    1039             : 
    1040        3053 :     return; // Autodesk:? Is this routine now an intentional NOOP?
    1041             : 
    1042             :     if (state.dataSysRpts->OneTimeFlag_FindFirstLastPtr) {
    1043             :         LoopStack.allocate(state.dataSysRpts->MaxLoopArraySize);
    1044             :         state.dataAirSystemsData->DemandSideConnect.allocate(state.dataSysRpts->MaxCompArraySize);
    1045             : 
    1046             :         state.dataSysRpts->OneTimeFlag_FindFirstLastPtr = false;
    1047             :     }
    1048             :     for (auto &e : LoopStack) {
    1049             :         e.LoopNum = 0;
    1050             :         e.LoopType = 0;
    1051             :     }
    1052             : 
    1053             :     ConnectionFlag = false;
    1054             :     //    countloop=0
    1055             :     //    write(outputfiledebug,*) '1228=lt,lc,lnum,cflag,arrcnt',looptype,loopcount,LoopNum,connectionflag,arraycount
    1056             : 
    1057             :     while (LoopCount > 0) {
    1058             :         //        write(outputfiledebug,*) '1231==lt,lc,lnum,cflag,arrcnt',looptype,loopcount,LoopNum,connectionflag,arraycount
    1059             :         //        write(outputfiledebug,*) 'loop=plname',TRIM(plantloop(LoopNum)%name)
    1060             :         --LoopCount;
    1061             :         //        countloop=countloop+1
    1062             :         //        if (countloop > 100) exit
    1063             :         if (LoopType == 1) {
    1064             :             for (int BranchNum = 1; BranchNum <= state.dataPlnt->VentRepPlant[static_cast<int>(LoopSideLocation::Supply)](LoopNum).TotalBranches;
    1065             :                  ++BranchNum) {
    1066             :                 for (int SupplySideCompNum = 1;
    1067             :                      SupplySideCompNum <=
    1068             :                      state.dataPlnt->VentRepPlant[static_cast<int>(LoopSideLocation::Supply)](LoopNum).Branch(BranchNum).TotalComponents;
    1069             :                      ++SupplySideCompNum) {
    1070             :                     {
    1071             :                         auto const &thisVentRepComp =
    1072             :                             state.dataPlnt->VentRepPlant[static_cast<int>(LoopSideLocation::Supply)](LoopNum).Branch(BranchNum).Comp(
    1073             :                                 SupplySideCompNum);
    1074             :                         DemandSideLoopType = thisVentRepComp.ConnectPlant.LoopType;
    1075             :                         DemandSideLoopNum = thisVentRepComp.ConnectPlant.LoopNum;
    1076             :                         DemandSideBranchNum = thisVentRepComp.ConnectPlant.BranchNum;
    1077             :                         DemandSideCompNum = thisVentRepComp.ConnectPlant.CompNum;
    1078             :                     }
    1079             :                     // If the connection is valid load the connection array
    1080             :                     if (DemandSideLoopType == 1 || DemandSideLoopType == 2) {
    1081             :                         ConnectionFlag = true;
    1082             :                         ++ArrayCount;
    1083             :                         if (ArrayCount > state.dataSysRpts->MaxCompArraySize) {
    1084             :                             state.dataAirSystemsData->DemandSideConnect.redimension(state.dataSysRpts->MaxCompArraySize += 100);
    1085             :                         }
    1086             :                         state.dataAirSystemsData->DemandSideConnect(ArrayCount).LoopType = DemandSideLoopType;
    1087             :                         state.dataAirSystemsData->DemandSideConnect(ArrayCount).LoopNum = DemandSideLoopNum;
    1088             :                         state.dataAirSystemsData->DemandSideConnect(ArrayCount).BranchNum = DemandSideBranchNum;
    1089             :                         state.dataAirSystemsData->DemandSideConnect(ArrayCount).CompNum = DemandSideCompNum;
    1090             : 
    1091             :                         found = false;
    1092             :                         print(state.files.debug, "1271=lstacksize {}\n", size(LoopStack));
    1093             :                         for (int Idx = 1; Idx <= isize(LoopStack); ++Idx) {
    1094             :                             if (DemandSideLoopNum == LoopStack(Idx).LoopNum && DemandSideLoopType == LoopStack(Idx).LoopType) {
    1095             :                                 found = true;
    1096             :                                 break;
    1097             :                             }
    1098             :                         }
    1099             :                         if (!found) {
    1100             :                             ++LoopCount;
    1101             :                             //       write(outputfiledebug,*) '1280=lc,mxsize',loopcount,maxlooparraysize
    1102             :                             //       write(outputfiledebug,*) '1281=dsloopnum,dslooptype',DemandSideLoopNum,DemandSideLoopType
    1103             :                             if (LoopCount > state.dataSysRpts->MaxLoopArraySize) {
    1104             :                                 LoopStack.redimension(state.dataSysRpts->MaxLoopArraySize += 100);
    1105             :                             }
    1106             :                             //               write(outputfiledebug,*)
    1107             :                             //               '1294=lcnt,dsloopnum,dslooptype',loopcount,DemandSideLoopNum,DemandSideLoopType
    1108             :                             LoopStack(LoopCount).LoopNum = DemandSideLoopNum;
    1109             :                             LoopStack(LoopCount).LoopType = DemandSideLoopType;
    1110             :                         }
    1111             :                     }
    1112             :                 }
    1113             :             }
    1114             :         } else if (LoopType == 2) {
    1115             :             for (int BranchNum = 1; BranchNum <= state.dataPlnt->VentRepCond[static_cast<int>(LoopSideLocation::Supply)](LoopNum).TotalBranches;
    1116             :                  ++BranchNum) {
    1117             :                 for (SupplySideCompNum = 1;
    1118             :                      SupplySideCompNum <=
    1119             :                      state.dataPlnt->VentRepCond[static_cast<int>(LoopSideLocation::Supply)](LoopNum).Branch(BranchNum).TotalComponents;
    1120             :                      ++SupplySideCompNum) {
    1121             :                     {
    1122             :                         auto const &thisVentRepComp =
    1123             :                             state.dataPlnt->VentRepCond[static_cast<int>(LoopSideLocation::Supply)](LoopNum).Branch(BranchNum).Comp(
    1124             :                                 SupplySideCompNum);
    1125             :                         DemandSideLoopType = thisVentRepComp.ConnectPlant.LoopType;
    1126             :                         DemandSideLoopNum = thisVentRepComp.ConnectPlant.LoopNum;
    1127             :                         DemandSideBranchNum = thisVentRepComp.ConnectPlant.BranchNum;
    1128             :                         DemandSideCompNum = thisVentRepComp.ConnectPlant.CompNum;
    1129             :                     }
    1130             :                     // If the connection is valid load the connection array
    1131             :                     if (DemandSideLoopType == 1 || DemandSideLoopType == 2) {
    1132             :                         ConnectionFlag = true;
    1133             :                         ++ArrayCount;
    1134             :                         if (ArrayCount > state.dataSysRpts->MaxCompArraySize) {
    1135             :                             state.dataAirSystemsData->DemandSideConnect.redimension(state.dataSysRpts->MaxCompArraySize += 100);
    1136             :                         }
    1137             :                         state.dataAirSystemsData->DemandSideConnect(ArrayCount).LoopType = DemandSideLoopType;
    1138             :                         state.dataAirSystemsData->DemandSideConnect(ArrayCount).LoopNum = DemandSideLoopNum;
    1139             :                         state.dataAirSystemsData->DemandSideConnect(ArrayCount).BranchNum = DemandSideBranchNum;
    1140             :                         state.dataAirSystemsData->DemandSideConnect(ArrayCount).CompNum = DemandSideCompNum;
    1141             : 
    1142             :                         found = false;
    1143             :                         for (int Idx = 1; Idx <= isize(LoopStack); ++Idx) {
    1144             :                             if (DemandSideLoopNum == LoopStack(Idx).LoopNum && DemandSideLoopType == LoopStack(Idx).LoopType) {
    1145             :                                 found = true;
    1146             :                                 break;
    1147             :                             }
    1148             :                         }
    1149             :                         if (!found) {
    1150             :                             ++LoopCount;
    1151             :                             //       write(outputfiledebug,*) '1341=lcnt,arrsize',loopcount,maxlooparraysize
    1152             :                             //       write(outputfiledebug,*) '1342=lsloopnum,dslooptype',DemandSideLoopNum,DemandSideLoopType
    1153             :                             if (LoopCount > state.dataSysRpts->MaxLoopArraySize) {
    1154             :                                 LoopStack.redimension(state.dataSysRpts->MaxLoopArraySize += 100);
    1155             :                             }
    1156             :                             LoopStack(LoopCount).LoopNum = DemandSideLoopNum;
    1157             :                             LoopStack(LoopCount).LoopType = DemandSideLoopType;
    1158             :                         }
    1159             :                     }
    1160             :                 }
    1161             :             }
    1162             :         } else {
    1163             :             print(state.files.debug, "{}\n", "1361=error");
    1164             :             // error
    1165             :         }
    1166             : 
    1167             :         // now unload the LoopNum and LoopType arrays
    1168             :         if (LoopCount > 0) {
    1169             :             LoopType = LoopStack(LoopCount).LoopType;
    1170             :             LoopNum = LoopStack(LoopCount).LoopNum;
    1171             :         }
    1172             : 
    1173             :     } // While loop
    1174             : }
    1175             : 
    1176           0 : void UpdateZoneCompPtrArray(EnergyPlusData &state,
    1177             :                             int &Idx,
    1178             :                             int const ListNum,
    1179             :                             int const AirDistUnitNum,
    1180             :                             int const PlantLoopType,
    1181             :                             int const PlantLoop,
    1182             :                             int const PlantBranch,
    1183             :                             int const PlantComp)
    1184             : {
    1185             :     // SUBROUTINE INFORMATION:
    1186             :     //       AUTHOR         Dan Fisher
    1187             :     //       DATE WRITTEN   June 2005
    1188             :     //       MODIFIED       na
    1189             :     //       RE-ENGINEERED  na
    1190             : 
    1191             :     // PURPOSE OF THIS SUBROUTINE:
    1192             :     // Update Zone Component pointers
    1193             : 
    1194           0 :     if (state.dataSysRpts->OneTimeFlag_UpdateZoneCompPtrArray) {
    1195           0 :         state.dataAirSystemsData->ZoneCompToPlant.allocate(state.dataSysRpts->ArrayLimit_UpdateZoneCompPtrArray);
    1196           0 :         for (auto &e : state.dataAirSystemsData->ZoneCompToPlant) {
    1197           0 :             e.ZoneEqListNum = 0;
    1198           0 :             e.ZoneEqCompNum = 0;
    1199           0 :             e.PlantLoopType = 0;
    1200           0 :             e.PlantLoopNum = 0;
    1201           0 :             e.PlantLoopBranch = 0;
    1202           0 :             e.PlantLoopComp = 0;
    1203           0 :             e.FirstDemandSidePtr = 0;
    1204           0 :             e.LastDemandSidePtr = 0;
    1205             :         }
    1206             : 
    1207           0 :         state.dataSysRpts->OneTimeFlag_UpdateZoneCompPtrArray = false;
    1208             :     }
    1209             : 
    1210           0 :     if (state.dataSysRpts->ArrayCounter_UpdateZoneCompPtrArray >= state.dataSysRpts->ArrayLimit_UpdateZoneCompPtrArray) { // Redimension larger
    1211           0 :         int const OldArrayLimit(state.dataSysRpts->ArrayLimit_UpdateZoneCompPtrArray);
    1212           0 :         state.dataAirSystemsData->ZoneCompToPlant.redimension(state.dataSysRpts->ArrayLimit_UpdateZoneCompPtrArray *= 2);
    1213           0 :         for (int i = OldArrayLimit + 1; i <= state.dataSysRpts->ArrayLimit_UpdateZoneCompPtrArray; ++i) {
    1214           0 :             auto &zctp = state.dataAirSystemsData->ZoneCompToPlant(i);
    1215           0 :             zctp.ZoneEqListNum = 0;
    1216           0 :             zctp.ZoneEqCompNum = 0;
    1217           0 :             zctp.PlantLoopType = 0;
    1218           0 :             zctp.PlantLoopNum = 0;
    1219           0 :             zctp.PlantLoopBranch = 0;
    1220           0 :             zctp.PlantLoopComp = 0;
    1221           0 :             zctp.FirstDemandSidePtr = 0;
    1222           0 :             zctp.LastDemandSidePtr = 0;
    1223             :         }
    1224             :     }
    1225             : 
    1226           0 :     Idx = state.dataSysRpts->ArrayCounter_UpdateZoneCompPtrArray;
    1227           0 :     auto &zctp = state.dataAirSystemsData->ZoneCompToPlant(Idx);
    1228           0 :     zctp.ZoneEqListNum = ListNum;
    1229           0 :     zctp.ZoneEqCompNum = AirDistUnitNum;
    1230           0 :     zctp.PlantLoopType = PlantLoopType;
    1231           0 :     zctp.PlantLoopNum = PlantLoop;
    1232           0 :     zctp.PlantLoopBranch = PlantBranch;
    1233           0 :     zctp.PlantLoopComp = PlantComp;
    1234           0 :     ++state.dataSysRpts->ArrayCounter_UpdateZoneCompPtrArray;
    1235           0 : }
    1236             : 
    1237          35 : void UpdateZoneSubCompPtrArray(EnergyPlusData &state,
    1238             :                                int &Idx,
    1239             :                                int const ListNum,
    1240             :                                int const AirDistUnitNum,
    1241             :                                int const SubCompNum,
    1242             :                                int const PlantLoopType,
    1243             :                                int const PlantLoop,
    1244             :                                int const PlantBranch,
    1245             :                                int const PlantComp)
    1246             : {
    1247             :     // SUBROUTINE INFORMATION:
    1248             :     //       AUTHOR         Dan Fisher
    1249             :     //       DATE WRITTEN   June 2005
    1250             :     //       MODIFIED       na
    1251             :     //       RE-ENGINEERED  na
    1252             : 
    1253             :     // PURPOSE OF THIS SUBROUTINE:
    1254             :     // Update Zone Sub Component Pointer Array
    1255             : 
    1256          35 :     if (state.dataSysRpts->OneTimeFlag_UpdateZoneSubCompPtrArray) {
    1257           3 :         state.dataAirSystemsData->ZoneSubCompToPlant.allocate(state.dataSysRpts->ArrayLimit_UpdateZoneSubCompPtrArray);
    1258         303 :         for (auto &e : state.dataAirSystemsData->ZoneSubCompToPlant) {
    1259         300 :             e.ZoneEqListNum = 0;
    1260         300 :             e.ZoneEqCompNum = 0;
    1261         300 :             e.ZoneEqSubCompNum = 0;
    1262         300 :             e.PlantLoopType = 0;
    1263         300 :             e.PlantLoopNum = 0;
    1264         300 :             e.PlantLoopBranch = 0;
    1265         300 :             e.PlantLoopComp = 0;
    1266         300 :             e.FirstDemandSidePtr = 0;
    1267         300 :             e.LastDemandSidePtr = 0;
    1268             :         }
    1269             : 
    1270           3 :         state.dataSysRpts->OneTimeFlag_UpdateZoneSubCompPtrArray = false;
    1271             :     }
    1272             : 
    1273          35 :     if (state.dataSysRpts->ArrayCounter_UpdateZoneSubCompPtrArray >= state.dataSysRpts->ArrayLimit_UpdateZoneSubCompPtrArray) { // Redimension larger
    1274           0 :         int const OldArrayLimit(state.dataSysRpts->ArrayLimit_UpdateZoneSubCompPtrArray);
    1275           0 :         state.dataAirSystemsData->ZoneSubCompToPlant.redimension(state.dataSysRpts->ArrayLimit_UpdateZoneSubCompPtrArray *= 2);
    1276           0 :         for (int i = OldArrayLimit + 1; i <= state.dataSysRpts->ArrayLimit_UpdateZoneSubCompPtrArray; ++i) {
    1277           0 :             auto &zctp = state.dataAirSystemsData->ZoneSubCompToPlant(i);
    1278           0 :             zctp.ZoneEqListNum = 0;
    1279           0 :             zctp.ZoneEqCompNum = 0;
    1280           0 :             zctp.ZoneEqSubCompNum = 0;
    1281           0 :             zctp.PlantLoopType = 0;
    1282           0 :             zctp.PlantLoopNum = 0;
    1283           0 :             zctp.PlantLoopBranch = 0;
    1284           0 :             zctp.PlantLoopComp = 0;
    1285           0 :             zctp.FirstDemandSidePtr = 0;
    1286           0 :             zctp.LastDemandSidePtr = 0;
    1287             :         }
    1288             :     }
    1289             : 
    1290          35 :     Idx = state.dataSysRpts->ArrayCounter_UpdateZoneSubCompPtrArray;
    1291          35 :     auto &zctp = state.dataAirSystemsData->ZoneSubCompToPlant(Idx);
    1292          35 :     zctp.ZoneEqListNum = ListNum;
    1293          35 :     zctp.ZoneEqCompNum = AirDistUnitNum;
    1294          35 :     zctp.ZoneEqSubCompNum = SubCompNum;
    1295          35 :     zctp.PlantLoopType = PlantLoopType;
    1296          35 :     zctp.PlantLoopNum = PlantLoop;
    1297          35 :     zctp.PlantLoopBranch = PlantBranch;
    1298          35 :     zctp.PlantLoopComp = PlantComp;
    1299          35 :     ++state.dataSysRpts->ArrayCounter_UpdateZoneSubCompPtrArray;
    1300          35 : }
    1301             : 
    1302        2216 : void UpdateZoneSubSubCompPtrArray(EnergyPlusData &state,
    1303             :                                   int &Idx,
    1304             :                                   int const ListNum,
    1305             :                                   int const AirDistUnitNum,
    1306             :                                   int const SubCompNum,
    1307             :                                   int const SubSubCompNum,
    1308             :                                   int const PlantLoopType,
    1309             :                                   int const PlantLoop,
    1310             :                                   int const PlantBranch,
    1311             :                                   int const PlantComp)
    1312             : {
    1313             :     // SUBROUTINE INFORMATION:
    1314             :     //       AUTHOR         Dan Fisher
    1315             :     //       DATE WRITTEN   June 2005
    1316             :     //       MODIFIED       na
    1317             :     //       RE-ENGINEERED  na
    1318             : 
    1319             :     // PURPOSE OF THIS SUBROUTINE:
    1320             :     // Update Zone Sub Component Pointer Array
    1321             : 
    1322        2216 :     if (state.dataSysRpts->OneTimeFlag_UpdateZoneSubSubCompPtrArray) {
    1323         269 :         state.dataAirSystemsData->ZoneSubSubCompToPlant.allocate(state.dataSysRpts->ArrayLimit_UpdateZoneSubSubCompPtrArray);
    1324       27169 :         for (auto &e : state.dataAirSystemsData->ZoneSubSubCompToPlant) {
    1325       26900 :             e.ZoneEqListNum = 0;
    1326       26900 :             e.ZoneEqCompNum = 0;
    1327       26900 :             e.ZoneEqSubCompNum = 0;
    1328       26900 :             e.ZoneEqSubSubCompNum = 0;
    1329       26900 :             e.PlantLoopType = 0;
    1330       26900 :             e.PlantLoopNum = 0;
    1331       26900 :             e.PlantLoopBranch = 0;
    1332       26900 :             e.PlantLoopComp = 0;
    1333       26900 :             e.FirstDemandSidePtr = 0;
    1334       26900 :             e.LastDemandSidePtr = 0;
    1335             :         }
    1336             : 
    1337         269 :         state.dataSysRpts->OneTimeFlag_UpdateZoneSubSubCompPtrArray = false;
    1338             :     }
    1339             : 
    1340        2216 :     if (state.dataSysRpts->ArrayCounter_UpdateZoneSubSubCompPtrArray >=
    1341        2216 :         state.dataSysRpts->ArrayLimit_UpdateZoneSubSubCompPtrArray) { // Redimension larger
    1342           2 :         int const OldArrayLimit(state.dataSysRpts->ArrayLimit_UpdateZoneSubSubCompPtrArray);
    1343           2 :         state.dataAirSystemsData->ZoneSubSubCompToPlant.redimension(state.dataSysRpts->ArrayLimit_UpdateZoneSubSubCompPtrArray *= 2);
    1344         202 :         for (int i = OldArrayLimit + 1; i <= state.dataSysRpts->ArrayLimit_UpdateZoneSubSubCompPtrArray; ++i) {
    1345         200 :             auto &zctp = state.dataAirSystemsData->ZoneSubSubCompToPlant(i);
    1346         200 :             zctp.ZoneEqListNum = 0;
    1347         200 :             zctp.ZoneEqCompNum = 0;
    1348         200 :             zctp.ZoneEqSubCompNum = 0;
    1349         200 :             zctp.ZoneEqSubSubCompNum = 0;
    1350         200 :             zctp.PlantLoopType = 0;
    1351         200 :             zctp.PlantLoopNum = 0;
    1352         200 :             zctp.PlantLoopBranch = 0;
    1353         200 :             zctp.PlantLoopComp = 0;
    1354         200 :             zctp.FirstDemandSidePtr = 0;
    1355         200 :             zctp.LastDemandSidePtr = 0;
    1356             :         }
    1357             :     }
    1358             : 
    1359        2216 :     Idx = state.dataSysRpts->ArrayCounter_UpdateZoneSubSubCompPtrArray;
    1360        2216 :     auto &zctp = state.dataAirSystemsData->ZoneSubSubCompToPlant(Idx);
    1361        2216 :     zctp.ZoneEqListNum = ListNum;
    1362        2216 :     zctp.ZoneEqCompNum = AirDistUnitNum;
    1363        2216 :     zctp.ZoneEqSubCompNum = SubCompNum;
    1364        2216 :     zctp.ZoneEqSubSubCompNum = SubSubCompNum;
    1365        2216 :     zctp.PlantLoopType = PlantLoopType;
    1366        2216 :     zctp.PlantLoopNum = PlantLoop;
    1367        2216 :     zctp.PlantLoopBranch = PlantBranch;
    1368        2216 :     zctp.PlantLoopComp = PlantComp;
    1369        2216 :     ++state.dataSysRpts->ArrayCounter_UpdateZoneSubSubCompPtrArray;
    1370        2216 : }
    1371             : 
    1372        5459 : void UpdateAirSysCompPtrArray(EnergyPlusData &state,
    1373             :                               int &Idx,
    1374             :                               int const AirLoopNum,
    1375             :                               int const BranchNum,
    1376             :                               int const CompNum,
    1377             :                               int const PlantLoopType,
    1378             :                               int const PlantLoop,
    1379             :                               int const PlantBranch,
    1380             :                               int const PlantComp)
    1381             : {
    1382             :     // SUBROUTINE INFORMATION:
    1383             :     //       AUTHOR         Dan Fisher
    1384             :     //       DATE WRITTEN   June 2005
    1385             :     //       MODIFIED       na
    1386             :     //       RE-ENGINEERED  na
    1387             : 
    1388             :     // PURPOSE OF THIS SUBROUTINE:
    1389             :     // Update Air System Component Pointer Array
    1390             : 
    1391        5459 :     if (state.dataSysRpts->OneTimeFlag_UpdateAirSysCompPtrArray) {
    1392         292 :         state.dataAirSystemsData->AirSysCompToPlant.allocate(state.dataSysRpts->ArrayLimit_UpdateAirSysCompPtrArray);
    1393       29492 :         for (auto &e : state.dataAirSystemsData->AirSysCompToPlant) {
    1394       29200 :             e.AirLoopNum = 0;
    1395       29200 :             e.AirLoopBranch = 0;
    1396       29200 :             e.AirLoopComp = 0;
    1397       29200 :             e.PlantLoopType = 0;
    1398       29200 :             e.PlantLoopNum = 0;
    1399       29200 :             e.PlantLoopBranch = 0;
    1400       29200 :             e.PlantLoopComp = 0;
    1401       29200 :             e.FirstDemandSidePtr = 0;
    1402       29200 :             e.LastDemandSidePtr = 0;
    1403             :         }
    1404             : 
    1405         292 :         state.dataSysRpts->OneTimeFlag_UpdateAirSysCompPtrArray = false;
    1406             :     }
    1407             : 
    1408        5459 :     if (state.dataSysRpts->ArrayCounter_UpdateAirSysCompPtrArray >= state.dataSysRpts->ArrayLimit_UpdateAirSysCompPtrArray) { // Redimension larger
    1409          11 :         int const OldArrayLimit(state.dataSysRpts->ArrayLimit_UpdateAirSysCompPtrArray);
    1410          11 :         state.dataAirSystemsData->AirSysCompToPlant.redimension(state.dataSysRpts->ArrayLimit_UpdateAirSysCompPtrArray *= 2);
    1411        1911 :         for (int i = OldArrayLimit + 1; i <= state.dataSysRpts->ArrayLimit_UpdateAirSysCompPtrArray; ++i) {
    1412        1900 :             auto &actp = state.dataAirSystemsData->AirSysCompToPlant(i);
    1413        1900 :             actp.AirLoopNum = 0;
    1414        1900 :             actp.AirLoopBranch = 0;
    1415        1900 :             actp.AirLoopComp = 0;
    1416        1900 :             actp.PlantLoopType = 0;
    1417        1900 :             actp.PlantLoopNum = 0;
    1418        1900 :             actp.PlantLoopBranch = 0;
    1419        1900 :             actp.PlantLoopComp = 0;
    1420        1900 :             actp.FirstDemandSidePtr = 0;
    1421        1900 :             actp.LastDemandSidePtr = 0;
    1422             :         }
    1423             :     }
    1424             : 
    1425        5459 :     Idx = state.dataSysRpts->ArrayCounter_UpdateAirSysCompPtrArray;
    1426        5459 :     auto &actp = state.dataAirSystemsData->AirSysCompToPlant(Idx);
    1427        5459 :     actp.AirLoopNum = AirLoopNum;
    1428        5459 :     actp.AirLoopBranch = BranchNum;
    1429        5459 :     actp.AirLoopComp = CompNum;
    1430        5459 :     actp.PlantLoopType = PlantLoopType;
    1431        5459 :     actp.PlantLoopNum = PlantLoop;
    1432        5459 :     actp.PlantLoopBranch = PlantBranch;
    1433        5459 :     actp.PlantLoopComp = PlantComp;
    1434        5459 :     ++state.dataSysRpts->ArrayCounter_UpdateAirSysCompPtrArray;
    1435        5459 : }
    1436             : 
    1437           0 : void UpdateAirSysSubCompPtrArray(EnergyPlusData &state,
    1438             :                                  int &Idx,
    1439             :                                  int const AirLoopNum,
    1440             :                                  int const BranchNum,
    1441             :                                  int const CompNum,
    1442             :                                  int const SubCompNum,
    1443             :                                  int const PlantLoopType,
    1444             :                                  int const PlantLoop,
    1445             :                                  int const PlantBranch,
    1446             :                                  int const PlantComp)
    1447             : {
    1448             :     // SUBROUTINE INFORMATION:
    1449             :     //       AUTHOR         Dan Fisher
    1450             :     //       DATE WRITTEN   June 2005
    1451             :     //       MODIFIED       na
    1452             :     //       RE-ENGINEERED  na
    1453             : 
    1454             :     // PURPOSE OF THIS SUBROUTINE:
    1455             :     // Update Air System Sub Component Pointer Array
    1456             : 
    1457           0 :     if (state.dataSysRpts->OneTimeFlag_UpdateAirSysSubCompPtrArray) {
    1458           0 :         state.dataAirSystemsData->AirSysSubCompToPlant.allocate(state.dataSysRpts->ArrayLimit_UpdateAirSysSubCompPtrArray);
    1459           0 :         for (auto &e : state.dataAirSystemsData->AirSysSubCompToPlant) {
    1460           0 :             e.AirLoopNum = 0;
    1461           0 :             e.AirLoopBranch = 0;
    1462           0 :             e.AirLoopComp = 0;
    1463           0 :             e.AirLoopSubComp = 0;
    1464           0 :             e.PlantLoopType = 0;
    1465           0 :             e.PlantLoopNum = 0;
    1466           0 :             e.PlantLoopBranch = 0;
    1467           0 :             e.PlantLoopComp = 0;
    1468           0 :             e.FirstDemandSidePtr = 0;
    1469           0 :             e.LastDemandSidePtr = 0;
    1470             :         }
    1471             : 
    1472           0 :         state.dataSysRpts->OneTimeFlag_UpdateAirSysSubCompPtrArray = false;
    1473             :     }
    1474             : 
    1475           0 :     if (state.dataSysRpts->ArrayCounter_UpdateAirSysSubCompPtrArray >=
    1476           0 :         state.dataSysRpts->ArrayLimit_UpdateAirSysSubCompPtrArray) { // Redimension larger
    1477           0 :         int const OldArrayLimit(state.dataSysRpts->ArrayLimit_UpdateAirSysSubCompPtrArray);
    1478           0 :         state.dataAirSystemsData->AirSysSubCompToPlant.redimension(state.dataSysRpts->ArrayLimit_UpdateAirSysSubCompPtrArray *= 2);
    1479           0 :         for (int i = OldArrayLimit + 1; i <= state.dataSysRpts->ArrayLimit_UpdateAirSysSubCompPtrArray; ++i) {
    1480           0 :             auto &actp = state.dataAirSystemsData->AirSysSubCompToPlant(i);
    1481           0 :             actp.AirLoopNum = 0;
    1482           0 :             actp.AirLoopBranch = 0;
    1483           0 :             actp.AirLoopComp = 0;
    1484           0 :             actp.AirLoopSubComp = 0;
    1485           0 :             actp.PlantLoopType = 0;
    1486           0 :             actp.PlantLoopNum = 0;
    1487           0 :             actp.PlantLoopBranch = 0;
    1488           0 :             actp.PlantLoopComp = 0;
    1489           0 :             actp.FirstDemandSidePtr = 0;
    1490           0 :             actp.LastDemandSidePtr = 0;
    1491             :         }
    1492             :     }
    1493             : 
    1494           0 :     Idx = state.dataSysRpts->ArrayCounter_UpdateAirSysSubCompPtrArray;
    1495           0 :     auto &actp = state.dataAirSystemsData->AirSysSubCompToPlant(Idx);
    1496           0 :     actp.AirLoopNum = AirLoopNum;
    1497           0 :     actp.AirLoopBranch = BranchNum;
    1498           0 :     actp.AirLoopComp = CompNum;
    1499           0 :     actp.AirLoopSubComp = SubCompNum;
    1500           0 :     actp.PlantLoopType = PlantLoopType;
    1501           0 :     actp.PlantLoopNum = PlantLoop;
    1502           0 :     actp.PlantLoopBranch = PlantBranch;
    1503           0 :     actp.PlantLoopComp = PlantComp;
    1504           0 :     ++state.dataSysRpts->ArrayCounter_UpdateAirSysSubCompPtrArray;
    1505           0 : }
    1506             : 
    1507           0 : void UpdateAirSysSubSubCompPtrArray(EnergyPlusData &state,
    1508             :                                     int &Idx,
    1509             :                                     int const AirLoopNum,
    1510             :                                     int const BranchNum,
    1511             :                                     int const CompNum,
    1512             :                                     int const SubCompNum,
    1513             :                                     int const SubSubCompNum,
    1514             :                                     int const PlantLoopType,
    1515             :                                     int const PlantLoop,
    1516             :                                     int const PlantBranch,
    1517             :                                     int const PlantComp)
    1518             : {
    1519             :     // SUBROUTINE INFORMATION:
    1520             :     //       AUTHOR         Dan Fisher
    1521             :     //       DATE WRITTEN   June 2005
    1522             :     //       MODIFIED       na
    1523             :     //       RE-ENGINEERED  na
    1524             : 
    1525             :     // PURPOSE OF THIS SUBROUTINE:
    1526             :     // Update Air System Sub Sub Component Pointer Array
    1527             : 
    1528           0 :     if (state.dataSysRpts->OneTimeFlag_UpdateAirSysSubSubCompPtrArray) {
    1529           0 :         state.dataAirSystemsData->AirSysSubSubCompToPlant.allocate(state.dataSysRpts->ArrayLimit_UpdateAirSysSubSubCompPtrArray);
    1530           0 :         for (auto &e : state.dataAirSystemsData->AirSysSubSubCompToPlant) {
    1531           0 :             e.AirLoopNum = 0;
    1532           0 :             e.AirLoopBranch = 0;
    1533           0 :             e.AirLoopComp = 0;
    1534           0 :             e.AirLoopSubComp = 0;
    1535           0 :             e.AirLoopSubSubComp = 0;
    1536           0 :             e.PlantLoopType = 0;
    1537           0 :             e.PlantLoopNum = 0;
    1538           0 :             e.PlantLoopBranch = 0;
    1539           0 :             e.PlantLoopComp = 0;
    1540           0 :             e.FirstDemandSidePtr = 0;
    1541           0 :             e.LastDemandSidePtr = 0;
    1542             :         }
    1543             : 
    1544           0 :         state.dataSysRpts->OneTimeFlag_UpdateAirSysSubSubCompPtrArray = false;
    1545             :     }
    1546             : 
    1547           0 :     if (state.dataSysRpts->ArrayCounter_UpdateAirSysSubSubCompPtrArray >=
    1548           0 :         state.dataSysRpts->ArrayLimit_UpdateAirSysSubSubCompPtrArray) { // Redimension larger
    1549           0 :         int const OldArrayLimit(state.dataSysRpts->ArrayLimit_UpdateAirSysSubSubCompPtrArray);
    1550           0 :         state.dataAirSystemsData->AirSysSubSubCompToPlant.redimension(state.dataSysRpts->ArrayLimit_UpdateAirSysSubSubCompPtrArray *= 2);
    1551           0 :         for (int i = OldArrayLimit + 1; i <= state.dataSysRpts->ArrayLimit_UpdateAirSysSubSubCompPtrArray; ++i) {
    1552           0 :             auto &actp = state.dataAirSystemsData->AirSysSubSubCompToPlant(i);
    1553           0 :             actp.AirLoopNum = 0;
    1554           0 :             actp.AirLoopBranch = 0;
    1555           0 :             actp.AirLoopComp = 0;
    1556           0 :             actp.AirLoopSubComp = 0;
    1557           0 :             actp.AirLoopSubSubComp = 0;
    1558           0 :             actp.PlantLoopType = 0;
    1559           0 :             actp.PlantLoopNum = 0;
    1560           0 :             actp.PlantLoopBranch = 0;
    1561           0 :             actp.PlantLoopComp = 0;
    1562           0 :             actp.FirstDemandSidePtr = 0;
    1563           0 :             actp.LastDemandSidePtr = 0;
    1564             :         }
    1565             :     }
    1566             : 
    1567           0 :     Idx = state.dataSysRpts->ArrayCounter_UpdateAirSysSubSubCompPtrArray;
    1568           0 :     auto &actp = state.dataAirSystemsData->AirSysSubSubCompToPlant(Idx);
    1569           0 :     actp.AirLoopNum = AirLoopNum;
    1570           0 :     actp.AirLoopBranch = BranchNum;
    1571           0 :     actp.AirLoopComp = CompNum;
    1572           0 :     actp.AirLoopSubComp = SubCompNum;
    1573           0 :     actp.AirLoopSubSubComp = SubSubCompNum;
    1574           0 :     actp.PlantLoopType = PlantLoopType;
    1575           0 :     actp.PlantLoopNum = PlantLoop;
    1576           0 :     actp.PlantLoopBranch = PlantBranch;
    1577           0 :     actp.PlantLoopComp = PlantComp;
    1578           0 :     ++state.dataSysRpts->ArrayCounter_UpdateAirSysSubSubCompPtrArray;
    1579           0 : }
    1580             : 
    1581         795 : void AllocateAndSetUpVentReports(EnergyPlusData &state)
    1582             : {
    1583             : 
    1584             :     // SUBROUTINE INFORMATION:
    1585             :     //       AUTHOR         Sankaranarayanan K P
    1586             :     //       DATE WRITTEN   July 2005
    1587             :     //       MODIFIED       na
    1588             :     //       RE-ENGINEERED  na
    1589             : 
    1590         795 :     int NumPrimaryAirSys = state.dataHVACGlobal->NumPrimaryAirSys;
    1591             : 
    1592             :     // PURPOSE OF THIS SUBROUTINE:
    1593             :     // Allocates Arrays and setup output variables related to Ventilation reports.
    1594         795 :     state.dataSysRpts->ZoneVentRepVars.allocate(state.dataGlobal->NumOfZones);
    1595         795 :     state.dataSysRpts->SysLoadRepVars.allocate(NumPrimaryAirSys);
    1596         795 :     state.dataSysRpts->SysVentRepVars.allocate(NumPrimaryAirSys);
    1597         795 :     state.dataSysRpts->SysPreDefRep.allocate(NumPrimaryAirSys);
    1598             : 
    1599        2002 :     for (int sysIndex = 1; sysIndex <= NumPrimaryAirSys; ++sysIndex) {
    1600        1207 :         auto &thisSysVentRepVars = state.dataSysRpts->SysVentRepVars(sysIndex);
    1601        1207 :         thisSysVentRepVars.MechVentFlow = 0.0;
    1602        1207 :         thisSysVentRepVars.NatVentFlow = 0.0;
    1603        1207 :         thisSysVentRepVars.TargetVentilationFlowVoz = 0.0;
    1604        1207 :         thisSysVentRepVars.TimeBelowVozDyn = 0.0;
    1605        1207 :         thisSysVentRepVars.TimeAtVozDyn = 0.0;
    1606        1207 :         thisSysVentRepVars.TimeAboveVozDyn = 0.0;
    1607        1207 :         thisSysVentRepVars.TimeVentUnocc = 0.0;
    1608        1207 :         thisSysVentRepVars.AnyZoneOccupied = false;
    1609             :     }
    1610             : 
    1611         795 :     if (state.dataSysRpts->AirLoopLoadsReportEnabled) {
    1612        2002 :         for (int sysIndex = 1; sysIndex <= NumPrimaryAirSys; ++sysIndex) {
    1613        1207 :             auto &thisSysLoadRepVars = state.dataSysRpts->SysLoadRepVars(sysIndex);
    1614        1207 :             auto &thisSysVentRepVars = state.dataSysRpts->SysVentRepVars(sysIndex);
    1615        1207 :             std::string const primaryAirSysName = state.dataAirSystemsData->PrimaryAirSystems(sysIndex).Name;
    1616             : 
    1617             :             // CurrentModuleObject='AirloopHVAC'
    1618             :             // SYSTEM LOADS REPORT
    1619        2414 :             SetupOutputVariable(state,
    1620             :                                 "Air System Total Heating Energy",
    1621             :                                 Constant::Units::J,
    1622        1207 :                                 thisSysLoadRepVars.TotHTNG,
    1623             :                                 OutputProcessor::TimeStepType::System,
    1624             :                                 OutputProcessor::StoreType::Sum,
    1625             :                                 primaryAirSysName);
    1626             : 
    1627        2414 :             SetupOutputVariable(state,
    1628             :                                 "Air System Total Cooling Energy",
    1629             :                                 Constant::Units::J,
    1630        1207 :                                 thisSysLoadRepVars.TotCLNG,
    1631             :                                 OutputProcessor::TimeStepType::System,
    1632             :                                 OutputProcessor::StoreType::Sum,
    1633             :                                 primaryAirSysName);
    1634             : 
    1635             :             // SYSTEM ENERGY USE REPORT
    1636        2414 :             SetupOutputVariable(state,
    1637             :                                 "Air System Hot Water Energy",
    1638             :                                 Constant::Units::J,
    1639        1207 :                                 thisSysLoadRepVars.TotH2OHOT,
    1640             :                                 OutputProcessor::TimeStepType::System,
    1641             :                                 OutputProcessor::StoreType::Sum,
    1642             :                                 primaryAirSysName);
    1643             : 
    1644        2414 :             SetupOutputVariable(state,
    1645             :                                 "Air System Steam Energy",
    1646             :                                 Constant::Units::J,
    1647        1207 :                                 thisSysLoadRepVars.TotSteam,
    1648             :                                 OutputProcessor::TimeStepType::System,
    1649             :                                 OutputProcessor::StoreType::Sum,
    1650             :                                 primaryAirSysName);
    1651             : 
    1652        2414 :             SetupOutputVariable(state,
    1653             :                                 "Air System Chilled Water Energy",
    1654             :                                 Constant::Units::J,
    1655        1207 :                                 thisSysLoadRepVars.TotH2OCOLD,
    1656             :                                 OutputProcessor::TimeStepType::System,
    1657             :                                 OutputProcessor::StoreType::Sum,
    1658             :                                 primaryAirSysName);
    1659             : 
    1660        2414 :             SetupOutputVariable(state,
    1661             :                                 "Air System Electricity Energy",
    1662             :                                 Constant::Units::J,
    1663        1207 :                                 thisSysLoadRepVars.TotElec,
    1664             :                                 OutputProcessor::TimeStepType::System,
    1665             :                                 OutputProcessor::StoreType::Sum,
    1666             :                                 primaryAirSysName);
    1667             : 
    1668        2414 :             SetupOutputVariable(state,
    1669             :                                 "Air System NaturalGas Energy",
    1670             :                                 Constant::Units::J,
    1671        1207 :                                 thisSysLoadRepVars.TotNaturalGas,
    1672             :                                 OutputProcessor::TimeStepType::System,
    1673             :                                 OutputProcessor::StoreType::Sum,
    1674             :                                 primaryAirSysName);
    1675             : 
    1676        2414 :             SetupOutputVariable(state,
    1677             :                                 "Air System Propane Energy",
    1678             :                                 Constant::Units::J,
    1679        1207 :                                 thisSysLoadRepVars.TotPropane,
    1680             :                                 OutputProcessor::TimeStepType::System,
    1681             :                                 OutputProcessor::StoreType::Sum,
    1682             :                                 primaryAirSysName);
    1683             : 
    1684        2414 :             SetupOutputVariable(state,
    1685             :                                 "Air System Water Volume",
    1686             :                                 Constant::Units::m3,
    1687        1207 :                                 thisSysLoadRepVars.DomesticH2O,
    1688             :                                 OutputProcessor::TimeStepType::System,
    1689             :                                 OutputProcessor::StoreType::Sum,
    1690             :                                 primaryAirSysName);
    1691             : 
    1692             :             // SYSTEM COMPONENT LOAD REPORT
    1693        2414 :             SetupOutputVariable(state,
    1694             :                                 "Air System Fan Air Heating Energy",
    1695             :                                 Constant::Units::J,
    1696        1207 :                                 thisSysLoadRepVars.FANCompHTNG,
    1697             :                                 OutputProcessor::TimeStepType::System,
    1698             :                                 OutputProcessor::StoreType::Sum,
    1699             :                                 primaryAirSysName);
    1700             : 
    1701        2414 :             SetupOutputVariable(state,
    1702             :                                 "Air System Cooling Coil Total Cooling Energy",
    1703             :                                 Constant::Units::J,
    1704        1207 :                                 thisSysLoadRepVars.CCCompCLNG,
    1705             :                                 OutputProcessor::TimeStepType::System,
    1706             :                                 OutputProcessor::StoreType::Sum,
    1707             :                                 primaryAirSysName);
    1708             : 
    1709        2414 :             SetupOutputVariable(state,
    1710             :                                 "Air System Heating Coil Total Heating Energy",
    1711             :                                 Constant::Units::J,
    1712        1207 :                                 thisSysLoadRepVars.HCCompHTNG,
    1713             :                                 OutputProcessor::TimeStepType::System,
    1714             :                                 OutputProcessor::StoreType::Sum,
    1715             :                                 primaryAirSysName);
    1716             : 
    1717        2414 :             SetupOutputVariable(state,
    1718             :                                 "Air System Heat Exchanger Total Heating Energy",
    1719             :                                 Constant::Units::J,
    1720        1207 :                                 thisSysLoadRepVars.HeatExHTNG,
    1721             :                                 OutputProcessor::TimeStepType::System,
    1722             :                                 OutputProcessor::StoreType::Sum,
    1723             :                                 primaryAirSysName);
    1724             : 
    1725        2414 :             SetupOutputVariable(state,
    1726             :                                 "Air System Heat Exchanger Total Cooling Energy",
    1727             :                                 Constant::Units::J,
    1728        1207 :                                 thisSysLoadRepVars.HeatExCLNG,
    1729             :                                 OutputProcessor::TimeStepType::System,
    1730             :                                 OutputProcessor::StoreType::Sum,
    1731             :                                 primaryAirSysName);
    1732             : 
    1733        2414 :             SetupOutputVariable(state,
    1734             :                                 "Air System Solar Collector Total Heating Energy",
    1735             :                                 Constant::Units::J,
    1736        1207 :                                 thisSysLoadRepVars.SolarCollectHeating,
    1737             :                                 OutputProcessor::TimeStepType::System,
    1738             :                                 OutputProcessor::StoreType::Sum,
    1739             :                                 primaryAirSysName);
    1740             : 
    1741        2414 :             SetupOutputVariable(state,
    1742             :                                 "Air System Solar Collector Total Cooling Energy",
    1743             :                                 Constant::Units::J,
    1744        1207 :                                 thisSysLoadRepVars.SolarCollectCooling,
    1745             :                                 OutputProcessor::TimeStepType::System,
    1746             :                                 OutputProcessor::StoreType::Sum,
    1747             :                                 primaryAirSysName);
    1748             : 
    1749        2414 :             SetupOutputVariable(state,
    1750             :                                 "Air System User Defined Air Terminal Total Heating Energy",
    1751             :                                 Constant::Units::J,
    1752        1207 :                                 thisSysLoadRepVars.UserDefinedTerminalHeating,
    1753             :                                 OutputProcessor::TimeStepType::System,
    1754             :                                 OutputProcessor::StoreType::Sum,
    1755             :                                 primaryAirSysName);
    1756             : 
    1757        2414 :             SetupOutputVariable(state,
    1758             :                                 "Air System User Defined Air Terminal Total Cooling Energy",
    1759             :                                 Constant::Units::J,
    1760        1207 :                                 thisSysLoadRepVars.UserDefinedTerminalCooling,
    1761             :                                 OutputProcessor::TimeStepType::System,
    1762             :                                 OutputProcessor::StoreType::Sum,
    1763             :                                 primaryAirSysName);
    1764             : 
    1765        2414 :             SetupOutputVariable(state,
    1766             :                                 "Air System Humidifier Total Heating Energy",
    1767             :                                 Constant::Units::J,
    1768        1207 :                                 thisSysLoadRepVars.HumidHTNG,
    1769             :                                 OutputProcessor::TimeStepType::System,
    1770             :                                 OutputProcessor::StoreType::Sum,
    1771             :                                 primaryAirSysName);
    1772             : 
    1773        2414 :             SetupOutputVariable(state,
    1774             :                                 "Air System Evaporative Cooler Total Cooling Energy",
    1775             :                                 Constant::Units::J,
    1776        1207 :                                 thisSysLoadRepVars.EvapCLNG,
    1777             :                                 OutputProcessor::TimeStepType::System,
    1778             :                                 OutputProcessor::StoreType::Sum,
    1779             :                                 primaryAirSysName);
    1780             : 
    1781        2414 :             SetupOutputVariable(state,
    1782             :                                 "Air System Desiccant Dehumidifier Total Cooling Energy",
    1783             :                                 Constant::Units::J,
    1784        1207 :                                 thisSysLoadRepVars.DesDehumidCLNG,
    1785             :                                 OutputProcessor::TimeStepType::System,
    1786             :                                 OutputProcessor::StoreType::Sum,
    1787             :                                 primaryAirSysName);
    1788             : 
    1789             :             // SYSTEM COMPONENT ENERGY REPORT
    1790        2414 :             SetupOutputVariable(state,
    1791             :                                 "Air System Fan Electricity Energy",
    1792             :                                 Constant::Units::J,
    1793        1207 :                                 thisSysLoadRepVars.FANCompElec,
    1794             :                                 OutputProcessor::TimeStepType::System,
    1795             :                                 OutputProcessor::StoreType::Sum,
    1796             :                                 primaryAirSysName);
    1797             : 
    1798        2414 :             SetupOutputVariable(state,
    1799             :                                 "Air System Heating Coil Hot Water Energy",
    1800             :                                 Constant::Units::J,
    1801        1207 :                                 thisSysLoadRepVars.HCCompH2OHOT,
    1802             :                                 OutputProcessor::TimeStepType::System,
    1803             :                                 OutputProcessor::StoreType::Sum,
    1804             :                                 primaryAirSysName);
    1805             : 
    1806        2414 :             SetupOutputVariable(state,
    1807             :                                 "Air System Cooling Coil Chilled Water Energy",
    1808             :                                 Constant::Units::J,
    1809        1207 :                                 thisSysLoadRepVars.CCCompH2OCOLD,
    1810             :                                 OutputProcessor::TimeStepType::System,
    1811             :                                 OutputProcessor::StoreType::Sum,
    1812             :                                 primaryAirSysName);
    1813             : 
    1814        2414 :             SetupOutputVariable(state,
    1815             :                                 "Air System DX Heating Coil Electricity Energy",
    1816             :                                 Constant::Units::J,
    1817        1207 :                                 thisSysLoadRepVars.HCCompElec,
    1818             :                                 OutputProcessor::TimeStepType::System,
    1819             :                                 OutputProcessor::StoreType::Sum,
    1820             :                                 primaryAirSysName);
    1821             : 
    1822        2414 :             SetupOutputVariable(state,
    1823             :                                 "Air System DX Cooling Coil Electricity Energy",
    1824             :                                 Constant::Units::J,
    1825        1207 :                                 thisSysLoadRepVars.CCCompElec,
    1826             :                                 OutputProcessor::TimeStepType::System,
    1827             :                                 OutputProcessor::StoreType::Sum,
    1828             :                                 primaryAirSysName);
    1829             : 
    1830        2414 :             SetupOutputVariable(state,
    1831             :                                 "Air System Heating Coil Electricity Energy",
    1832             :                                 Constant::Units::J,
    1833        1207 :                                 thisSysLoadRepVars.HCCompElecRes,
    1834             :                                 OutputProcessor::TimeStepType::System,
    1835             :                                 OutputProcessor::StoreType::Sum,
    1836             :                                 primaryAirSysName);
    1837             : 
    1838        2414 :             SetupOutputVariable(state,
    1839             :                                 "Air System Heating Coil NaturalGas Energy",
    1840             :                                 Constant::Units::J,
    1841        1207 :                                 thisSysLoadRepVars.HCCompNaturalGas,
    1842             :                                 OutputProcessor::TimeStepType::System,
    1843             :                                 OutputProcessor::StoreType::Sum,
    1844             :                                 primaryAirSysName);
    1845             : 
    1846        2414 :             SetupOutputVariable(state,
    1847             :                                 "Air System Heating Coil Propane Energy",
    1848             :                                 Constant::Units::J,
    1849        1207 :                                 thisSysLoadRepVars.HCCompPropane,
    1850             :                                 OutputProcessor::TimeStepType::System,
    1851             :                                 OutputProcessor::StoreType::Sum,
    1852             :                                 primaryAirSysName);
    1853             : 
    1854        2414 :             SetupOutputVariable(state,
    1855             :                                 "Air System Heating Coil Steam Energy",
    1856             :                                 Constant::Units::J,
    1857        1207 :                                 thisSysLoadRepVars.HCCompSteam,
    1858             :                                 OutputProcessor::TimeStepType::System,
    1859             :                                 OutputProcessor::StoreType::Sum,
    1860             :                                 primaryAirSysName);
    1861             : 
    1862        2414 :             SetupOutputVariable(state,
    1863             :                                 "Air System Humidifier Electricity Energy",
    1864             :                                 Constant::Units::J,
    1865        1207 :                                 thisSysLoadRepVars.HumidElec,
    1866             :                                 OutputProcessor::TimeStepType::System,
    1867             :                                 OutputProcessor::StoreType::Sum,
    1868             :                                 primaryAirSysName);
    1869             : 
    1870        2414 :             SetupOutputVariable(state,
    1871             :                                 "Air System Humidifier NaturalGas Energy",
    1872             :                                 Constant::Units::J,
    1873        1207 :                                 thisSysLoadRepVars.HumidNaturalGas,
    1874             :                                 OutputProcessor::TimeStepType::System,
    1875             :                                 OutputProcessor::StoreType::Sum,
    1876             :                                 primaryAirSysName);
    1877             : 
    1878        2414 :             SetupOutputVariable(state,
    1879             :                                 "Air System Humidifier Propane Energy",
    1880             :                                 Constant::Units::J,
    1881        1207 :                                 thisSysLoadRepVars.HumidPropane,
    1882             :                                 OutputProcessor::TimeStepType::System,
    1883             :                                 OutputProcessor::StoreType::Sum,
    1884             :                                 primaryAirSysName);
    1885             : 
    1886        2414 :             SetupOutputVariable(state,
    1887             :                                 "Air System Evaporative Cooler Electricity Energy",
    1888             :                                 Constant::Units::J,
    1889        1207 :                                 thisSysLoadRepVars.EvapElec,
    1890             :                                 OutputProcessor::TimeStepType::System,
    1891             :                                 OutputProcessor::StoreType::Sum,
    1892             :                                 primaryAirSysName);
    1893             : 
    1894        2414 :             SetupOutputVariable(state,
    1895             :                                 "Air System Desiccant Dehumidifier Electricity Energy",
    1896             :                                 Constant::Units::J,
    1897        1207 :                                 thisSysLoadRepVars.DesDehumidElec,
    1898             :                                 OutputProcessor::TimeStepType::System,
    1899             :                                 OutputProcessor::StoreType::Sum,
    1900             :                                 primaryAirSysName);
    1901             : 
    1902        2414 :             SetupOutputVariable(state,
    1903             :                                 "Air System Mechanical Ventilation Flow Rate",
    1904             :                                 Constant::Units::m3_s,
    1905        1207 :                                 thisSysVentRepVars.MechVentFlow,
    1906             :                                 OutputProcessor::TimeStepType::System,
    1907             :                                 OutputProcessor::StoreType::Average,
    1908             :                                 primaryAirSysName);
    1909             : 
    1910        2414 :             SetupOutputVariable(state,
    1911             :                                 "Air System Natural Ventilation Flow Rate",
    1912             :                                 Constant::Units::m3_s,
    1913        1207 :                                 thisSysVentRepVars.NatVentFlow,
    1914             :                                 OutputProcessor::TimeStepType::System,
    1915             :                                 OutputProcessor::StoreType::Average,
    1916             :                                 primaryAirSysName);
    1917             : 
    1918        2414 :             SetupOutputVariable(state,
    1919             :                                 "Air System Target Voz Ventilation Flow Rate",
    1920             :                                 Constant::Units::m3_s,
    1921        1207 :                                 thisSysVentRepVars.TargetVentilationFlowVoz,
    1922             :                                 OutputProcessor::TimeStepType::System,
    1923             :                                 OutputProcessor::StoreType::Average,
    1924             :                                 primaryAirSysName);
    1925             : 
    1926        2414 :             SetupOutputVariable(state,
    1927             :                                 "Air System Ventilation Below Target Voz Time",
    1928             :                                 Constant::Units::hr,
    1929        1207 :                                 thisSysVentRepVars.TimeBelowVozDyn,
    1930             :                                 OutputProcessor::TimeStepType::System,
    1931             :                                 OutputProcessor::StoreType::Sum,
    1932             :                                 primaryAirSysName);
    1933             : 
    1934        2414 :             SetupOutputVariable(state,
    1935             :                                 "Air System Ventilation At Target Voz Time",
    1936             :                                 Constant::Units::hr,
    1937        1207 :                                 thisSysVentRepVars.TimeAtVozDyn,
    1938             :                                 OutputProcessor::TimeStepType::System,
    1939             :                                 OutputProcessor::StoreType::Sum,
    1940             :                                 primaryAirSysName);
    1941             : 
    1942        2414 :             SetupOutputVariable(state,
    1943             :                                 "Air System Ventilation Above Target Voz Time",
    1944             :                                 Constant::Units::hr,
    1945        1207 :                                 thisSysVentRepVars.TimeAboveVozDyn,
    1946             :                                 OutputProcessor::TimeStepType::System,
    1947             :                                 OutputProcessor::StoreType::Sum,
    1948             :                                 primaryAirSysName);
    1949             : 
    1950        2414 :             SetupOutputVariable(state,
    1951             :                                 "Air System Ventilation When Unoccupied Time",
    1952             :                                 Constant::Units::hr,
    1953        1207 :                                 thisSysVentRepVars.TimeVentUnocc,
    1954             :                                 OutputProcessor::TimeStepType::System,
    1955             :                                 OutputProcessor::StoreType::Sum,
    1956             :                                 primaryAirSysName);
    1957        1207 :         }
    1958             :     }
    1959        5845 :     for (int ZoneIndex = 1; ZoneIndex <= state.dataGlobal->NumOfZones; ++ZoneIndex) {
    1960        5050 :         if (!state.dataZoneEquip->ZoneEquipConfig(ZoneIndex).IsControlled) continue;
    1961        4314 :         auto &thisZoneVentRepVars = state.dataSysRpts->ZoneVentRepVars(ZoneIndex);
    1962        4314 :         auto &thisZoneName = state.dataZoneEquip->ZoneEquipConfig(ZoneIndex).ZoneName;
    1963             :         // CurrentModuleObject='Zones(Controlled)'
    1964        4314 :         if (state.dataSysRpts->VentLoadsReportEnabled) {
    1965             :             // Cooling Loads
    1966        8628 :             SetupOutputVariable(state,
    1967             :                                 "Zone Mechanical Ventilation No Load Heat Removal Energy",
    1968             :                                 Constant::Units::J,
    1969        4314 :                                 thisZoneVentRepVars.NoLoadCoolingByVent,
    1970             :                                 OutputProcessor::TimeStepType::System,
    1971             :                                 OutputProcessor::StoreType::Sum,
    1972             :                                 thisZoneName);
    1973             : 
    1974        8628 :             SetupOutputVariable(state,
    1975             :                                 "Zone Mechanical Ventilation Cooling Load Increase Energy",
    1976             :                                 Constant::Units::J,
    1977        4314 :                                 thisZoneVentRepVars.CoolingLoadAddedByVent,
    1978             :                                 OutputProcessor::TimeStepType::System,
    1979             :                                 OutputProcessor::StoreType::Sum,
    1980             :                                 thisZoneName);
    1981             : 
    1982        8628 :             SetupOutputVariable(state,
    1983             :                                 "Zone Mechanical Ventilation Cooling Load Increase Due to Overheating Energy",
    1984             :                                 Constant::Units::J,
    1985        4314 :                                 thisZoneVentRepVars.OverheatingByVent,
    1986             :                                 OutputProcessor::TimeStepType::System,
    1987             :                                 OutputProcessor::StoreType::Sum,
    1988             :                                 thisZoneName);
    1989             : 
    1990        8628 :             SetupOutputVariable(state,
    1991             :                                 "Zone Mechanical Ventilation Cooling Load Decrease Energy",
    1992             :                                 Constant::Units::J,
    1993        4314 :                                 thisZoneVentRepVars.CoolingLoadMetByVent,
    1994             :                                 OutputProcessor::TimeStepType::System,
    1995             :                                 OutputProcessor::StoreType::Sum,
    1996             :                                 thisZoneName);
    1997             :             // Heating Loads
    1998        8628 :             SetupOutputVariable(state,
    1999             :                                 "Zone Mechanical Ventilation No Load Heat Addition Energy",
    2000             :                                 Constant::Units::J,
    2001        4314 :                                 thisZoneVentRepVars.NoLoadHeatingByVent,
    2002             :                                 OutputProcessor::TimeStepType::System,
    2003             :                                 OutputProcessor::StoreType::Sum,
    2004             :                                 thisZoneName);
    2005             : 
    2006        8628 :             SetupOutputVariable(state,
    2007             :                                 "Zone Mechanical Ventilation Heating Load Increase Energy",
    2008             :                                 Constant::Units::J,
    2009        4314 :                                 thisZoneVentRepVars.HeatingLoadAddedByVent,
    2010             :                                 OutputProcessor::TimeStepType::System,
    2011             :                                 OutputProcessor::StoreType::Sum,
    2012             :                                 thisZoneName);
    2013             : 
    2014        8628 :             SetupOutputVariable(state,
    2015             :                                 "Zone Mechanical Ventilation Heating Load Increase Due to Overcooling Energy",
    2016             :                                 Constant::Units::J,
    2017        4314 :                                 thisZoneVentRepVars.OvercoolingByVent,
    2018             :                                 OutputProcessor::TimeStepType::System,
    2019             :                                 OutputProcessor::StoreType::Sum,
    2020             :                                 thisZoneName);
    2021             : 
    2022        8628 :             SetupOutputVariable(state,
    2023             :                                 "Zone Mechanical Ventilation Heating Load Decrease Energy",
    2024             :                                 Constant::Units::J,
    2025        4314 :                                 thisZoneVentRepVars.HeatingLoadMetByVent,
    2026             :                                 OutputProcessor::TimeStepType::System,
    2027             :                                 OutputProcessor::StoreType::Sum,
    2028             :                                 thisZoneName);
    2029             :         }
    2030             : 
    2031        8628 :         SetupOutputVariable(state,
    2032             :                             "Zone Mechanical Ventilation Mass Flow Rate",
    2033             :                             Constant::Units::kg_s,
    2034        4314 :                             thisZoneVentRepVars.OAMassFlow,
    2035             :                             OutputProcessor::TimeStepType::System,
    2036             :                             OutputProcessor::StoreType::Average,
    2037             :                             thisZoneName);
    2038             : 
    2039        8628 :         SetupOutputVariable(state,
    2040             :                             "Zone Mechanical Ventilation Mass",
    2041             :                             Constant::Units::kg,
    2042        4314 :                             thisZoneVentRepVars.OAMass,
    2043             :                             OutputProcessor::TimeStepType::System,
    2044             :                             OutputProcessor::StoreType::Sum,
    2045             :                             thisZoneName);
    2046             : 
    2047        8628 :         SetupOutputVariable(state,
    2048             :                             "Zone Mechanical Ventilation Standard Density Volume Flow Rate",
    2049             :                             Constant::Units::m3_s,
    2050        4314 :                             thisZoneVentRepVars.OAVolFlowStdRho,
    2051             :                             OutputProcessor::TimeStepType::System,
    2052             :                             OutputProcessor::StoreType::Average,
    2053             :                             thisZoneName);
    2054             : 
    2055        8628 :         SetupOutputVariable(state,
    2056             :                             "Zone Mechanical Ventilation Standard Density Volume",
    2057             :                             Constant::Units::m3,
    2058        4314 :                             thisZoneVentRepVars.OAVolStdRho,
    2059             :                             OutputProcessor::TimeStepType::System,
    2060             :                             OutputProcessor::StoreType::Sum,
    2061             :                             thisZoneName);
    2062             : 
    2063        8628 :         SetupOutputVariable(state,
    2064             :                             "Zone Mechanical Ventilation Current Density Volume Flow Rate",
    2065             :                             Constant::Units::m3_s,
    2066        4314 :                             thisZoneVentRepVars.OAVolFlowCrntRho,
    2067             :                             OutputProcessor::TimeStepType::System,
    2068             :                             OutputProcessor::StoreType::Average,
    2069             :                             thisZoneName);
    2070             : 
    2071        8628 :         SetupOutputVariable(state,
    2072             :                             "Zone Mechanical Ventilation Current Density Volume",
    2073             :                             Constant::Units::m3,
    2074        4314 :                             thisZoneVentRepVars.OAVolCrntRho,
    2075             :                             OutputProcessor::TimeStepType::System,
    2076             :                             OutputProcessor::StoreType::Sum,
    2077             :                             thisZoneName);
    2078             : 
    2079        8628 :         SetupOutputVariable(state,
    2080             :                             "Zone Mechanical Ventilation Air Changes per Hour",
    2081             :                             Constant::Units::ach,
    2082        4314 :                             thisZoneVentRepVars.MechACH,
    2083             :                             OutputProcessor::TimeStepType::System,
    2084             :                             OutputProcessor::StoreType::Average,
    2085             :                             thisZoneName);
    2086             : 
    2087        8628 :         SetupOutputVariable(state,
    2088             :                             "Zone Target Voz Ventilation Flow Rate",
    2089             :                             Constant::Units::m3_s,
    2090        4314 :                             thisZoneVentRepVars.TargetVentilationFlowVoz,
    2091             :                             OutputProcessor::TimeStepType::System,
    2092             :                             OutputProcessor::StoreType::Average,
    2093             :                             thisZoneName);
    2094             : 
    2095        8628 :         SetupOutputVariable(state,
    2096             :                             "Zone Ventilation Below Target Voz Time",
    2097             :                             Constant::Units::hr,
    2098        4314 :                             thisZoneVentRepVars.TimeBelowVozDyn,
    2099             :                             OutputProcessor::TimeStepType::System,
    2100             :                             OutputProcessor::StoreType::Sum,
    2101             :                             thisZoneName);
    2102             : 
    2103        8628 :         SetupOutputVariable(state,
    2104             :                             "Zone Ventilation At Target Voz Time",
    2105             :                             Constant::Units::hr,
    2106        4314 :                             thisZoneVentRepVars.TimeAtVozDyn,
    2107             :                             OutputProcessor::TimeStepType::System,
    2108             :                             OutputProcessor::StoreType::Sum,
    2109             :                             thisZoneName);
    2110             : 
    2111        8628 :         SetupOutputVariable(state,
    2112             :                             "Zone Ventilation Above Target Voz Time",
    2113             :                             Constant::Units::hr,
    2114        4314 :                             thisZoneVentRepVars.TimeAboveVozDyn,
    2115             :                             OutputProcessor::TimeStepType::System,
    2116             :                             OutputProcessor::StoreType::Sum,
    2117             :                             thisZoneName);
    2118             : 
    2119        8628 :         SetupOutputVariable(state,
    2120             :                             "Zone Ventilation When Unoccupied Time",
    2121             :                             Constant::Units::hr,
    2122        4314 :                             thisZoneVentRepVars.TimeVentUnocc,
    2123             :                             OutputProcessor::TimeStepType::System,
    2124             :                             OutputProcessor::StoreType::Sum,
    2125             :                             thisZoneName);
    2126             :     }
    2127             : 
    2128             :     // Facility outputs
    2129        1590 :     SetupOutputVariable(state,
    2130             :                         "Facility Any Zone Ventilation Below Target Voz Time",
    2131             :                         Constant::Units::hr,
    2132         795 :                         state.dataSysRpts->AnyZoneTimeBelowVozDyn,
    2133             :                         OutputProcessor::TimeStepType::System,
    2134             :                         OutputProcessor::StoreType::Sum,
    2135             :                         "Facility");
    2136             : 
    2137        1590 :     SetupOutputVariable(state,
    2138             :                         "Facility All Zones Ventilation At Target Voz Time",
    2139             :                         Constant::Units::hr,
    2140         795 :                         state.dataSysRpts->AllZonesTimeAtVozDyn,
    2141             :                         OutputProcessor::TimeStepType::System,
    2142             :                         OutputProcessor::StoreType::Sum,
    2143             :                         "Facility");
    2144             : 
    2145        1590 :     SetupOutputVariable(state,
    2146             :                         "Facility Any Zone Ventilation Above Target Voz Time",
    2147             :                         Constant::Units::hr,
    2148         795 :                         state.dataSysRpts->AnyZoneTimeAboveVozDyn,
    2149             :                         OutputProcessor::TimeStepType::System,
    2150             :                         OutputProcessor::StoreType::Sum,
    2151             :                         "Facility");
    2152             : 
    2153        1590 :     SetupOutputVariable(state,
    2154             :                         "Facility Any Zone Ventilation When Unoccupied Time",
    2155             :                         Constant::Units::hr,
    2156         795 :                         state.dataSysRpts->AnyZoneTimeVentUnocc,
    2157             :                         OutputProcessor::TimeStepType::System,
    2158             :                         OutputProcessor::StoreType::Sum,
    2159             :                         "Facility");
    2160         795 : }
    2161             : 
    2162         795 : void CreateEnergyReportStructure(EnergyPlusData &state)
    2163             : {
    2164             : 
    2165             :     // SUBROUTINE INFORMATION:
    2166             :     //       AUTHOR         Dan Fisher/Linda Lawrie
    2167             :     //       DATE WRITTEN   June 2005
    2168             : 
    2169             :     // PURPOSE OF THIS SUBROUTINE:
    2170             :     // Creates the Energy Reporting Structure.  This routine is only called once --
    2171             :     // so string compares have been left in.
    2172             : 
    2173             :     // METHODOLOGY EMPLOYED:
    2174             :     // Once all compsets/nodes/connections have been established find all components
    2175             :     // subcomponents, etc.
    2176             : 
    2177             :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    2178             :     int AirLoopNum;
    2179             :     int BranchNum;
    2180             :     int CompNum;
    2181             :     int SubCompNum;
    2182             :     int SubSubCompNum;
    2183             :     int VarNum;
    2184             :     int VarNum1;
    2185             :     int CtrlZoneNum;
    2186             :     bool ErrorsFound;
    2187             :     bool ModeFlagOn;
    2188             :     int NumInlets;
    2189             :     int NumOutlets;
    2190             :     int PlantLoopNum;
    2191             : 
    2192             :     // Dimension GetChildrenData arrays
    2193         795 :     EPVector<DataLoopNode::ConnectionObjectType> SubCompTypes;
    2194         795 :     Array1D_string SubCompNames;
    2195         795 :     Array1D_string InletNodeNames;
    2196         795 :     Array1D_int InletNodeNumbers;
    2197         795 :     Array1D<NodeInputManager::CompFluidStream> InletFluidStreams;
    2198         795 :     Array1D_string OutletNodeNames;
    2199         795 :     Array1D_int OutletNodeNumbers;
    2200         795 :     Array1D<NodeInputManager::CompFluidStream> OutletFluidStreams;
    2201             :     int NumChildren;
    2202             :     int NumGrandChildren;
    2203             :     bool IsParent;
    2204             : 
    2205             :     // Dimension GetMeteredVariables arrays
    2206         795 :     Array1D<OutputProcessor::MeteredVar> meteredVars;
    2207             :     int NumVariables;
    2208             :     int NumLeft; // Counter for deeper components
    2209             : 
    2210             :     // some variables for setting up the plant data structures
    2211             : 
    2212         795 :     state.dataSysRpts->VentReportStructureCreated = true;
    2213        2002 :     for (AirLoopNum = 1; AirLoopNum <= state.dataHVACGlobal->NumPrimaryAirSys; ++AirLoopNum) {
    2214        2433 :         for (BranchNum = 1; BranchNum <= state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum).NumBranches; ++BranchNum) {
    2215        4952 :             for (CompNum = 1; CompNum <= state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum).Branch(BranchNum).TotalComponents; ++CompNum) {
    2216             :                 DataLoopNode::ConnectionObjectType TypeOfComp = static_cast<DataLoopNode::ConnectionObjectType>(
    2217        3726 :                     EnergyPlus::getEnumValue(BranchNodeConnections::ConnectionObjectTypeNamesUC,
    2218        3726 :                                              state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum).Branch(BranchNum).Comp(CompNum).TypeOf));
    2219        3726 :                 std::string &NameOfComp = state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum).Branch(BranchNum).Comp(CompNum).Name;
    2220             :                 // Get complete list of components for complex branches
    2221        3726 :                 if (BranchNodeConnections::IsParentObject(state, TypeOfComp, NameOfComp)) {
    2222             : 
    2223        1833 :                     state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum).Branch(BranchNum).Comp(CompNum).Parent = true;
    2224        1833 :                     NumChildren = BranchNodeConnections::GetNumChildren(state, TypeOfComp, NameOfComp);
    2225             : 
    2226        1833 :                     SubCompTypes.allocate(NumChildren);
    2227        1833 :                     SubCompNames.allocate(NumChildren);
    2228        1833 :                     InletNodeNames.allocate(NumChildren);
    2229        1833 :                     InletNodeNumbers.allocate(NumChildren);
    2230        1833 :                     OutletNodeNames.allocate(NumChildren);
    2231        1833 :                     OutletNodeNumbers.allocate(NumChildren);
    2232        1833 :                     state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum).Branch(BranchNum).Comp(CompNum).SubComp.allocate(NumChildren);
    2233             : 
    2234        1833 :                     BranchNodeConnections::GetChildrenData(state,
    2235             :                                                            TypeOfComp,
    2236             :                                                            NameOfComp,
    2237             :                                                            NumChildren,
    2238             :                                                            SubCompTypes,
    2239             :                                                            SubCompNames,
    2240             :                                                            InletNodeNames,
    2241             :                                                            InletNodeNumbers,
    2242             :                                                            OutletNodeNames,
    2243             :                                                            OutletNodeNumbers,
    2244             :                                                            ErrorsFound);
    2245             : 
    2246        5028 :                     for (SubCompNum = 1; SubCompNum <= NumChildren; ++SubCompNum) {
    2247             :                         {
    2248             :                             auto &thisSubComponent =
    2249        3195 :                                 state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum).Branch(BranchNum).Comp(CompNum).SubComp(SubCompNum);
    2250        3195 :                             thisSubComponent.TypeOf = BranchNodeConnections::ConnectionObjectTypeNamesUC[static_cast<int>(SubCompTypes(SubCompNum))];
    2251        3195 :                             thisSubComponent.Name = SubCompNames(SubCompNum);
    2252        3195 :                             thisSubComponent.NodeNameIn = InletNodeNames(SubCompNum);
    2253        3195 :                             thisSubComponent.NodeNameOut = OutletNodeNames(SubCompNum);
    2254        3195 :                             thisSubComponent.NodeNumIn = InletNodeNumbers(SubCompNum);
    2255        3195 :                             thisSubComponent.NodeNumOut = OutletNodeNumbers(SubCompNum);
    2256             :                         }
    2257             :                     }
    2258             : 
    2259        1833 :                     SubCompTypes.deallocate();
    2260        1833 :                     SubCompNames.deallocate();
    2261        1833 :                     InletNodeNames.deallocate();
    2262        1833 :                     InletNodeNumbers.deallocate();
    2263        1833 :                     OutletNodeNames.deallocate();
    2264        1833 :                     OutletNodeNumbers.deallocate();
    2265             : 
    2266             :                 } else {
    2267        1893 :                     NumChildren = 0;
    2268        1893 :                     state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum).Branch(BranchNum).Comp(CompNum).Parent = false;
    2269             :                 }
    2270        3726 :                 state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum).Branch(BranchNum).Comp(CompNum).NumSubComps = NumChildren;
    2271             : 
    2272             :                 // check for 'grandchildren'
    2273        6921 :                 for (SubCompNum = 1; SubCompNum <= NumChildren; ++SubCompNum) {
    2274        3195 :                     DataLoopNode::ConnectionObjectType TypeOfSubComp = static_cast<DataLoopNode::ConnectionObjectType>(EnergyPlus::getEnumValue(
    2275             :                         BranchNodeConnections::ConnectionObjectTypeNamesUC,
    2276        3195 :                         state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum).Branch(BranchNum).Comp(CompNum).SubComp(SubCompNum).TypeOf));
    2277             :                     std::string &NameOfSubComp =
    2278        3195 :                         state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum).Branch(BranchNum).Comp(CompNum).SubComp(SubCompNum).Name;
    2279        3195 :                     if (BranchNodeConnections::IsParentObject(state, TypeOfSubComp, NameOfSubComp)) {
    2280          14 :                         NumGrandChildren = BranchNodeConnections::GetNumChildren(state, TypeOfSubComp, NameOfSubComp);
    2281          14 :                         SubCompTypes.allocate(NumGrandChildren);
    2282          14 :                         SubCompNames.allocate(NumGrandChildren);
    2283          14 :                         InletNodeNames.allocate(NumGrandChildren);
    2284          14 :                         InletNodeNumbers.allocate(NumGrandChildren);
    2285          14 :                         OutletNodeNames.allocate(NumGrandChildren);
    2286          14 :                         OutletNodeNumbers.allocate(NumGrandChildren);
    2287          14 :                         state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum)
    2288          14 :                             .Branch(BranchNum)
    2289          14 :                             .Comp(CompNum)
    2290          14 :                             .SubComp(SubCompNum)
    2291          14 :                             .SubSubComp.allocate(NumGrandChildren);
    2292             : 
    2293          14 :                         BranchNodeConnections::GetChildrenData(state,
    2294             :                                                                TypeOfSubComp,
    2295             :                                                                NameOfSubComp,
    2296             :                                                                NumGrandChildren,
    2297             :                                                                SubCompTypes,
    2298             :                                                                SubCompNames,
    2299             :                                                                InletNodeNames,
    2300             :                                                                InletNodeNumbers,
    2301             :                                                                OutletNodeNames,
    2302             :                                                                OutletNodeNumbers,
    2303             :                                                                ErrorsFound);
    2304             : 
    2305          47 :                         for (SubSubCompNum = 1; SubSubCompNum <= NumGrandChildren; ++SubSubCompNum) {
    2306             :                             {
    2307          33 :                                 auto &thisSubSubComponent = state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum)
    2308          33 :                                                                 .Branch(BranchNum)
    2309          33 :                                                                 .Comp(CompNum)
    2310          33 :                                                                 .SubComp(SubCompNum)
    2311          33 :                                                                 .SubSubComp(SubSubCompNum);
    2312          99 :                                 thisSubSubComponent.TypeOf = static_cast<std::string>(
    2313          66 :                                     BranchNodeConnections::ConnectionObjectTypeNamesUC[static_cast<int>(SubCompTypes(SubSubCompNum))]);
    2314          33 :                                 thisSubSubComponent.Name = SubCompNames(SubSubCompNum);
    2315          33 :                                 thisSubSubComponent.NodeNameIn = InletNodeNames(SubSubCompNum);
    2316          33 :                                 thisSubSubComponent.NodeNameOut = OutletNodeNames(SubSubCompNum);
    2317          33 :                                 thisSubSubComponent.NodeNumIn = InletNodeNumbers(SubSubCompNum);
    2318          33 :                                 thisSubSubComponent.NodeNumOut = OutletNodeNumbers(SubSubCompNum);
    2319          33 :                                 NumLeft = BranchNodeConnections::GetNumChildren(state, SubCompTypes(SubSubCompNum), SubCompNames(SubSubCompNum));
    2320          33 :                                 if (NumLeft > 0) {
    2321           0 :                                     ShowSevereError(
    2322             :                                         state,
    2323           0 :                                         format("Hanging Children for component={}:{}", thisSubSubComponent.TypeOf, SubCompNames(SubSubCompNum)));
    2324             :                                 }
    2325             :                             }
    2326             :                         }
    2327             : 
    2328          14 :                         SubCompTypes.deallocate();
    2329          14 :                         SubCompNames.deallocate();
    2330          14 :                         InletNodeNames.deallocate();
    2331          14 :                         InletNodeNumbers.deallocate();
    2332          14 :                         OutletNodeNames.deallocate();
    2333          14 :                         OutletNodeNumbers.deallocate();
    2334             :                     } else {
    2335        3181 :                         NumGrandChildren = 0;
    2336        3181 :                         state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum).Branch(BranchNum).Comp(CompNum).SubComp(SubCompNum).Parent = false;
    2337             :                     }
    2338             : 
    2339        3195 :                     state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum).Branch(BranchNum).Comp(CompNum).SubComp(SubCompNum).NumSubSubComps =
    2340             :                         NumGrandChildren;
    2341             :                 }
    2342             :             }
    2343             :         }
    2344             :     }
    2345             : 
    2346        2002 :     for (AirLoopNum = 1; AirLoopNum <= state.dataHVACGlobal->NumPrimaryAirSys; ++AirLoopNum) {
    2347        2433 :         for (BranchNum = 1; BranchNum <= state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum).NumBranches; ++BranchNum) {
    2348        4952 :             for (CompNum = 1; CompNum <= state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum).Branch(BranchNum).TotalComponents; ++CompNum) {
    2349             :                 // Get complete list of components for complex branches
    2350             :                 {
    2351        3726 :                     auto &thisComp = state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum).Branch(BranchNum).Comp(CompNum);
    2352        3726 :                     std::string &TypeOfComp = thisComp.TypeOf;
    2353        3726 :                     std::string &NameOfComp = thisComp.Name;
    2354        3726 :                     NumVariables = GetNumMeteredVariables(state, TypeOfComp, NameOfComp);
    2355        3726 :                     if (NumVariables > 0) {
    2356        2009 :                         meteredVars.allocate(NumVariables);
    2357        2009 :                         thisComp.MeteredVar.allocate(NumVariables);
    2358             : 
    2359        2009 :                         thisComp.NumMeteredVars = NumVariables;
    2360        2009 :                         GetMeteredVariables(state, NameOfComp, meteredVars);
    2361        2009 :                         ModeFlagOn = true;
    2362        5857 :                         for (VarNum = 1; VarNum <= NumVariables; ++VarNum) {
    2363             :                             {
    2364        3848 :                                 thisComp.MeteredVar(VarNum) = meteredVars(VarNum); // Copy
    2365        3848 :                                 auto &thisVar = thisComp.MeteredVar(VarNum);
    2366        3848 :                                 if (thisVar.endUseCat == OutputProcessor::EndUseCat::HeatingCoils && ModeFlagOn) {
    2367        2454 :                                     for (VarNum1 = 1; VarNum1 <= NumVariables; ++VarNum1) {
    2368        1799 :                                         thisComp.MeteredVar(VarNum1).heatOrCool = Constant::HeatOrCool::HeatingOnly;
    2369             :                                     }
    2370         655 :                                     ModeFlagOn = false;
    2371        3193 :                                 } else if (thisVar.endUseCat == OutputProcessor::EndUseCat::CoolingCoils && ModeFlagOn) {
    2372        1275 :                                     for (VarNum1 = 1; VarNum1 <= NumVariables; ++VarNum1) {
    2373         850 :                                         thisComp.MeteredVar(VarNum1).heatOrCool = Constant::HeatOrCool::CoolingOnly;
    2374             :                                     }
    2375         425 :                                     ModeFlagOn = false;
    2376        2768 :                                 } else if (ModeFlagOn) {
    2377        1199 :                                     thisVar.heatOrCool = Constant::HeatOrCool::NoHeatNoCool;
    2378             :                                 }
    2379             :                             }
    2380             :                         }
    2381             : 
    2382        2009 :                         meteredVars.deallocate();
    2383             :                     }
    2384        6921 :                     for (SubCompNum = 1; SubCompNum <= thisComp.NumSubComps; ++SubCompNum) {
    2385             :                         // Get complete list of components for complex branches
    2386        3195 :                         std::string &TypeOfSubComp = thisComp.SubComp(SubCompNum).TypeOf;
    2387        3195 :                         std::string &NameOfSubComp = thisComp.SubComp(SubCompNum).Name;
    2388        3195 :                         NumVariables = GetNumMeteredVariables(state, TypeOfSubComp, NameOfSubComp);
    2389        3195 :                         if (NumVariables > 0) {
    2390        2123 :                             meteredVars.allocate(NumVariables);
    2391        2123 :                             thisComp.SubComp(SubCompNum).MeteredVar.allocate(NumVariables);
    2392             : 
    2393        2123 :                             GetMeteredVariables(state, NameOfSubComp, meteredVars);
    2394        2123 :                             ModeFlagOn = true;
    2395        7607 :                             for (VarNum = 1; VarNum <= NumVariables; ++VarNum) {
    2396             :                                 {
    2397        5484 :                                     thisComp.SubComp(SubCompNum).MeteredVar(VarNum) = meteredVars(VarNum);
    2398        5484 :                                     auto &thisVar = thisComp.SubComp(SubCompNum).MeteredVar(VarNum);
    2399        5484 :                                     if (thisVar.endUseCat == OutputProcessor::EndUseCat::HeatingCoils && ModeFlagOn) {
    2400        3329 :                                         for (VarNum1 = 1; VarNum1 <= NumVariables; ++VarNum1) {
    2401        2563 :                                             thisComp.SubComp(SubCompNum).MeteredVar(VarNum1).heatOrCool = Constant::HeatOrCool::HeatingOnly;
    2402             :                                         }
    2403         766 :                                         ModeFlagOn = false;
    2404        4718 :                                     } else if (thisVar.endUseCat == OutputProcessor::EndUseCat::CoolingCoils && ModeFlagOn) {
    2405        3039 :                                         for (VarNum1 = 1; VarNum1 <= NumVariables; ++VarNum1) {
    2406        2246 :                                             thisComp.SubComp(SubCompNum).MeteredVar(VarNum1).heatOrCool = Constant::HeatOrCool::CoolingOnly;
    2407             :                                         }
    2408         793 :                                         ModeFlagOn = false;
    2409        3925 :                                     } else if (ModeFlagOn) {
    2410         983 :                                         thisVar.heatOrCool = Constant::HeatOrCool::NoHeatNoCool;
    2411             :                                     }
    2412             :                                 }
    2413             :                             }
    2414             : 
    2415        2123 :                             meteredVars.deallocate();
    2416             :                         }
    2417             : 
    2418        3195 :                         thisComp.SubComp(SubCompNum).NumMeteredVars = NumVariables;
    2419             : 
    2420        3228 :                         for (SubSubCompNum = 1; SubSubCompNum <= thisComp.SubComp(SubCompNum).NumSubSubComps; ++SubSubCompNum) {
    2421             :                             // Get complete list of components for complex branches
    2422          33 :                             std::string &TypeOfSubSubComp = thisComp.SubComp(SubCompNum).SubSubComp(SubSubCompNum).TypeOf;
    2423          33 :                             std::string &NameOfSubSubComp = thisComp.SubComp(SubCompNum).SubSubComp(SubSubCompNum).Name;
    2424          33 :                             NumVariables = GetNumMeteredVariables(state, TypeOfSubSubComp, NameOfSubSubComp);
    2425          33 :                             if (NumVariables > 0) {
    2426          33 :                                 meteredVars.allocate(NumVariables);
    2427          33 :                                 thisComp.SubComp(SubCompNum).SubSubComp(SubSubCompNum).MeteredVar.allocate(NumVariables);
    2428             : 
    2429          33 :                                 GetMeteredVariables(state, NameOfSubSubComp, meteredVars);
    2430          33 :                                 ModeFlagOn = true;
    2431         126 :                                 for (VarNum = 1; VarNum <= NumVariables; ++VarNum) {
    2432             :                                     {
    2433          93 :                                         thisComp.SubComp(SubCompNum).SubSubComp(SubSubCompNum).MeteredVar(VarNum) = meteredVars(VarNum);
    2434          93 :                                         auto &thisVar = thisComp.SubComp(SubCompNum).SubSubComp(SubSubCompNum).MeteredVar(VarNum);
    2435          93 :                                         if (thisVar.endUseCat == OutputProcessor::EndUseCat::HeatingCoils && ModeFlagOn) {
    2436          43 :                                             for (VarNum1 = 1; VarNum1 <= NumVariables; ++VarNum1) {
    2437          34 :                                                 thisComp.SubComp(SubCompNum).SubSubComp(SubSubCompNum).MeteredVar(VarNum1).heatOrCool =
    2438             :                                                     Constant::HeatOrCool::HeatingOnly;
    2439             :                                             }
    2440           9 :                                             ModeFlagOn = false;
    2441          84 :                                         } else if (thisVar.endUseCat == OutputProcessor::EndUseCat::CoolingCoils && ModeFlagOn) {
    2442          33 :                                             for (VarNum1 = 1; VarNum1 <= NumVariables; ++VarNum1) {
    2443          24 :                                                 thisComp.SubComp(SubCompNum).SubSubComp(SubSubCompNum).MeteredVar(VarNum1).heatOrCool =
    2444             :                                                     Constant::HeatOrCool::CoolingOnly;
    2445             :                                             }
    2446           9 :                                             ModeFlagOn = false;
    2447          75 :                                         } else if (ModeFlagOn) {
    2448          41 :                                             thisVar.heatOrCool = Constant::HeatOrCool::NoHeatNoCool;
    2449             :                                         }
    2450             :                                     }
    2451             :                                 }
    2452             : 
    2453          33 :                                 meteredVars.deallocate();
    2454             :                             }
    2455          33 :                             thisComp.SubComp(SubCompNum).SubSubComp(SubSubCompNum).NumMeteredVars = NumVariables;
    2456             :                         }
    2457             :                     }
    2458             :                 }
    2459             :             }
    2460             :         }
    2461             :     }
    2462             : 
    2463             :     // Allocate the system serving zone equipment component arrays
    2464        5845 :     for (CtrlZoneNum = 1; CtrlZoneNum <= state.dataGlobal->NumOfZones; ++CtrlZoneNum) {
    2465        5050 :         if (!state.dataZoneEquip->ZoneEquipConfig(CtrlZoneNum).IsControlled) continue;
    2466             :         // Set index of air loop serving zone
    2467        9207 :         for (CompNum = 1; CompNum <= state.dataZoneEquip->ZoneEquipList(CtrlZoneNum).NumOfEquipTypes; ++CompNum) {
    2468        4893 :             std::string &TypeOfComp = state.dataZoneEquip->ZoneEquipList(CtrlZoneNum).EquipTypeName(CompNum);
    2469        4893 :             std::string &NameOfComp = state.dataZoneEquip->ZoneEquipList(CtrlZoneNum).EquipName(CompNum);
    2470             :             DataLoopNode::ConnectionObjectType TypeOfCompNum = static_cast<DataLoopNode::ConnectionObjectType>(
    2471        4893 :                 EnergyPlus::getEnumValue(BranchNodeConnections::ConnectionObjectTypeNamesUC, TypeOfComp));
    2472        4893 :             BranchNodeConnections::GetComponentData(state,
    2473             :                                                     TypeOfCompNum,
    2474             :                                                     NameOfComp,
    2475             :                                                     IsParent,
    2476             :                                                     NumInlets,
    2477             :                                                     InletNodeNames,
    2478             :                                                     InletNodeNumbers,
    2479             :                                                     InletFluidStreams,
    2480             :                                                     NumOutlets,
    2481             :                                                     OutletNodeNames,
    2482             :                                                     OutletNodeNumbers,
    2483             :                                                     OutletFluidStreams);
    2484             :             {
    2485        4893 :                 auto &thisEquipData = state.dataZoneEquip->ZoneEquipList(CtrlZoneNum).EquipData(CompNum);
    2486        4893 :                 thisEquipData.TypeOf = TypeOfComp;
    2487        4893 :                 thisEquipData.Name = NameOfComp;
    2488        4893 :                 thisEquipData.OutletNodeNums.allocate(NumOutlets);
    2489        4893 :                 thisEquipData.NumOutlets = NumOutlets;
    2490        4893 :                 thisEquipData.OutletNodeNums = OutletNodeNumbers;
    2491        4893 :                 thisEquipData.InletNodeNums.allocate(NumInlets);
    2492        4893 :                 thisEquipData.NumInlets = NumInlets;
    2493        4893 :                 thisEquipData.InletNodeNums = InletNodeNumbers;
    2494        4893 :                 thisEquipData.Parent = IsParent;
    2495        4893 :                 NumVariables = GetNumMeteredVariables(state, TypeOfComp, NameOfComp);
    2496        4893 :                 thisEquipData.NumMeteredVars = NumVariables;
    2497        4893 :                 if (NumVariables > 0) {
    2498         735 :                     InletNodeNames.deallocate();
    2499         735 :                     InletNodeNumbers.deallocate();
    2500         735 :                     InletFluidStreams.deallocate();
    2501         735 :                     OutletNodeNames.deallocate();
    2502         735 :                     OutletNodeNumbers.deallocate();
    2503         735 :                     OutletFluidStreams.deallocate();
    2504             : 
    2505         735 :                     meteredVars.allocate(NumVariables);
    2506         735 :                     thisEquipData.MeteredVar.allocate(NumVariables);
    2507             : 
    2508         735 :                     GetMeteredVariables(state, NameOfComp, meteredVars);
    2509             : 
    2510         735 :                     ModeFlagOn = true;
    2511        2182 :                     for (VarNum = 1; VarNum <= NumVariables; ++VarNum) {
    2512             :                         {
    2513        1447 :                             thisEquipData.MeteredVar(VarNum) = meteredVars(VarNum);
    2514        1447 :                             auto &thisVar = thisEquipData.MeteredVar(VarNum);
    2515        1447 :                             if (thisVar.endUseCat == OutputProcessor::EndUseCat::HeatingCoils && ModeFlagOn) {
    2516         449 :                                 for (VarNum1 = 1; VarNum1 <= NumVariables; ++VarNum1) {
    2517         357 :                                     thisEquipData.MeteredVar(VarNum1).heatOrCool = Constant::HeatOrCool::HeatingOnly;
    2518             :                                 }
    2519          92 :                                 ModeFlagOn = false;
    2520        1355 :                             } else if (thisVar.endUseCat == OutputProcessor::EndUseCat::CoolingCoils && ModeFlagOn) {
    2521         178 :                                 for (VarNum1 = 1; VarNum1 <= NumVariables; ++VarNum1) {
    2522         107 :                                     thisEquipData.MeteredVar(VarNum1).heatOrCool = Constant::HeatOrCool::CoolingOnly;
    2523             :                                 }
    2524          71 :                                 ModeFlagOn = false;
    2525        1284 :                             } else if (ModeFlagOn) {
    2526         992 :                                 thisVar.heatOrCool = Constant::HeatOrCool::NoHeatNoCool;
    2527             :                             }
    2528             :                         }
    2529             :                     }
    2530             : 
    2531         735 :                     meteredVars.deallocate();
    2532             :                 }
    2533             : 
    2534        4893 :                 if (BranchNodeConnections::IsParentObject(state, TypeOfCompNum, NameOfComp)) {
    2535        4304 :                     NumChildren = BranchNodeConnections::GetNumChildren(state, TypeOfCompNum, NameOfComp);
    2536        4304 :                     thisEquipData.NumSubEquip = NumChildren;
    2537             : 
    2538        4304 :                     SubCompTypes.allocate(NumChildren);
    2539        4304 :                     SubCompNames.allocate(NumChildren);
    2540        4304 :                     InletNodeNames.allocate(NumChildren);
    2541        4304 :                     InletNodeNumbers.allocate(NumChildren);
    2542        4304 :                     OutletNodeNames.allocate(NumChildren);
    2543        4304 :                     OutletNodeNumbers.allocate(NumChildren);
    2544        4304 :                     thisEquipData.SubEquipData.allocate(NumChildren);
    2545             : 
    2546        4304 :                     BranchNodeConnections::GetChildrenData(state,
    2547             :                                                            TypeOfCompNum,
    2548             :                                                            NameOfComp,
    2549             :                                                            NumChildren,
    2550             :                                                            SubCompTypes,
    2551             :                                                            SubCompNames,
    2552             :                                                            InletNodeNames,
    2553             :                                                            InletNodeNumbers,
    2554             :                                                            OutletNodeNames,
    2555             :                                                            OutletNodeNumbers,
    2556             :                                                            ErrorsFound);
    2557             : 
    2558       10191 :                     for (SubCompNum = 1; SubCompNum <= NumChildren; ++SubCompNum) {
    2559        5887 :                         thisEquipData.SubEquipData(SubCompNum).TypeOf =
    2560       11774 :                             BranchNodeConnections::ConnectionObjectTypeNamesUC[static_cast<int>(SubCompTypes(SubCompNum))];
    2561        5887 :                         thisEquipData.SubEquipData(SubCompNum).Name = SubCompNames(SubCompNum);
    2562        5887 :                         thisEquipData.SubEquipData(SubCompNum).OutletNodeNum = OutletNodeNumbers(SubCompNum);
    2563        5887 :                         thisEquipData.SubEquipData(SubCompNum).InletNodeNum = InletNodeNumbers(SubCompNum);
    2564             :                     }
    2565             : 
    2566        4304 :                     SubCompTypes.deallocate();
    2567        4304 :                     SubCompNames.deallocate();
    2568        4304 :                     InletNodeNames.deallocate();
    2569        4304 :                     InletNodeNumbers.deallocate();
    2570        4304 :                     OutletNodeNames.deallocate();
    2571        4304 :                     OutletNodeNumbers.deallocate();
    2572             :                 } else {
    2573         589 :                     NumChildren = 0;
    2574             :                 }
    2575             : 
    2576       10780 :                 for (SubCompNum = 1; SubCompNum <= NumChildren; ++SubCompNum) {
    2577        5887 :                     std::string &TypeOfSubComp = thisEquipData.SubEquipData(SubCompNum).TypeOf;
    2578        5887 :                     std::string &NameOfSubComp = thisEquipData.SubEquipData(SubCompNum).Name;
    2579             :                     DataLoopNode::ConnectionObjectType TypeOfSubCompNum = static_cast<DataLoopNode::ConnectionObjectType>(
    2580        5887 :                         EnergyPlus::getEnumValue(BranchNodeConnections::ConnectionObjectTypeNamesUC, TypeOfSubComp));
    2581        5887 :                     if (BranchNodeConnections::IsParentObject(state, TypeOfSubCompNum, NameOfSubComp)) {
    2582        2594 :                         NumGrandChildren = BranchNodeConnections::GetNumChildren(state, TypeOfSubCompNum, NameOfSubComp);
    2583        2594 :                         thisEquipData.SubEquipData(SubCompNum).NumSubSubEquip = NumGrandChildren;
    2584        2594 :                         SubCompTypes.allocate(NumGrandChildren);
    2585        2594 :                         SubCompNames.allocate(NumGrandChildren);
    2586        2594 :                         InletNodeNames.allocate(NumGrandChildren);
    2587        2594 :                         InletNodeNumbers.allocate(NumGrandChildren);
    2588        2594 :                         OutletNodeNames.allocate(NumGrandChildren);
    2589        2594 :                         OutletNodeNumbers.allocate(NumGrandChildren);
    2590        2594 :                         thisEquipData.SubEquipData(SubCompNum).SubSubEquipData.allocate(NumGrandChildren);
    2591             :                         // Sankar added the array number for EquipData
    2592        2594 :                         BranchNodeConnections::GetChildrenData(state,
    2593             :                                                                TypeOfSubCompNum,
    2594             :                                                                NameOfSubComp,
    2595             :                                                                NumGrandChildren,
    2596             :                                                                SubCompTypes,
    2597             :                                                                SubCompNames,
    2598             :                                                                InletNodeNames,
    2599             :                                                                InletNodeNumbers,
    2600             :                                                                OutletNodeNames,
    2601             :                                                                OutletNodeNumbers,
    2602             :                                                                ErrorsFound);
    2603             : 
    2604        5263 :                         for (SubSubCompNum = 1; SubSubCompNum <= NumGrandChildren; ++SubSubCompNum) {
    2605        2669 :                             thisEquipData.SubEquipData(SubCompNum).SubSubEquipData(SubSubCompNum).TypeOf =
    2606        5338 :                                 BranchNodeConnections::ConnectionObjectTypeNamesUC[static_cast<int>(SubCompTypes(SubSubCompNum))];
    2607        2669 :                             thisEquipData.SubEquipData(SubCompNum).SubSubEquipData(SubSubCompNum).Name = SubCompNames(SubSubCompNum);
    2608        2669 :                             thisEquipData.SubEquipData(SubCompNum).SubSubEquipData(SubSubCompNum).OutletNodeNum = OutletNodeNumbers(SubSubCompNum);
    2609        2669 :                             thisEquipData.SubEquipData(SubCompNum).SubSubEquipData(SubSubCompNum).InletNodeNum = InletNodeNumbers(SubSubCompNum);
    2610             :                         }
    2611        2594 :                         SubCompTypes.deallocate();
    2612        2594 :                         SubCompNames.deallocate();
    2613        2594 :                         InletNodeNames.deallocate();
    2614        2594 :                         InletNodeNumbers.deallocate();
    2615        2594 :                         OutletNodeNames.deallocate();
    2616        2594 :                         OutletNodeNumbers.deallocate();
    2617             :                     } else {
    2618        3293 :                         NumGrandChildren = 0;
    2619             :                     }
    2620             :                 } // for (SubCompNum)
    2621             :             }
    2622             :         } // for (CompNum)
    2623             :     }     // for (CtrlZoneNum)
    2624             : 
    2625        5845 :     for (CtrlZoneNum = 1; CtrlZoneNum <= state.dataGlobal->NumOfZones; ++CtrlZoneNum) {
    2626        5050 :         if (!state.dataZoneEquip->ZoneEquipConfig(CtrlZoneNum).IsControlled) continue;
    2627        9207 :         for (CompNum = 1; CompNum <= state.dataZoneEquip->ZoneEquipList(CtrlZoneNum).NumOfEquipTypes; ++CompNum) {
    2628       10780 :             for (SubCompNum = 1; SubCompNum <= state.dataZoneEquip->ZoneEquipList(CtrlZoneNum).EquipData(CompNum).NumSubEquip; ++SubCompNum) {
    2629        5887 :                 auto &thisSubEquipData = state.dataZoneEquip->ZoneEquipList(CtrlZoneNum).EquipData(CompNum).SubEquipData(SubCompNum);
    2630        5887 :                 std::string &TypeOfSubComp = thisSubEquipData.TypeOf;
    2631        5887 :                 std::string &NameOfSubComp = thisSubEquipData.Name;
    2632             : 
    2633        5887 :                 NumVariables = GetNumMeteredVariables(state, TypeOfSubComp, NameOfSubComp);
    2634        5887 :                 thisSubEquipData.NumMeteredVars = NumVariables; // Sankar added this line
    2635        5887 :                 if (NumVariables > 0) {
    2636        1915 :                     meteredVars.allocate(NumVariables);
    2637        1915 :                     thisSubEquipData.MeteredVar.allocate(NumVariables);
    2638             : 
    2639        1915 :                     GetMeteredVariables(state, NameOfSubComp, meteredVars);
    2640             : 
    2641        1915 :                     ModeFlagOn = true;
    2642        5507 :                     for (VarNum = 1; VarNum <= NumVariables; ++VarNum) {
    2643        3592 :                         thisSubEquipData.MeteredVar(VarNum) = meteredVars(VarNum);
    2644        3592 :                         auto &thisVar = thisSubEquipData.MeteredVar(VarNum);
    2645        3592 :                         if (thisVar.endUseCat == OutputProcessor::EndUseCat::HeatingCoils && ModeFlagOn) {
    2646        1714 :                             for (VarNum1 = 1; VarNum1 <= NumVariables; ++VarNum1) {
    2647        1194 :                                 thisSubEquipData.MeteredVar(VarNum1).heatOrCool = Constant::HeatOrCool::HeatingOnly;
    2648             :                             }
    2649         520 :                             ModeFlagOn = false;
    2650        3072 :                         } else if (thisVar.endUseCat == OutputProcessor::EndUseCat::CoolingCoils && ModeFlagOn) {
    2651        1517 :                             for (VarNum1 = 1; VarNum1 <= NumVariables; ++VarNum1) {
    2652        1066 :                                 thisSubEquipData.MeteredVar(VarNum1).heatOrCool = Constant::HeatOrCool::CoolingOnly;
    2653             :                             }
    2654         451 :                             ModeFlagOn = false;
    2655        2621 :                         } else if (ModeFlagOn) {
    2656        1402 :                             thisVar.heatOrCool = Constant::HeatOrCool::NoHeatNoCool;
    2657             :                         }
    2658             :                     }
    2659             : 
    2660        1915 :                     meteredVars.deallocate();
    2661             :                 } // if (NumVariables > 0)
    2662             : 
    2663        8556 :                 for (SubSubCompNum = 1; SubSubCompNum <= thisSubEquipData.NumSubSubEquip; ++SubSubCompNum) {
    2664        2669 :                     std::string &TypeOfSubSubComp = thisSubEquipData.SubSubEquipData(SubSubCompNum).TypeOf;
    2665        2669 :                     std::string &NameOfSubSubComp = thisSubEquipData.SubSubEquipData(SubSubCompNum).Name;
    2666             : 
    2667        2669 :                     NumVariables = GetNumMeteredVariables(state, TypeOfSubSubComp, NameOfSubSubComp);
    2668        2669 :                     thisSubEquipData.SubSubEquipData(SubSubCompNum).NumMeteredVars = NumVariables; // Sankar added this line
    2669        2669 :                     if (NumVariables > 0) {
    2670        2669 :                         meteredVars.allocate(NumVariables);
    2671        2669 :                         thisSubEquipData.SubSubEquipData(SubSubCompNum).MeteredVar.allocate(NumVariables);
    2672             : 
    2673        2669 :                         GetMeteredVariables(state, NameOfSubSubComp, meteredVars);
    2674        2669 :                         ModeFlagOn = true;
    2675        8154 :                         for (VarNum = 1; VarNum <= NumVariables; ++VarNum) {
    2676        5485 :                             thisSubEquipData.SubSubEquipData(SubSubCompNum).MeteredVar(VarNum) = meteredVars(VarNum);
    2677        5485 :                             auto &thisVar = thisSubEquipData.SubSubEquipData(SubSubCompNum).MeteredVar(VarNum);
    2678        5485 :                             if (thisVar.endUseCat == OutputProcessor::EndUseCat::HeatingCoils && ModeFlagOn) {
    2679        7932 :                                 for (VarNum1 = 1; VarNum1 <= NumVariables; ++VarNum1) {
    2680        5349 :                                     thisSubEquipData.SubSubEquipData(SubSubCompNum).MeteredVar(VarNum1).heatOrCool =
    2681             :                                         Constant::HeatOrCool::HeatingOnly;
    2682             :                                 }
    2683        2583 :                                 ModeFlagOn = false;
    2684        2902 :                             } else if (thisVar.endUseCat == OutputProcessor::EndUseCat::CoolingCoils && ModeFlagOn) {
    2685          80 :                                 for (VarNum1 = 1; VarNum1 <= NumVariables; ++VarNum1) {
    2686          63 :                                     thisSubEquipData.SubSubEquipData(SubSubCompNum).MeteredVar(VarNum1).heatOrCool =
    2687             :                                         Constant::HeatOrCool::CoolingOnly;
    2688             :                                 }
    2689          17 :                                 ModeFlagOn = false;
    2690        2885 :                             } else if (ModeFlagOn) {
    2691          73 :                                 thisVar.heatOrCool = Constant::HeatOrCool::NoHeatNoCool;
    2692             :                             }
    2693             :                         }
    2694             : 
    2695        2669 :                         meteredVars.deallocate();
    2696             :                     } // if (NumVariables > 0)
    2697             :                 }     // for (SubSubCompNum)
    2698             :             }         // for (SubCompNum)
    2699             :         }             // for (CompNum)
    2700             :     }                 // for (CtrlZoneNum)
    2701             : 
    2702             :     //***Plant Loops
    2703             : 
    2704             :     // previously, four separate huge DO loops all looking very very similar were used here
    2705             :     // each individual block would operate on a single type of loop-side (plant demand, cond supply, etc.)
    2706             :     // now, a bigger DO loop is applied iterating over all loops
    2707             :     // a pointer (ThisReportData) is then directed to a particular item in the appropriate array
    2708             :     // by operating on the pointer directly, we are actually operating on the item in the TARGET array item
    2709             :     // in making this change, over 700 lines of code were dropped down to a single block
    2710             : 
    2711        1942 :     for (PlantLoopNum = 1; PlantLoopNum <= state.dataHVACGlobal->NumPlantLoops + state.dataHVACGlobal->NumCondLoops; ++PlantLoopNum) {
    2712        3441 :         for (DataPlant::LoopSideLocation LoopSideNum : DataPlant::LoopSideKeys) {
    2713             : 
    2714             :             // Report selection
    2715        2294 :             ReportLoopData *select_ThisReportData(nullptr);
    2716             : 
    2717        2294 :             assert(LoopSideNum == LoopSideLocation::Demand || LoopSideNum == LoopSideLocation::Supply);
    2718        2294 :             if (PlantLoopNum <= state.dataHVACGlobal->NumPlantLoops) {
    2719        1778 :                 select_ThisReportData = &state.dataPlnt->VentRepPlant[static_cast<int>(LoopSideNum)](PlantLoopNum);
    2720             :             } else { // CondLoop
    2721             :                 select_ThisReportData =
    2722         516 :                     &state.dataPlnt->VentRepCond[static_cast<int>(LoopSideNum)](PlantLoopNum - state.dataHVACGlobal->NumPlantLoops);
    2723             :             }
    2724             : 
    2725             :             // Object Data
    2726        2294 :             ReportLoopData &ThisReportData(*select_ThisReportData);
    2727             : 
    2728       15736 :             for (BranchNum = 1; BranchNum <= ThisReportData.TotalBranches; ++BranchNum) {
    2729       26968 :                 for (CompNum = 1; CompNum <= ThisReportData.Branch(BranchNum).TotalComponents; ++CompNum) {
    2730             :                     {
    2731       13526 :                         auto &thisComp = ThisReportData.Branch(BranchNum).Comp(CompNum);
    2732       13526 :                         std::string &TypeOfComp = thisComp.TypeOf;
    2733       13526 :                         std::string &NameOfComp = thisComp.Name;
    2734             :                         DataLoopNode::ConnectionObjectType TypeOfCompNum = static_cast<DataLoopNode::ConnectionObjectType>(
    2735       13526 :                             EnergyPlus::getEnumValue(BranchNodeConnections::ConnectionObjectTypeNamesUC, TypeOfComp));
    2736             :                         // Get complete list of components for complex branches
    2737       13526 :                         if (BranchNodeConnections::IsParentObject(state, TypeOfCompNum, NameOfComp)) {
    2738             : 
    2739          10 :                             NumChildren = BranchNodeConnections::GetNumChildren(state, TypeOfCompNum, NameOfComp);
    2740             : 
    2741          10 :                             SubCompTypes.allocate(NumChildren);
    2742          10 :                             SubCompNames.allocate(NumChildren);
    2743          10 :                             InletNodeNames.allocate(NumChildren);
    2744          10 :                             InletNodeNumbers.allocate(NumChildren);
    2745          10 :                             OutletNodeNames.allocate(NumChildren);
    2746          10 :                             OutletNodeNumbers.allocate(NumChildren);
    2747          10 :                             thisComp.SubComp.allocate(NumChildren);
    2748             : 
    2749          10 :                             BranchNodeConnections::GetChildrenData(state,
    2750             :                                                                    TypeOfCompNum,
    2751             :                                                                    NameOfComp,
    2752             :                                                                    NumChildren,
    2753             :                                                                    SubCompTypes,
    2754             :                                                                    SubCompNames,
    2755             :                                                                    InletNodeNames,
    2756             :                                                                    InletNodeNumbers,
    2757             :                                                                    OutletNodeNames,
    2758             :                                                                    OutletNodeNumbers,
    2759             :                                                                    ErrorsFound);
    2760             : 
    2761          50 :                             for (SubCompNum = 1; SubCompNum <= NumChildren; ++SubCompNum) {
    2762          40 :                                 thisComp.SubComp(SubCompNum).TypeOf =
    2763          80 :                                     BranchNodeConnections::ConnectionObjectTypeNamesUC[static_cast<int>(SubCompTypes(SubCompNum))];
    2764          40 :                                 thisComp.SubComp(SubCompNum).Name = SubCompNames(SubCompNum);
    2765          40 :                                 thisComp.SubComp(SubCompNum).NodeNameIn = InletNodeNames(SubCompNum);
    2766          40 :                                 thisComp.SubComp(SubCompNum).NodeNameOut = OutletNodeNames(SubCompNum);
    2767          40 :                                 thisComp.SubComp(SubCompNum).NodeNumIn = InletNodeNumbers(SubCompNum);
    2768          40 :                                 thisComp.SubComp(SubCompNum).NodeNumOut = OutletNodeNumbers(SubCompNum);
    2769             :                             }
    2770             : 
    2771          10 :                             SubCompTypes.deallocate();
    2772          10 :                             SubCompNames.deallocate();
    2773          10 :                             InletNodeNames.deallocate();
    2774          10 :                             InletNodeNumbers.deallocate();
    2775          10 :                             OutletNodeNames.deallocate();
    2776          10 :                             OutletNodeNumbers.deallocate();
    2777             : 
    2778             :                         } else {
    2779       13516 :                             NumChildren = 0;
    2780             :                         }
    2781       13526 :                         thisComp.NumSubComps = NumChildren;
    2782             : 
    2783             :                         // check for 'grandchildren'
    2784       13566 :                         for (SubCompNum = 1; SubCompNum <= NumChildren; ++SubCompNum) {
    2785          40 :                             std::string &TypeOfSubComp = thisComp.SubComp(SubCompNum).TypeOf;
    2786          40 :                             std::string NameOfSubComp = thisComp.SubComp(SubCompNum).Name;
    2787             :                             DataLoopNode::ConnectionObjectType TypeOfSubCompNum = static_cast<DataLoopNode::ConnectionObjectType>(
    2788          40 :                                 EnergyPlus::getEnumValue(BranchNodeConnections::ConnectionObjectTypeNamesUC, TypeOfSubComp));
    2789          40 :                             if (BranchNodeConnections::IsParentObject(state, TypeOfSubCompNum, NameOfSubComp)) {
    2790           0 :                                 NumGrandChildren = BranchNodeConnections::GetNumChildren(state, TypeOfSubCompNum, NameOfSubComp);
    2791           0 :                                 SubCompTypes.allocate(NumGrandChildren);
    2792           0 :                                 SubCompNames.allocate(NumGrandChildren);
    2793           0 :                                 InletNodeNames.allocate(NumGrandChildren);
    2794           0 :                                 InletNodeNumbers.allocate(NumGrandChildren);
    2795           0 :                                 OutletNodeNames.allocate(NumGrandChildren);
    2796           0 :                                 OutletNodeNumbers.allocate(NumGrandChildren);
    2797           0 :                                 thisComp.SubComp(SubCompNum).SubSubComp.allocate(NumGrandChildren);
    2798             : 
    2799           0 :                                 BranchNodeConnections::GetChildrenData(state,
    2800             :                                                                        TypeOfSubCompNum,
    2801             :                                                                        NameOfSubComp,
    2802             :                                                                        NumGrandChildren,
    2803             :                                                                        SubCompTypes,
    2804             :                                                                        SubCompNames,
    2805             :                                                                        InletNodeNames,
    2806             :                                                                        InletNodeNumbers,
    2807             :                                                                        OutletNodeNames,
    2808             :                                                                        OutletNodeNumbers,
    2809             :                                                                        ErrorsFound);
    2810             : 
    2811           0 :                                 for (SubSubCompNum = 1; SubSubCompNum <= NumGrandChildren; ++SubSubCompNum) {
    2812             :                                     {
    2813           0 :                                         auto &thisSubSubComp = thisComp.SubComp(SubCompNum).SubSubComp(SubSubCompNum);
    2814             :                                         thisSubSubComp.TypeOf =
    2815           0 :                                             BranchNodeConnections::ConnectionObjectTypeNamesUC[static_cast<int>(SubCompTypes(SubSubCompNum))];
    2816           0 :                                         thisSubSubComp.Name = SubCompNames(SubSubCompNum);
    2817           0 :                                         thisSubSubComp.NodeNameIn = InletNodeNames(SubSubCompNum);
    2818           0 :                                         thisSubSubComp.NodeNameOut = OutletNodeNames(SubSubCompNum);
    2819           0 :                                         thisSubSubComp.NodeNumIn = InletNodeNumbers(SubSubCompNum);
    2820           0 :                                         thisSubSubComp.NodeNumOut = OutletNodeNumbers(SubSubCompNum);
    2821             :                                     }
    2822             :                                 }
    2823             : 
    2824           0 :                                 SubCompTypes.deallocate();
    2825           0 :                                 SubCompNames.deallocate();
    2826           0 :                                 InletNodeNames.deallocate();
    2827           0 :                                 InletNodeNumbers.deallocate();
    2828           0 :                                 OutletNodeNames.deallocate();
    2829           0 :                                 OutletNodeNumbers.deallocate();
    2830             :                             } else {
    2831          40 :                                 NumGrandChildren = 0;
    2832          40 :                                 thisComp.SubComp(SubCompNum).Parent = false;
    2833             :                             }
    2834             : 
    2835          40 :                             thisComp.SubComp(SubCompNum).NumSubSubComps = NumGrandChildren;
    2836          40 :                         }
    2837             :                     }
    2838             :                 }
    2839             :             }
    2840             :         }
    2841             :     }
    2842             : 
    2843        1942 :     for (PlantLoopNum = 1; PlantLoopNum <= state.dataHVACGlobal->NumPlantLoops + state.dataHVACGlobal->NumCondLoops; ++PlantLoopNum) {
    2844             : 
    2845        3441 :         for (DataPlant::LoopSideLocation LoopSideNum : DataPlant::LoopSideKeys) {
    2846             : 
    2847             :             // Report selection
    2848        2294 :             ReportLoopData *select_ThisReportData(nullptr);
    2849             : 
    2850        2294 :             assert(LoopSideNum == LoopSideLocation::Demand || LoopSideNum == LoopSideLocation::Supply);
    2851        2294 :             if (PlantLoopNum <= state.dataHVACGlobal->NumPlantLoops) {
    2852        1778 :                 select_ThisReportData = &state.dataPlnt->VentRepPlant[static_cast<int>(LoopSideNum)](PlantLoopNum);
    2853             :             } else { // CondLoop
    2854             :                 select_ThisReportData =
    2855         516 :                     &state.dataPlnt->VentRepCond[static_cast<int>(LoopSideNum)](PlantLoopNum - state.dataHVACGlobal->NumPlantLoops);
    2856             :             }
    2857             : 
    2858             :             // Object Data
    2859        2294 :             ReportLoopData &ThisReportData(*select_ThisReportData);
    2860             : 
    2861       15736 :             for (BranchNum = 1; BranchNum <= ThisReportData.TotalBranches; ++BranchNum) {
    2862       26968 :                 for (CompNum = 1; CompNum <= ThisReportData.Branch(BranchNum).TotalComponents; ++CompNum) {
    2863             :                     // Get complete list of components for complex branches
    2864       13526 :                     auto &thisComp = ThisReportData.Branch(BranchNum).Comp(CompNum);
    2865       13526 :                     std::string &TypeOfComp = thisComp.TypeOf;
    2866       13526 :                     std::string &NameOfComp = thisComp.Name;
    2867       13526 :                     NumVariables = GetNumMeteredVariables(state, TypeOfComp, NameOfComp);
    2868       13526 :                     if (NumVariables > 0) {
    2869        7922 :                         meteredVars.allocate(NumVariables);
    2870        7922 :                         thisComp.MeteredVar.allocate(NumVariables);
    2871             : 
    2872        7922 :                         thisComp.NumMeteredVars = NumVariables;
    2873        7922 :                         GetMeteredVariables(state, NameOfComp, meteredVars);
    2874        7922 :                         ModeFlagOn = true;
    2875             : 
    2876       26787 :                         for (VarNum = 1; VarNum <= NumVariables; ++VarNum) {
    2877       18865 :                             thisComp.MeteredVar(VarNum) = meteredVars(VarNum);
    2878       18865 :                             auto &thisVar = thisComp.MeteredVar(VarNum);
    2879       18865 :                             if (thisVar.endUseCat == OutputProcessor::EndUseCat::HeatingCoils && ModeFlagOn) {
    2880        9680 :                                 for (VarNum1 = 1; VarNum1 <= NumVariables; ++VarNum1) {
    2881        6615 :                                     thisComp.MeteredVar(VarNum1).heatOrCool = Constant::HeatOrCool::HeatingOnly;
    2882             :                                 }
    2883        3065 :                                 ModeFlagOn = false;
    2884       15800 :                             } else if (thisVar.endUseCat == OutputProcessor::EndUseCat::CoolingCoils && ModeFlagOn) {
    2885        2647 :                                 for (VarNum1 = 1; VarNum1 <= NumVariables; ++VarNum1) {
    2886        1823 :                                     thisComp.MeteredVar(VarNum1).heatOrCool = Constant::HeatOrCool::CoolingOnly;
    2887             :                                 }
    2888         824 :                                 ModeFlagOn = false;
    2889       14976 :                             } else if (ModeFlagOn) {
    2890       10777 :                                 thisVar.heatOrCool = Constant::HeatOrCool::NoHeatNoCool;
    2891             :                             }
    2892             :                         }
    2893             : 
    2894        7922 :                         meteredVars.deallocate();
    2895             :                     } // if (NumVariables > 0)
    2896             : 
    2897       13566 :                     for (SubCompNum = 1; SubCompNum <= thisComp.NumSubComps; ++SubCompNum) {
    2898             :                         // Get complete list of components for complex branches
    2899          40 :                         std::string &TypeOfSubComp = thisComp.SubComp(SubCompNum).TypeOf;
    2900          40 :                         std::string &NameOfSubComp = thisComp.SubComp(SubCompNum).Name;
    2901          40 :                         NumVariables = GetNumMeteredVariables(state, TypeOfSubComp, NameOfSubComp);
    2902          40 :                         if (NumVariables > 0) {
    2903          40 :                             meteredVars.allocate(NumVariables);
    2904          40 :                             thisComp.SubComp(SubCompNum).MeteredVar.allocate(NumVariables);
    2905             : 
    2906          40 :                             GetMeteredVariables(state, NameOfSubComp, meteredVars);
    2907          40 :                             ModeFlagOn = true;
    2908             : 
    2909         176 :                             for (VarNum = 1; VarNum <= NumVariables; ++VarNum) {
    2910         136 :                                 thisComp.SubComp(SubCompNum).MeteredVar(VarNum) = meteredVars(VarNum);
    2911         136 :                                 auto &thisVar = thisComp.SubComp(SubCompNum).MeteredVar(VarNum);
    2912         136 :                                 if (thisVar.endUseCat == OutputProcessor::EndUseCat::HeatingCoils && ModeFlagOn) {
    2913          24 :                                     for (VarNum1 = 1; VarNum1 <= NumVariables; ++VarNum1) {
    2914          20 :                                         thisComp.SubComp(SubCompNum).MeteredVar(VarNum1).heatOrCool = Constant::HeatOrCool::HeatingOnly;
    2915             :                                     }
    2916           4 :                                     ModeFlagOn = false;
    2917         132 :                                 } else if (thisVar.endUseCat == OutputProcessor::EndUseCat::CoolingCoils && ModeFlagOn) {
    2918          56 :                                     for (VarNum1 = 1; VarNum1 <= NumVariables; ++VarNum1) {
    2919          42 :                                         thisComp.SubComp(SubCompNum).MeteredVar(VarNum1).heatOrCool = Constant::HeatOrCool::CoolingOnly;
    2920             :                                     }
    2921          14 :                                     ModeFlagOn = false;
    2922         118 :                                 } else if (ModeFlagOn) {
    2923          78 :                                     thisVar.heatOrCool = Constant::HeatOrCool::NoHeatNoCool;
    2924             :                                 }
    2925             :                             }
    2926             : 
    2927          40 :                             meteredVars.deallocate();
    2928             :                         } // if (NumVariables > 0)
    2929             : 
    2930          40 :                         thisComp.SubComp(SubCompNum).NumMeteredVars = NumVariables;
    2931             :                     } // for (SubCompNum)
    2932             :                 }     // for (CompNum)
    2933             :             }         // for (BranchNum)
    2934             :         }             // for (LoopSide)
    2935             :     }                 // for (PlantLoopNum)
    2936         795 : } // CreateEnergyReportStructure()
    2937             : 
    2938             : // End Initialization Section of the Module
    2939             : //******************************************************************************
    2940             : 
    2941             : // Beginning of Reporting subroutines for the SimAir Module
    2942             : // *****************************************************************************
    2943             : 
    2944      615229 : void ReportSystemEnergyUse(EnergyPlusData &state)
    2945             : {
    2946             :     // SUBROUTINE INFORMATION:
    2947             :     //       AUTHOR         Dan Fisher
    2948             :     //       DATE WRITTEN   November 2005
    2949             : 
    2950             :     // PURPOSE OF THIS SUBROUTINE:
    2951             :     // calculate and report system loads and energy
    2952             : 
    2953             :     // METHODOLOGY EMPLOYED:
    2954             :     // Accumulate meter data to appropriate report variables
    2955             : 
    2956             :     int Idx;          // loop counter
    2957             :     int nodes;        // loop counter
    2958             :     int BranchNum;    // counter for zone air distribution inlets
    2959             :     int EquipListNum; // counter for zone air distribution inlets
    2960             :     int VarNum;       // counter for zone air distribution inlets
    2961             :     int CompNum;
    2962             :     int SubCompNum;
    2963             :     int SubSubCompNum;
    2964             :     Constant::HeatOrCool CompMode;
    2965             :     int InletNodeNum;
    2966             :     int OutletNodeNum;
    2967             :     int ADUNum;
    2968             :     int ADUCoolNum;
    2969             :     int ADUHeatNum;
    2970             :     int AirDistCoolInletNodeNum;
    2971             :     int AirDistHeatInletNodeNum;
    2972             :     Constant::eResource EnergyType;
    2973             :     Real64 CompEnergyUse;
    2974             :     Real64 ZoneLoad;
    2975             :     Real64 CompLoad;
    2976             :     Real64 ADUCoolFlowrate;
    2977             :     Real64 ADUHeatFlowrate;
    2978             :     bool CompLoadFlag;
    2979             : 
    2980      615229 :     Real64 TimeStepSysSec = state.dataHVACGlobal->TimeStepSysSec;
    2981      615229 :     if (!state.dataSysRpts->AirLoopLoadsReportEnabled) return;
    2982             : 
    2983     1462657 :     for (int airLoopNum = 1; airLoopNum <= state.dataHVACGlobal->NumPrimaryAirSys; ++airLoopNum) {
    2984      847428 :         auto &thisSysLoadRepVars = state.dataSysRpts->SysLoadRepVars(airLoopNum);
    2985             :         // SYSTEM LOADS REPORT
    2986      847428 :         thisSysLoadRepVars.TotHTNG = 0.0;
    2987      847428 :         thisSysLoadRepVars.TotCLNG = 0.0;
    2988             : 
    2989             :         // SYSTEM ENERGY USE REPORT
    2990      847428 :         thisSysLoadRepVars.TotElec = 0.0;
    2991      847428 :         thisSysLoadRepVars.TotNaturalGas = 0.0;
    2992      847428 :         thisSysLoadRepVars.TotPropane = 0.0;
    2993      847428 :         thisSysLoadRepVars.TotSteam = 0.0;
    2994      847428 :         thisSysLoadRepVars.TotH2OCOLD = 0.0;
    2995      847428 :         thisSysLoadRepVars.TotH2OHOT = 0.0;
    2996             : 
    2997             :         // SYSTEM COMPONENT LOADS REPORT
    2998      847428 :         thisSysLoadRepVars.FANCompHTNG = 0.0;
    2999      847428 :         thisSysLoadRepVars.CCCompCLNG = 0.0;
    3000      847428 :         thisSysLoadRepVars.HCCompHTNG = 0.0;
    3001      847428 :         thisSysLoadRepVars.HeatExHTNG = 0.0;
    3002      847428 :         thisSysLoadRepVars.HeatExCLNG = 0.0;
    3003      847428 :         thisSysLoadRepVars.SolarCollectHeating = 0.0;
    3004      847428 :         thisSysLoadRepVars.SolarCollectCooling = 0.0;
    3005      847428 :         thisSysLoadRepVars.UserDefinedTerminalHeating = 0.0;
    3006      847428 :         thisSysLoadRepVars.UserDefinedTerminalCooling = 0.0;
    3007      847428 :         thisSysLoadRepVars.HumidHTNG = 0.0;
    3008      847428 :         thisSysLoadRepVars.EvapCLNG = 0.0;
    3009      847428 :         thisSysLoadRepVars.DesDehumidCLNG = 0.0;
    3010      847428 :         thisSysLoadRepVars.DomesticH2O = 0.0;
    3011             : 
    3012             :         // SYSTEM COMPONENT ENERGY REPORT
    3013      847428 :         thisSysLoadRepVars.FANCompElec = 0.0;
    3014      847428 :         thisSysLoadRepVars.HCCompH2OHOT = 0.0;
    3015      847428 :         thisSysLoadRepVars.CCCompH2OCOLD = 0.0;
    3016      847428 :         thisSysLoadRepVars.HCCompElec = 0.0;
    3017      847428 :         thisSysLoadRepVars.CCCompElec = 0.0;
    3018      847428 :         thisSysLoadRepVars.HCCompElecRes = 0.0;
    3019      847428 :         thisSysLoadRepVars.HCCompNaturalGas = 0.0;
    3020      847428 :         thisSysLoadRepVars.HCCompPropane = 0.0;
    3021      847428 :         thisSysLoadRepVars.HCCompSteam = 0.0;
    3022      847428 :         thisSysLoadRepVars.HumidElec = 0.0;
    3023      847428 :         thisSysLoadRepVars.HumidNaturalGas = 0.0;
    3024      847428 :         thisSysLoadRepVars.HumidPropane = 0.0;
    3025      847428 :         thisSysLoadRepVars.DesDehumidElec = 0.0;
    3026      847428 :         thisSysLoadRepVars.EvapElec = 0.0;
    3027             :     }
    3028             : 
    3029      615229 :     auto &Node = state.dataLoopNodes->Node;
    3030             : 
    3031     1462657 :     for (int AirLoopNum = 1; AirLoopNum <= state.dataHVACGlobal->NumPrimaryAirSys; ++AirLoopNum) {
    3032      847428 :         auto const &pas = state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum);
    3033     1705116 :         for (BranchNum = 1; BranchNum <= pas.NumBranches; ++BranchNum) {
    3034      857688 :             auto const &pasBranch = pas.Branch(BranchNum);
    3035      857688 :             if (Node(pasBranch.NodeNumOut).MassFlowRate <= 0.0) continue;
    3036     2352276 :             for (CompNum = 1; CompNum <= pasBranch.TotalComponents; ++CompNum) {
    3037     1765514 :                 auto const &pasBranchComp = pasBranch.Comp(CompNum);
    3038     1765514 :                 InletNodeNum = pasBranchComp.NodeNumIn;
    3039     1765514 :                 OutletNodeNum = pasBranchComp.NodeNumOut;
    3040     1765514 :                 if (InletNodeNum <= 0 || OutletNodeNum <= 0) continue;
    3041     1765514 :                 CompLoad = Node(OutletNodeNum).MassFlowRate * (Psychrometrics::PsyHFnTdbW(Node(InletNodeNum).Temp, Node(InletNodeNum).HumRat) -
    3042     1765514 :                                                                Psychrometrics::PsyHFnTdbW(Node(OutletNodeNum).Temp, Node(OutletNodeNum).HumRat));
    3043     1765514 :                 CompLoad *= TimeStepSysSec;
    3044     1765514 :                 CompEnergyUse = 0.0;
    3045     1765514 :                 EnergyType = Constant::eResource::Invalid;
    3046     1765514 :                 CompLoadFlag = true;
    3047     1765514 :                 CalcSystemEnergyUse(state, CompLoadFlag, AirLoopNum, pasBranchComp.TypeOf, EnergyType, CompLoad, CompEnergyUse);
    3048     1765514 :                 CompLoadFlag = false;
    3049     3686779 :                 for (VarNum = 1; VarNum <= pasBranchComp.NumMeteredVars; ++VarNum) {
    3050     1921265 :                     auto const &pasBranchCompMeter = pasBranchComp.MeteredVar(VarNum);
    3051     1921265 :                     CompMode = pasBranchCompMeter.heatOrCool;
    3052     1921265 :                     CompEnergyUse = pasBranchCompMeter.curMeterReading;
    3053     1921265 :                     EnergyType = pasBranchCompMeter.resource;
    3054     1921265 :                     CalcSystemEnergyUse(state, CompLoadFlag, AirLoopNum, pasBranchComp.TypeOf, EnergyType, CompLoad, CompEnergyUse);
    3055             :                 }
    3056             : 
    3057     3486824 :                 for (SubCompNum = 1; SubCompNum <= pasBranchComp.NumSubComps; ++SubCompNum) {
    3058     1721310 :                     auto const &pasBranchSubComp = pasBranchComp.SubComp(SubCompNum);
    3059     1721310 :                     InletNodeNum = pasBranchSubComp.NodeNumIn;
    3060     1721310 :                     OutletNodeNum = pasBranchSubComp.NodeNumOut;
    3061     1721310 :                     if (InletNodeNum <= 0 || OutletNodeNum <= 0) continue;
    3062     1721310 :                     CompLoad = Node(OutletNodeNum).MassFlowRate * (Psychrometrics::PsyHFnTdbW(Node(InletNodeNum).Temp, Node(InletNodeNum).HumRat) -
    3063     1721310 :                                                                    Psychrometrics::PsyHFnTdbW(Node(OutletNodeNum).Temp, Node(OutletNodeNum).HumRat));
    3064     1721310 :                     CompLoad *= TimeStepSysSec;
    3065     1721310 :                     CompEnergyUse = 0.0;
    3066     1721310 :                     EnergyType = Constant::eResource::Invalid;
    3067     1721310 :                     CompLoadFlag = true;
    3068     1721310 :                     CalcSystemEnergyUse(state, CompLoadFlag, AirLoopNum, pasBranchSubComp.TypeOf, EnergyType, CompLoad, CompEnergyUse);
    3069     1721310 :                     CompLoadFlag = false;
    3070     4668783 :                     for (VarNum = 1; VarNum <= pasBranchSubComp.NumMeteredVars; ++VarNum) {
    3071     2947473 :                         auto const &pasBranchSubCompMeter = pasBranchSubComp.MeteredVar(VarNum);
    3072     2947473 :                         CompMode = pasBranchSubCompMeter.heatOrCool;
    3073     2947473 :                         CompEnergyUse = pasBranchSubCompMeter.curMeterReading;
    3074     2947473 :                         EnergyType = pasBranchSubCompMeter.resource;
    3075     2947473 :                         CalcSystemEnergyUse(state, CompLoadFlag, AirLoopNum, pasBranchSubComp.TypeOf, EnergyType, CompLoad, CompEnergyUse);
    3076             :                     }
    3077             : 
    3078     1731502 :                     for (SubSubCompNum = 1; SubSubCompNum <= pasBranchSubComp.NumSubSubComps; ++SubSubCompNum) {
    3079       10192 :                         auto const &pasBranchSubSubComp = pasBranchSubComp.SubSubComp(SubSubCompNum);
    3080       10192 :                         InletNodeNum = pasBranchSubSubComp.NodeNumIn;
    3081       10192 :                         OutletNodeNum = pasBranchSubSubComp.NodeNumOut;
    3082       10192 :                         if (InletNodeNum <= 0 || OutletNodeNum <= 0) continue;
    3083       10192 :                         CompLoad =
    3084       10192 :                             Node(OutletNodeNum).MassFlowRate * (Psychrometrics::PsyHFnTdbW(Node(InletNodeNum).Temp, Node(InletNodeNum).HumRat) -
    3085       10192 :                                                                 Psychrometrics::PsyHFnTdbW(Node(OutletNodeNum).Temp, Node(OutletNodeNum).HumRat));
    3086       10192 :                         CompLoad *= TimeStepSysSec;
    3087       10192 :                         CompEnergyUse = 0.0;
    3088       10192 :                         EnergyType = Constant::eResource::Invalid;
    3089       10192 :                         CompLoadFlag = true;
    3090       10192 :                         CalcSystemEnergyUse(state, CompLoadFlag, AirLoopNum, pasBranchSubSubComp.TypeOf, EnergyType, CompLoad, CompEnergyUse);
    3091       10192 :                         CompLoadFlag = false;
    3092       39763 :                         for (VarNum = 1; VarNum <= pasBranchSubSubComp.NumMeteredVars; ++VarNum) {
    3093       29571 :                             auto const &pasBranchSubSubCompMeter = pasBranchSubSubComp.MeteredVar(VarNum);
    3094       29571 :                             CompMode = pasBranchSubSubCompMeter.heatOrCool;
    3095       29571 :                             CompEnergyUse = pasBranchSubSubCompMeter.curMeterReading;
    3096       29571 :                             EnergyType = pasBranchSubSubCompMeter.resource;
    3097       29571 :                             CalcSystemEnergyUse(state, CompLoadFlag, AirLoopNum, pasBranchSubSubComp.TypeOf, EnergyType, CompLoad, CompEnergyUse);
    3098             :                         }
    3099             :                     } // for (SubSubCompNum)
    3100             :                 }     // for (SubCompNum)
    3101             :             }         // for (CompNum)
    3102             :         }             // for (BranchNum)
    3103             :     }                 // for (AirLoopNum)
    3104             : 
    3105     4001607 :     for (int CtrlZoneNum = 1; CtrlZoneNum <= state.dataGlobal->NumOfZones; ++CtrlZoneNum) {
    3106     3386378 :         auto const &zecCtrlZone = state.dataZoneEquip->ZoneEquipConfig(CtrlZoneNum);
    3107     3386378 :         if (!zecCtrlZone.IsControlled) continue;
    3108             : 
    3109     2913258 :         ZoneLoad = state.dataZoneEnergyDemand->ZoneSysEnergyDemand(CtrlZoneNum).TotalOutputRequired;
    3110             : 
    3111             :         // if system operating in deadband reset zone load
    3112     2913258 :         if (state.dataZoneEnergyDemand->DeadBandOrSetback(CtrlZoneNum)) ZoneLoad = 0.0;
    3113             : 
    3114             :         // loop over the zone supply air path inlet nodes
    3115     5837020 :         for (int ZoneInNum = 1; ZoneInNum <= zecCtrlZone.NumInletNodes; ++ZoneInNum) {
    3116             :             // retrieve air loop indexes
    3117     2923762 :             int AirLoopNum = zecCtrlZone.InletNodeAirLoopNum(ZoneInNum);
    3118     2923762 :             if (AirLoopNum == 0) continue;
    3119             : 
    3120     2255099 :             auto const &zecCtrlZoneCool = zecCtrlZone.AirDistUnitCool(ZoneInNum);
    3121     2255099 :             auto const &zecCtrlZoneHeat = zecCtrlZone.AirDistUnitHeat(ZoneInNum);
    3122             : 
    3123     2255099 :             AirDistCoolInletNodeNum = max(zecCtrlZoneCool.InNode, 0);
    3124     2255099 :             AirDistHeatInletNodeNum = max(zecCtrlZoneHeat.InNode, 0);
    3125             : 
    3126             :             // Set for cooling or heating path
    3127     2255099 :             if (AirDistCoolInletNodeNum > 0 && AirDistHeatInletNodeNum == 0) {
    3128     2203002 :                 ADUCoolFlowrate = max(Node(zecCtrlZoneCool.InNode).MassFlowRate, 0.0);
    3129       52097 :             } else if (AirDistHeatInletNodeNum > 0 && AirDistCoolInletNodeNum == 0) {
    3130           0 :                 ADUHeatFlowrate = max(Node(zecCtrlZoneHeat.InNode).MassFlowRate, 0.0);
    3131             :             } else {
    3132       52097 :                 ADUCoolFlowrate = 0.0;
    3133       52097 :                 ADUHeatFlowrate = 0.0;
    3134             :             }
    3135             : 
    3136     2255099 :             EquipListNum = zecCtrlZone.EquipListIndex;
    3137     2255099 :             auto const &zel = state.dataZoneEquip->ZoneEquipList(EquipListNum);
    3138             : 
    3139     6765297 :             for (Idx = 1; Idx <= 2; ++Idx) {
    3140     4510198 :                 if (Idx == 1) {
    3141     2255099 :                     ADUCoolNum = max(zecCtrlZoneCool.AirDistUnitIndex, 0);
    3142     2255099 :                     if (ADUCoolNum == 0) continue;
    3143     2255099 :                     ADUNum = ADUCoolNum;
    3144             :                 } else { //(Idx =2)THEN
    3145     2255099 :                     ADUHeatNum = max(zecCtrlZoneHeat.AirDistUnitIndex, 0);
    3146     2255099 :                     if (ADUHeatNum == 0) continue;
    3147       52097 :                     ADUNum = ADUHeatNum;
    3148             :                 }
    3149             : 
    3150     2307196 :                 auto const &zelEquipData = zel.EquipData(ADUNum);
    3151             : 
    3152     2307196 :                 CompLoad = 0.0;
    3153     2307196 :                 if (zelEquipData.NumInlets > 0) {
    3154           0 :                     for (nodes = 1; nodes <= zelEquipData.NumInlets; ++nodes) {
    3155           0 :                         InletNodeNum = zelEquipData.InletNodeNums(Idx);
    3156           0 :                         CompLoad +=
    3157           0 :                             (Psychrometrics::PsyHFnTdbW(Node(InletNodeNum).Temp, Node(InletNodeNum).HumRat) * Node(InletNodeNum).MassFlowRate);
    3158             :                     }
    3159           0 :                     for (nodes = 1; nodes <= zelEquipData.NumOutlets; ++nodes) {
    3160           0 :                         OutletNodeNum = zelEquipData.OutletNodeNums(Idx);
    3161           0 :                         CompLoad -=
    3162           0 :                             (Psychrometrics::PsyHFnTdbW(Node(OutletNodeNum).Temp, Node(OutletNodeNum).HumRat) * Node(OutletNodeNum).MassFlowRate);
    3163             :                     }
    3164             :                 }
    3165     2307196 :                 CompLoad *= TimeStepSysSec;
    3166     2307196 :                 CompEnergyUse = 0.0;
    3167     2307196 :                 EnergyType = Constant::eResource::Invalid;
    3168     2307196 :                 CompLoadFlag = true;
    3169     2307196 :                 CalcSystemEnergyUse(state, CompLoadFlag, AirLoopNum, zelEquipData.TypeOf, EnergyType, CompLoad, CompEnergyUse);
    3170     2307196 :                 CompLoadFlag = false;
    3171     2388796 :                 for (VarNum = 1; VarNum <= zelEquipData.NumMeteredVars; ++VarNum) {
    3172       81600 :                     CompEnergyUse = zelEquipData.MeteredVar(VarNum).curMeterReading;
    3173       81600 :                     EnergyType = zelEquipData.MeteredVar(VarNum).resource;
    3174       81600 :                     CalcSystemEnergyUse(state, CompLoadFlag, AirLoopNum, zelEquipData.TypeOf, EnergyType, CompLoad, CompEnergyUse);
    3175             :                 }
    3176             : 
    3177     4646218 :                 for (SubCompNum = 1; SubCompNum <= zelEquipData.NumSubEquip; ++SubCompNum) {
    3178     2339022 :                     auto const &zelSubEquipData = zelEquipData.SubEquipData(SubCompNum);
    3179     2339022 :                     InletNodeNum = zelSubEquipData.InletNodeNum;
    3180     2339022 :                     OutletNodeNum = zelSubEquipData.OutletNodeNum;
    3181     2339022 :                     if (InletNodeNum <= 0 || OutletNodeNum <= 0) continue;
    3182     2339022 :                     CompLoad = Node(InletNodeNum).MassFlowRate * (Psychrometrics::PsyHFnTdbW(Node(InletNodeNum).Temp, Node(InletNodeNum).HumRat) -
    3183     2339022 :                                                                   Psychrometrics::PsyHFnTdbW(Node(OutletNodeNum).Temp, Node(OutletNodeNum).HumRat));
    3184     2339022 :                     CompLoad *= TimeStepSysSec;
    3185     2339022 :                     CompEnergyUse = 0.0;
    3186     2339022 :                     EnergyType = Constant::eResource::Invalid;
    3187     2339022 :                     CompLoadFlag = true;
    3188     2339022 :                     CalcSystemEnergyUse(state, CompLoadFlag, AirLoopNum, zelSubEquipData.TypeOf, EnergyType, CompLoad, CompEnergyUse);
    3189     2339022 :                     CompLoadFlag = false;
    3190     2424462 :                     for (VarNum = 1; VarNum <= zelSubEquipData.NumMeteredVars; ++VarNum) {
    3191       85440 :                         CompEnergyUse = zelSubEquipData.MeteredVar(VarNum).curMeterReading;
    3192       85440 :                         EnergyType = zelSubEquipData.MeteredVar(VarNum).resource;
    3193       85440 :                         CalcSystemEnergyUse(state, CompLoadFlag, AirLoopNum, zelSubEquipData.TypeOf, EnergyType, CompLoad, CompEnergyUse);
    3194             :                     }
    3195             : 
    3196     3946575 :                     for (SubSubCompNum = 1; SubSubCompNum <= zelSubEquipData.NumSubSubEquip; ++SubSubCompNum) {
    3197     1607553 :                         auto const &zelSubSubEquipData = zelSubEquipData.SubSubEquipData(SubSubCompNum);
    3198     1607553 :                         InletNodeNum = zelSubSubEquipData.InletNodeNum;
    3199     1607553 :                         OutletNodeNum = zelSubSubEquipData.OutletNodeNum;
    3200     1607553 :                         if (InletNodeNum <= 0 || OutletNodeNum <= 0) continue;
    3201     1607553 :                         CompLoad =
    3202     1607553 :                             Node(InletNodeNum).MassFlowRate * (Psychrometrics::PsyHFnTdbW(Node(InletNodeNum).Temp, Node(InletNodeNum).HumRat) -
    3203     1607553 :                                                                Psychrometrics::PsyHFnTdbW(Node(OutletNodeNum).Temp, Node(OutletNodeNum).HumRat));
    3204     1607553 :                         CompLoad *= TimeStepSysSec;
    3205     1607553 :                         CompEnergyUse = 0.0;
    3206     1607553 :                         EnergyType = Constant::eResource::Invalid;
    3207     1607553 :                         CompLoadFlag = true;
    3208     1607553 :                         CalcSystemEnergyUse(state, CompLoadFlag, AirLoopNum, zelSubSubEquipData.TypeOf, EnergyType, CompLoad, CompEnergyUse);
    3209     1607553 :                         CompLoadFlag = false;
    3210     4860467 :                         for (VarNum = 1; VarNum <= zelSubSubEquipData.NumMeteredVars; ++VarNum) {
    3211     3252914 :                             CompEnergyUse = zelSubSubEquipData.MeteredVar(VarNum).curMeterReading;
    3212     3252914 :                             EnergyType = zelSubSubEquipData.MeteredVar(VarNum).resource;
    3213     3252914 :                             CalcSystemEnergyUse(state, CompLoadFlag, AirLoopNum, zelSubSubEquipData.TypeOf, EnergyType, CompLoad, CompEnergyUse);
    3214             :                         }
    3215             :                     } // SubSubCompNum
    3216             :                 }     // SubCompNum
    3217             :             }         // Idx
    3218             :         }             // ZoneInNum
    3219             :     }                 // Controlled Zone Loop
    3220             : 
    3221     1462657 :     for (int airLoopNum = 1; airLoopNum <= state.dataHVACGlobal->NumPrimaryAirSys; ++airLoopNum) {
    3222      847428 :         auto &thisSysLoadRepVars = state.dataSysRpts->SysLoadRepVars(airLoopNum);
    3223      847428 :         thisSysLoadRepVars.TotHTNG = thisSysLoadRepVars.FANCompHTNG + thisSysLoadRepVars.HCCompHTNG + thisSysLoadRepVars.HeatExHTNG +
    3224      847428 :                                      thisSysLoadRepVars.HumidHTNG + thisSysLoadRepVars.SolarCollectHeating +
    3225      847428 :                                      thisSysLoadRepVars.UserDefinedTerminalHeating;
    3226      847428 :         thisSysLoadRepVars.TotCLNG = thisSysLoadRepVars.CCCompCLNG + thisSysLoadRepVars.HeatExCLNG + thisSysLoadRepVars.EvapCLNG +
    3227      847428 :                                      thisSysLoadRepVars.DesDehumidCLNG + thisSysLoadRepVars.SolarCollectCooling +
    3228      847428 :                                      thisSysLoadRepVars.UserDefinedTerminalCooling;
    3229      847428 :         thisSysLoadRepVars.TotElec = thisSysLoadRepVars.FANCompElec + thisSysLoadRepVars.HCCompElec + thisSysLoadRepVars.CCCompElec +
    3230      847428 :                                      thisSysLoadRepVars.HCCompElecRes + thisSysLoadRepVars.HumidElec + thisSysLoadRepVars.DesDehumidElec +
    3231      847428 :                                      thisSysLoadRepVars.EvapElec;
    3232      847428 :         thisSysLoadRepVars.TotNaturalGas = thisSysLoadRepVars.HCCompNaturalGas + thisSysLoadRepVars.HumidNaturalGas;
    3233      847428 :         thisSysLoadRepVars.TotPropane = thisSysLoadRepVars.HCCompPropane + thisSysLoadRepVars.HumidPropane;
    3234      847428 :         thisSysLoadRepVars.TotSteam = thisSysLoadRepVars.HCCompSteam;
    3235      847428 :         thisSysLoadRepVars.TotH2OCOLD = thisSysLoadRepVars.CCCompH2OCOLD;
    3236      847428 :         thisSysLoadRepVars.TotH2OHOT = thisSysLoadRepVars.HCCompH2OHOT;
    3237             :     }
    3238             : }
    3239             : 
    3240    18069050 : void CalcSystemEnergyUse(EnergyPlusData &state,
    3241             :                          bool const CompLoadFlag,
    3242             :                          int const AirLoopNum,
    3243             :                          std::string const &CompType,
    3244             :                          Constant::eResource const EnergyType,
    3245             :                          Real64 const CompLoad,
    3246             :                          Real64 const CompEnergy)
    3247             : {
    3248             :     // SUBROUTINE INFORMATION:
    3249             :     //       AUTHOR         Dan Fisher
    3250             :     //       DATE WRITTEN   Nov. 2005
    3251             : 
    3252             :     // PURPOSE OF THIS SUBROUTINE:
    3253             :     // accumulate system loads and energy to report variables
    3254             : 
    3255             :     // Tuned String comparisons were a big performance hit
    3256             :     // ComponentTypes and component_strings must remain in sync
    3257             :     enum ComponentTypes
    3258             :     { // Using older enum style to avoid the name scoping cruft
    3259             :         AIRLOOPHVAC_OUTDOORAIRSYSTEM,
    3260             :         AIRLOOPHVAC_UNITARY_FURNACE_HEATCOOL,
    3261             :         AIRLOOPHVAC_UNITARY_FURNACE_HEATONLY,
    3262             :         AIRLOOPHVAC_UNITARYHEATCOOL,
    3263             :         AIRLOOPHVAC_UNITARYHEATCOOL_VAVCHANGEOVERBYPASS,
    3264             :         AIRLOOPHVAC_UNITARYHEATONLY,
    3265             :         AIRLOOPHVAC_UNITARYHEATPUMP_AIRTOAIR,
    3266             :         AIRLOOPHVAC_UNITARYHEATPUMP_AIRTOAIR_MULTISPEED,
    3267             :         AIRLOOPHVAC_UNITARYHEATPUMP_WATERTOAIR,
    3268             :         AIRLOOPHVAC_UNITARYSYSTEM,
    3269             :         AIRTERMINAL_DUALDUCT_CONSTANTVOLUME_COOL,
    3270             :         AIRTERMINAL_DUALDUCT_CONSTANTVOLUME_HEAT,
    3271             :         AIRTERMINAL_DUALDUCT_VAV_COOL,
    3272             :         AIRTERMINAL_DUALDUCT_VAV_HEAT,
    3273             :         AIRTERMINAL_DUALDUCT_VAV_OUTDOORAIR_OUTDOORAIR,
    3274             :         AIRTERMINAL_DUALDUCT_VAV_OUTDOORAIR_RECIRCULATEDAIR,
    3275             :         AIRTERMINAL_SINGLEDUCT_CONSTANTVOLUME_COOLEDBEAM,
    3276             :         AIRTERMINAL_SINGLEDUCT_CONSTANTVOLUME_FOURPIPEBEAM,
    3277             :         AIRTERMINAL_SINGLEDUCT_CONSTANTVOLUME_FOURPIPEINDUCTION,
    3278             :         AIRTERMINAL_SINGLEDUCT_CONSTANTVOLUME_REHEAT,
    3279             :         AIRTERMINAL_SINGLEDUCT_CONSTANTVOLUME_NOREHEAT,
    3280             :         AIRTERMINAL_SINGLEDUCT_MIXER,
    3281             :         AIRTERMINAL_SINGLEDUCT_PARALLELPIU_REHEAT,
    3282             :         AIRTERMINAL_SINGLEDUCT_SERIESPIU_REHEAT,
    3283             :         AIRTERMINAL_SINGLEDUCT_USERDEFINED,
    3284             :         AIRTERMINAL_SINGLEDUCT_VAV_HEATANDCOOL_NOREHEAT,
    3285             :         AIRTERMINAL_SINGLEDUCT_VAV_HEATANDCOOL_REHEAT,
    3286             :         AIRTERMINAL_SINGLEDUCT_VAV_NOREHEAT,
    3287             :         AIRTERMINAL_SINGLEDUCT_VAV_REHEAT,
    3288             :         AIRTERMINAL_SINGLEDUCT_VAV_REHEAT_VARIABLESPEEDFAN,
    3289             :         COIL_COOLING_DX,
    3290             :         COIL_COOLING_DX_MULTISPEED,
    3291             :         COIL_COOLING_DX_SINGLESPEED,
    3292             :         COIL_COOLING_DX_SINGLESPEED_THERMALSTORAGE,
    3293             :         COIL_COOLING_DX_TWOSPEED,
    3294             :         COIL_COOLING_DX_TWOSTAGEWITHHUMIDITYCONTROLMODE,
    3295             :         COIL_COOLING_DX_VARIABLESPEED,
    3296             :         COIL_INTEGRATED_DX_VARIABLESPEED,
    3297             :         COIL_COOLING_WATER,
    3298             :         COIL_COOLING_WATER_DETAILEDGEOMETRY,
    3299             :         COIL_COOLING_WATERTOAIRHEATPUMP_EQUATIONFIT,
    3300             :         COIL_COOLING_WATERTOAIRHEATPUMP_PARAMETERESTIMATION,
    3301             :         COIL_COOLING_WATERTOAIRHEATPUMP_VARIABLESPEEDEQUATIONFIT,
    3302             :         COIL_HEATING_DESUPERHEATER,
    3303             :         COIL_HEATING_DX_MULTISPEED,
    3304             :         COIL_HEATING_DX_SINGLESPEED,
    3305             :         COIL_HEATING_DX_VARIABLESPEED,
    3306             :         COIL_HEATING_ELECTRIC,
    3307             :         COIL_HEATING_ELECTRIC_MULTISTAGE,
    3308             :         COIL_HEATING_GAS,
    3309             :         COIL_HEATING_GAS_MULTISTAGE,
    3310             :         COIL_HEATING_STEAM,
    3311             :         COIL_HEATING_WATER,
    3312             :         COIL_HEATING_WATERTOAIRHEATPUMP_EQUATIONFIT,
    3313             :         COIL_HEATING_WATERTOAIRHEATPUMP_PARAMETERESTIMATION,
    3314             :         COIL_HEATING_WATERTOAIRHEATPUMP_VARIABLESPEEDEQUATIONFIT,
    3315             :         COIL_WATERHEATING_AIRTOWATERHEATPUMP_VARIABLESPEED,
    3316             :         COIL_USERDEFINED,
    3317             :         COILSYSTEM_COOLING_DX,
    3318             :         COILSYSTEM_COOLING_DX_HEATEXCHANGERASSISTED,
    3319             :         COILSYSTEM_COOLING_WATER_HEATEXCHANGERASSISTED,
    3320             :         COILSYSTEM_COOLING_WATER,
    3321             :         COILSYSTEM_HEATING_DX,
    3322             :         DEHUMIDIFIER_DESICCANT_NOFANS,
    3323             :         DEHUMIDIFIER_DESICCANT_SYSTEM,
    3324             :         DUCT,
    3325             :         EVAPORATIVECOOLER_DIRECT_CELDEKPAD,
    3326             :         EVAPORATIVECOOLER_DIRECT_RESEARCHSPECIAL,
    3327             :         EVAPORATIVECOOLER_INDIRECT_CELDEKPAD,
    3328             :         EVAPORATIVECOOLER_INDIRECT_RESEARCHSPECIAL,
    3329             :         EVAPORATIVECOOLER_INDIRECT_WETCOIL,
    3330             :         FAN_COMPONENTMODEL,
    3331             :         FAN_SYSTEMMODEL,
    3332             :         FAN_CONSTANTVOLUME,
    3333             :         FAN_ONOFF,
    3334             :         FAN_VARIABLEVOLUME,
    3335             :         HEATEXCHANGER_AIRTOAIR_FLATPLATE,
    3336             :         HEATEXCHANGER_AIRTOAIR_SENSIBLEANDLATENT,
    3337             :         HEATEXCHANGER_DESICCANT_BALANCEDFLOW,
    3338             :         HUMIDIFIER_STEAM_ELECTRIC,
    3339             :         HUMIDIFIER_STEAM_GAS,
    3340             :         OUTDOORAIR_MIXER,
    3341             :         SOLARCOLLECTOR_FLATPLATE_PHOTOVOLTAICTHERMAL,
    3342             :         SOLARCOLLECTOR_UNGLAZEDTRANSPIRED,
    3343             :         ZONEHVAC_AIRDISTRIBUTIONUNIT,
    3344             :         ZONEHVAC_TERMINALUNIT_VRF,
    3345             :         COIL_COOLING_VRF,
    3346             :         COIL_HEATING_VRF,
    3347             :         COIL_COOLING_VRF_FTC,
    3348             :         COIL_HEATING_VRF_FTC,
    3349             :         n_ComponentTypes,
    3350             :         Unknown_ComponentType
    3351             :     };
    3352             : 
    3353             :     static std::unordered_map<std::string, ComponentTypes> const component_map = {
    3354           0 :         {"AIRLOOPHVAC:OUTDOORAIRSYSTEM", AIRLOOPHVAC_OUTDOORAIRSYSTEM},
    3355           0 :         {"AIRLOOPHVAC:UNITARY:FURNACE:HEATCOOL", AIRLOOPHVAC_UNITARY_FURNACE_HEATCOOL},
    3356           0 :         {"AIRLOOPHVAC:UNITARY:FURNACE:HEATONLY", AIRLOOPHVAC_UNITARY_FURNACE_HEATONLY},
    3357           0 :         {"AIRLOOPHVAC:UNITARYHEATCOOL", AIRLOOPHVAC_UNITARYHEATCOOL},
    3358           0 :         {"AIRLOOPHVAC:UNITARYHEATCOOL:VAVCHANGEOVERBYPASS", AIRLOOPHVAC_UNITARYHEATCOOL_VAVCHANGEOVERBYPASS},
    3359           0 :         {"AIRLOOPHVAC:UNITARYHEATONLY", AIRLOOPHVAC_UNITARYHEATONLY},
    3360           0 :         {"AIRLOOPHVAC:UNITARYHEATPUMP:AIRTOAIR", AIRLOOPHVAC_UNITARYHEATPUMP_AIRTOAIR},
    3361           0 :         {"AIRLOOPHVAC:UNITARYHEATPUMP:AIRTOAIR:MULTISPEED", AIRLOOPHVAC_UNITARYHEATPUMP_AIRTOAIR_MULTISPEED},
    3362           0 :         {"AIRLOOPHVAC:UNITARYHEATPUMP:WATERTOAIR", AIRLOOPHVAC_UNITARYHEATPUMP_WATERTOAIR},
    3363           0 :         {"AIRLOOPHVAC:UNITARYSYSTEM", AIRLOOPHVAC_UNITARYSYSTEM},
    3364           0 :         {"AIRTERMINAL:DUALDUCT:CONSTANTVOLUME:COOL", AIRTERMINAL_DUALDUCT_CONSTANTVOLUME_COOL},
    3365           0 :         {"AIRTERMINAL:DUALDUCT:CONSTANTVOLUME:HEAT", AIRTERMINAL_DUALDUCT_CONSTANTVOLUME_HEAT},
    3366           0 :         {"AIRTERMINAL:DUALDUCT:VAV:COOL", AIRTERMINAL_DUALDUCT_VAV_COOL},
    3367           0 :         {"AIRTERMINAL:DUALDUCT:VAV:HEAT", AIRTERMINAL_DUALDUCT_VAV_HEAT},
    3368           0 :         {"AIRTERMINAL:DUALDUCT:VAV:OUTDOORAIR:OUTDOORAIR", AIRTERMINAL_DUALDUCT_VAV_OUTDOORAIR_OUTDOORAIR},
    3369           0 :         {"AIRTERMINAL:DUALDUCT:VAV:OUTDOORAIR:RECIRCULATEDAIR", AIRTERMINAL_DUALDUCT_VAV_OUTDOORAIR_RECIRCULATEDAIR},
    3370           0 :         {"AIRTERMINAL:SINGLEDUCT:CONSTANTVOLUME:COOLEDBEAM", AIRTERMINAL_SINGLEDUCT_CONSTANTVOLUME_COOLEDBEAM},
    3371           0 :         {"AIRTERMINAL:SINGLEDUCT:CONSTANTVOLUME:FOURPIPEBEAM", AIRTERMINAL_SINGLEDUCT_CONSTANTVOLUME_FOURPIPEBEAM},
    3372           0 :         {"AIRTERMINAL:SINGLEDUCT:CONSTANTVOLUME:FOURPIPEINDUCTION", AIRTERMINAL_SINGLEDUCT_CONSTANTVOLUME_FOURPIPEINDUCTION},
    3373           0 :         {"AIRTERMINAL:SINGLEDUCT:CONSTANTVOLUME:REHEAT", AIRTERMINAL_SINGLEDUCT_CONSTANTVOLUME_REHEAT},
    3374           0 :         {"AIRTERMINAL:SINGLEDUCT:CONSTANTVOLUME:NOREHEAT", AIRTERMINAL_SINGLEDUCT_CONSTANTVOLUME_NOREHEAT},
    3375           0 :         {"AIRTERMINAL:SINGLEDUCT:MIXER", AIRTERMINAL_SINGLEDUCT_MIXER},
    3376           0 :         {"AIRTERMINAL:SINGLEDUCT:PARALLELPIU:REHEAT", AIRTERMINAL_SINGLEDUCT_PARALLELPIU_REHEAT},
    3377           0 :         {"AIRTERMINAL:SINGLEDUCT:SERIESPIU:REHEAT", AIRTERMINAL_SINGLEDUCT_SERIESPIU_REHEAT},
    3378           0 :         {"AIRTERMINAL:SINGLEDUCT:USERDEFINED", AIRTERMINAL_SINGLEDUCT_USERDEFINED},
    3379           0 :         {"AIRTERMINAL:SINGLEDUCT:VAV:HEATANDCOOL:NOREHEAT", AIRTERMINAL_SINGLEDUCT_VAV_HEATANDCOOL_NOREHEAT},
    3380           0 :         {"AIRTERMINAL:SINGLEDUCT:VAV:HEATANDCOOL:REHEAT", AIRTERMINAL_SINGLEDUCT_VAV_HEATANDCOOL_REHEAT},
    3381           0 :         {"AIRTERMINAL:SINGLEDUCT:VAV:NOREHEAT", AIRTERMINAL_SINGLEDUCT_VAV_NOREHEAT},
    3382           0 :         {"AIRTERMINAL:SINGLEDUCT:VAV:REHEAT", AIRTERMINAL_SINGLEDUCT_VAV_REHEAT},
    3383           0 :         {"AIRTERMINAL:SINGLEDUCT:VAV:REHEAT:VARIABLESPEEDFAN", AIRTERMINAL_SINGLEDUCT_VAV_REHEAT_VARIABLESPEEDFAN},
    3384           0 :         {"COIL:COOLING:DX", COIL_COOLING_DX},
    3385           0 :         {"COIL:COOLING:DX:MULTISPEED", COIL_COOLING_DX_MULTISPEED},
    3386           0 :         {"COIL:COOLING:DX:SINGLESPEED", COIL_COOLING_DX_SINGLESPEED},
    3387           0 :         {"COIL:COOLING:DX:SINGLESPEED:THERMALSTORAGE", COIL_COOLING_DX_SINGLESPEED_THERMALSTORAGE},
    3388           0 :         {"COIL:COOLING:DX:TWOSPEED", COIL_COOLING_DX_TWOSPEED},
    3389           0 :         {"COIL:COOLING:DX:TWOSTAGEWITHHUMIDITYCONTROLMODE", COIL_COOLING_DX_TWOSTAGEWITHHUMIDITYCONTROLMODE},
    3390           0 :         {"COIL:COOLING:DX:VARIABLESPEED", COIL_COOLING_DX_VARIABLESPEED},
    3391           0 :         {"COILSYSTEM:INTEGRATEDHEATPUMP:AIRSOURCE", COIL_INTEGRATED_DX_VARIABLESPEED},
    3392           0 :         {"COIL:COOLING:WATER", COIL_COOLING_WATER},
    3393           0 :         {"COIL:COOLING:WATER:DETAILEDGEOMETRY", COIL_COOLING_WATER_DETAILEDGEOMETRY},
    3394           0 :         {"COIL:COOLING:WATERTOAIRHEATPUMP:EQUATIONFIT", COIL_COOLING_WATERTOAIRHEATPUMP_EQUATIONFIT},
    3395           0 :         {"COIL:COOLING:WATERTOAIRHEATPUMP:PARAMETERESTIMATION", COIL_COOLING_WATERTOAIRHEATPUMP_PARAMETERESTIMATION},
    3396           0 :         {"COIL:COOLING:WATERTOAIRHEATPUMP:VARIABLESPEEDEQUATIONFIT", COIL_COOLING_WATERTOAIRHEATPUMP_VARIABLESPEEDEQUATIONFIT},
    3397           0 :         {"COIL:HEATING:DESUPERHEATER", COIL_HEATING_DESUPERHEATER},
    3398           0 :         {"COIL:HEATING:DX:MULTISPEED", COIL_HEATING_DX_MULTISPEED},
    3399           0 :         {"COIL:HEATING:DX:SINGLESPEED", COIL_HEATING_DX_SINGLESPEED},
    3400           0 :         {"COIL:HEATING:DX:VARIABLESPEED", COIL_HEATING_DX_VARIABLESPEED},
    3401           0 :         {"COIL:HEATING:ELECTRIC", COIL_HEATING_ELECTRIC},
    3402           0 :         {"COIL:HEATING:ELECTRIC:MULTISTAGE", COIL_HEATING_ELECTRIC_MULTISTAGE},
    3403           0 :         {"COIL:HEATING:FUEL", COIL_HEATING_GAS},
    3404           0 :         {"COIL:HEATING:GAS:MULTISTAGE", COIL_HEATING_GAS_MULTISTAGE},
    3405           0 :         {"COIL:HEATING:STEAM", COIL_HEATING_STEAM},
    3406           0 :         {"COIL:HEATING:WATER", COIL_HEATING_WATER},
    3407           0 :         {"COIL:HEATING:WATERTOAIRHEATPUMP:EQUATIONFIT", COIL_HEATING_WATERTOAIRHEATPUMP_EQUATIONFIT},
    3408           0 :         {"COIL:HEATING:WATERTOAIRHEATPUMP:PARAMETERESTIMATION", COIL_HEATING_WATERTOAIRHEATPUMP_PARAMETERESTIMATION},
    3409           0 :         {"COIL:HEATING:WATERTOAIRHEATPUMP:VARIABLESPEEDEQUATIONFIT", COIL_HEATING_WATERTOAIRHEATPUMP_VARIABLESPEEDEQUATIONFIT},
    3410           0 :         {"COIL:WATERHEATING:AIRTOWATERHEATPUMP:VARIABLESPEED", COIL_WATERHEATING_AIRTOWATERHEATPUMP_VARIABLESPEED},
    3411           0 :         {"COIL:USERDEFINED", COIL_USERDEFINED},
    3412           0 :         {"COILSYSTEM:COOLING:DX", COILSYSTEM_COOLING_DX},
    3413           0 :         {"COILSYSTEM:COOLING:DX:HEATEXCHANGERASSISTED", COILSYSTEM_COOLING_DX_HEATEXCHANGERASSISTED},
    3414           0 :         {"COILSYSTEM:COOLING:WATER:HEATEXCHANGERASSISTED", COILSYSTEM_COOLING_WATER_HEATEXCHANGERASSISTED},
    3415           0 :         {"COILSYSTEM:COOLING:WATER", COILSYSTEM_COOLING_WATER},
    3416           0 :         {"COILSYSTEM:HEATING:DX", COILSYSTEM_HEATING_DX},
    3417           0 :         {"DEHUMIDIFIER:DESICCANT:NOFANS", DEHUMIDIFIER_DESICCANT_NOFANS},
    3418           0 :         {"DEHUMIDIFIER:DESICCANT:SYSTEM", DEHUMIDIFIER_DESICCANT_SYSTEM},
    3419           0 :         {"DUCT", DUCT},
    3420           0 :         {"EVAPORATIVECOOLER:DIRECT:CELDEKPAD", EVAPORATIVECOOLER_DIRECT_CELDEKPAD},
    3421           0 :         {"EVAPORATIVECOOLER:DIRECT:RESEARCHSPECIAL", EVAPORATIVECOOLER_DIRECT_RESEARCHSPECIAL},
    3422           0 :         {"EVAPORATIVECOOLER:INDIRECT:CELDEKPAD", EVAPORATIVECOOLER_INDIRECT_CELDEKPAD},
    3423           0 :         {"EVAPORATIVECOOLER:INDIRECT:RESEARCHSPECIAL", EVAPORATIVECOOLER_INDIRECT_RESEARCHSPECIAL},
    3424           0 :         {"EVAPORATIVECOOLER:INDIRECT:WETCOIL", EVAPORATIVECOOLER_INDIRECT_WETCOIL},
    3425           0 :         {"FAN:COMPONENTMODEL", FAN_COMPONENTMODEL},
    3426           0 :         {"FAN:SYSTEMMODEL", FAN_SYSTEMMODEL},
    3427           0 :         {"FAN:CONSTANTVOLUME", FAN_CONSTANTVOLUME},
    3428           0 :         {"FAN:ONOFF", FAN_ONOFF},
    3429           0 :         {"FAN:VARIABLEVOLUME", FAN_VARIABLEVOLUME},
    3430           0 :         {"HEATEXCHANGER:AIRTOAIR:FLATPLATE", HEATEXCHANGER_AIRTOAIR_FLATPLATE},
    3431           0 :         {"HEATEXCHANGER:AIRTOAIR:SENSIBLEANDLATENT", HEATEXCHANGER_AIRTOAIR_SENSIBLEANDLATENT},
    3432           0 :         {"HEATEXCHANGER:DESICCANT:BALANCEDFLOW", HEATEXCHANGER_DESICCANT_BALANCEDFLOW},
    3433           0 :         {"HUMIDIFIER:STEAM:ELECTRIC", HUMIDIFIER_STEAM_ELECTRIC},
    3434           0 :         {"HUMIDIFIER:STEAM:GAS", HUMIDIFIER_STEAM_GAS},
    3435           0 :         {"OUTDOORAIR:MIXER", OUTDOORAIR_MIXER},
    3436           0 :         {"SOLARCOLLECTOR:FLATPLATE:PHOTOVOLTAICTHERMAL", SOLARCOLLECTOR_FLATPLATE_PHOTOVOLTAICTHERMAL},
    3437           0 :         {"SOLARCOLLECTOR:UNGLAZEDTRANSPIRED", SOLARCOLLECTOR_UNGLAZEDTRANSPIRED},
    3438           0 :         {"ZONEHVAC:AIRDISTRIBUTIONUNIT", ZONEHVAC_AIRDISTRIBUTIONUNIT},
    3439           0 :         {"ZONEHVAC:TERMINALUNIT:VARIABLEREFRIGERANTFLOW", ZONEHVAC_TERMINALUNIT_VRF},
    3440           0 :         {"COIL:COOLING:DX:VARIABLEREFRIGERANTFLOW", COIL_COOLING_VRF},
    3441           0 :         {"COIL:HEATING:DX:VARIABLEREFRIGERANTFLOW", COIL_HEATING_VRF},
    3442           0 :         {"COIL:COOLING:DX:VARIABLEREFRIGERANTFLOW:FLUIDTEMPERATURECONTROL", COIL_COOLING_VRF_FTC},
    3443    18117650 :         {"COIL:HEATING:DX:VARIABLEREFRIGERANTFLOW:FLUIDTEMPERATURECONTROL", COIL_HEATING_VRF_FTC}};
    3444    18069050 :     assert(component_map.size() == n_ComponentTypes);
    3445             : 
    3446    18069050 :     if (!state.dataSysRpts->AirLoopLoadsReportEnabled) return;
    3447    18069050 :     auto &thisSysLoadRepVars = state.dataSysRpts->SysLoadRepVars(AirLoopNum);
    3448             : 
    3449             :     // Find enum for the component type string
    3450             :     ComponentTypes comp_type;
    3451    18069050 :     auto const it = component_map.find(CompType);
    3452    18069050 :     if (it != component_map.end()) {
    3453    18069050 :         comp_type = it->second;
    3454             :     } else {
    3455           0 :         comp_type = Unknown_ComponentType;
    3456             :     }
    3457             : 
    3458    18069050 :     switch (comp_type) {
    3459      534443 :     case AIRLOOPHVAC_OUTDOORAIRSYSTEM: // Outside Air System
    3460             :         // Not reported
    3461      534443 :         break;
    3462      535448 :     case OUTDOORAIR_MIXER: // Outdoor Air Mixer
    3463             :         // No energy transfers to account for
    3464      535448 :         break;
    3465       27248 :     case AIRTERMINAL_SINGLEDUCT_MIXER:
    3466             :         // No energy transfers to account for
    3467       27248 :         break;
    3468     1204168 :     case FAN_CONSTANTVOLUME:
    3469             :     case FAN_VARIABLEVOLUME:
    3470             :     case FAN_ONOFF:
    3471             :     case FAN_SYSTEMMODEL:
    3472             :     case FAN_COMPONENTMODEL:
    3473             : 
    3474     1204168 :         if (CompLoadFlag) thisSysLoadRepVars.FANCompHTNG += std::abs(CompLoad);
    3475     1204168 :         thisSysLoadRepVars.FANCompElec += CompEnergy;
    3476             : 
    3477             :         // Cooling Coil Types for the air sys simulation
    3478     1204168 :         break;
    3479     2260655 :     case COILSYSTEM_COOLING_DX_HEATEXCHANGERASSISTED:
    3480             :     case COIL_COOLING_DX_SINGLESPEED:
    3481             :     case COIL_COOLING_DX_TWOSPEED:
    3482             :     case COIL_COOLING_DX_TWOSTAGEWITHHUMIDITYCONTROLMODE:
    3483             :     case COIL_COOLING_DX:
    3484             :     case COIL_COOLING_DX_MULTISPEED:
    3485             :     case COIL_COOLING_WATERTOAIRHEATPUMP_EQUATIONFIT:
    3486             :     case COIL_COOLING_WATERTOAIRHEATPUMP_PARAMETERESTIMATION:
    3487             :     case COIL_COOLING_WATERTOAIRHEATPUMP_VARIABLESPEEDEQUATIONFIT:
    3488             :     case COIL_COOLING_DX_VARIABLESPEED:
    3489             :     case COILSYSTEM_COOLING_WATER_HEATEXCHANGERASSISTED:
    3490             :     case COILSYSTEM_COOLING_WATER:
    3491             :     case COIL_COOLING_WATER_DETAILEDGEOMETRY:
    3492             :     case COIL_COOLING_WATER:
    3493             :     case COIL_COOLING_DX_SINGLESPEED_THERMALSTORAGE:
    3494             :     case COIL_COOLING_VRF:
    3495             :     case COIL_COOLING_VRF_FTC:
    3496             :     case COIL_WATERHEATING_AIRTOWATERHEATPUMP_VARIABLESPEED:
    3497             : 
    3498     2260655 :         if (CompLoadFlag) thisSysLoadRepVars.CCCompCLNG += std::abs(CompLoad);
    3499     2260655 :         if ((EnergyType == Constant::eResource::PlantLoopCoolingDemand) || (EnergyType == Constant::eResource::DistrictCooling)) {
    3500      313454 :             thisSysLoadRepVars.CCCompH2OCOLD += CompEnergy;
    3501     1947201 :         } else if (EnergyType == Constant::eResource::Electricity) {
    3502      638058 :             thisSysLoadRepVars.CCCompElec += CompEnergy;
    3503             :         }
    3504             : 
    3505             :         // Heating Coil Types for the air sys simulation
    3506     2260655 :         break;
    3507     7148211 :     case COIL_HEATING_WATER:
    3508             :     case COIL_HEATING_DX_SINGLESPEED:
    3509             :     case COIL_HEATING_DX_MULTISPEED:
    3510             :     case COIL_HEATING_WATERTOAIRHEATPUMP_EQUATIONFIT:
    3511             :     case COIL_HEATING_WATERTOAIRHEATPUMP_PARAMETERESTIMATION:
    3512             :     case COIL_HEATING_WATERTOAIRHEATPUMP_VARIABLESPEEDEQUATIONFIT:
    3513             :     case COIL_HEATING_DX_VARIABLESPEED:
    3514             :     case COIL_HEATING_STEAM:
    3515             :     case COIL_HEATING_GAS:
    3516             :     case COIL_HEATING_GAS_MULTISTAGE:
    3517             :     case COIL_HEATING_DESUPERHEATER:
    3518             : 
    3519     7148211 :         if (CompLoadFlag) thisSysLoadRepVars.HCCompHTNG += std::abs(CompLoad);
    3520     7148211 :         if ((EnergyType == Constant::eResource::PlantLoopHeatingDemand) || (EnergyType == Constant::eResource::DistrictHeatingWater)) {
    3521     1736743 :             thisSysLoadRepVars.HCCompH2OHOT += CompEnergy;
    3522     5411468 :         } else if (EnergyType == Constant::eResource::DistrictHeatingSteam) {
    3523           0 :             thisSysLoadRepVars.HCCompSteam += CompEnergy;
    3524     5411468 :         } else if (EnergyType == Constant::eResource::Electricity) {
    3525      565378 :             thisSysLoadRepVars.HCCompElec += CompEnergy;
    3526     4846090 :         } else if (EnergyType == Constant::eResource::NaturalGas) {
    3527      603636 :             thisSysLoadRepVars.HCCompNaturalGas += CompEnergy;
    3528     4242454 :         } else if (EnergyType == Constant::eResource::Propane) {
    3529           0 :             thisSysLoadRepVars.HCCompPropane += CompEnergy;
    3530             :         }
    3531             : 
    3532     7148211 :         break;
    3533      718593 :     case COIL_HEATING_ELECTRIC:
    3534             :     case COIL_HEATING_ELECTRIC_MULTISTAGE:
    3535             : 
    3536      718593 :         if (CompLoadFlag) thisSysLoadRepVars.HCCompHTNG += std::abs(CompLoad);
    3537      718593 :         if (EnergyType == Constant::eResource::Electricity) {
    3538      239531 :             thisSysLoadRepVars.HCCompElecRes += CompEnergy;
    3539             :         }
    3540             : 
    3541      718593 :         break;
    3542        4536 :     case COIL_USERDEFINED:
    3543             : 
    3544        4536 :         if (CompLoadFlag) {
    3545        4536 :             if (CompLoad > 0.0) {
    3546        2640 :                 thisSysLoadRepVars.CCCompCLNG += std::abs(CompLoad);
    3547             :             } else {
    3548        1896 :                 thisSysLoadRepVars.HCCompHTNG += std::abs(CompLoad);
    3549             :             }
    3550             :         }
    3551        4536 :         if ((EnergyType == Constant::eResource::PlantLoopHeatingDemand) || (EnergyType == Constant::eResource::DistrictHeatingWater)) {
    3552           0 :             thisSysLoadRepVars.HCCompH2OHOT += CompEnergy;
    3553        4536 :         } else if ((EnergyType == Constant::eResource::PlantLoopCoolingDemand) || (EnergyType == Constant::eResource::DistrictCooling)) {
    3554           0 :             thisSysLoadRepVars.CCCompH2OCOLD += CompEnergy;
    3555        4536 :         } else if (EnergyType == Constant::eResource::DistrictHeatingSteam) {
    3556           0 :             thisSysLoadRepVars.HCCompSteam += CompEnergy;
    3557        4536 :         } else if (EnergyType == Constant::eResource::Electricity) {
    3558           0 :             if (CompLoad > 0.0) {
    3559           0 :                 thisSysLoadRepVars.CCCompElec += CompEnergy;
    3560             :             } else {
    3561           0 :                 thisSysLoadRepVars.HCCompElec += CompEnergy;
    3562             :             }
    3563        4536 :         } else if (EnergyType == Constant::eResource::NaturalGas) {
    3564           0 :             thisSysLoadRepVars.HCCompNaturalGas += CompEnergy;
    3565        4536 :         } else if (EnergyType == Constant::eResource::Propane) {
    3566           0 :             thisSysLoadRepVars.HCCompPropane += CompEnergy;
    3567             :         }
    3568             : 
    3569             :         // DX Systems
    3570        4536 :         break;
    3571      461232 :     case COIL_HEATING_VRF:
    3572             :     case COIL_HEATING_VRF_FTC:
    3573             :     case AIRLOOPHVAC_UNITARYSYSTEM:
    3574             :         // All energy transfers accounted for in subcomponent models
    3575      461232 :         break;
    3576        9785 :     case AIRLOOPHVAC_UNITARYHEATPUMP_AIRTOAIR:
    3577             :         // All energy transfers accounted for in subcomponent models
    3578        9785 :         break;
    3579       27572 :     case AIRLOOPHVAC_UNITARYHEATPUMP_WATERTOAIR:
    3580             :         // All energy transfers accounted for in subcomponent models
    3581       27572 :         break;
    3582      106057 :     case COILSYSTEM_COOLING_DX:
    3583             :         // All energy transfers accounted for in subcomponent models
    3584      106057 :         break;
    3585         576 :     case COILSYSTEM_HEATING_DX:
    3586             :         // All energy transfers accounted for in subcomponent models
    3587         576 :         break;
    3588         727 :     case AIRLOOPHVAC_UNITARY_FURNACE_HEATONLY:
    3589             :         // All energy transfers accounted for in subcomponent models
    3590         727 :         break;
    3591       25253 :     case AIRLOOPHVAC_UNITARY_FURNACE_HEATCOOL:
    3592             :         // All energy transfers accounted for in subcomponent models
    3593       25253 :         break;
    3594          73 :     case AIRLOOPHVAC_UNITARYHEATONLY:
    3595             :         // All energy transfers accounted for in subcomponent models
    3596          73 :         break;
    3597       37079 :     case AIRLOOPHVAC_UNITARYHEATCOOL:
    3598             :         // All energy transfers accounted for in subcomponent models
    3599       37079 :         break;
    3600         939 :     case AIRLOOPHVAC_UNITARYHEATCOOL_VAVCHANGEOVERBYPASS:
    3601             :         // All energy transfers accounted for in subcomponent models
    3602         939 :         break;
    3603       16887 :     case AIRLOOPHVAC_UNITARYHEATPUMP_AIRTOAIR_MULTISPEED:
    3604             :         // All energy transfers accounted for in subcomponent models
    3605       16887 :         break;
    3606         396 :     case ZONEHVAC_TERMINALUNIT_VRF:
    3607             :         // All energy transfers accounted for in subcomponent models
    3608         396 :         break;
    3609             :         // Humidifier Types for the air system simulation
    3610       43413 :     case HUMIDIFIER_STEAM_GAS:
    3611             :     case HUMIDIFIER_STEAM_ELECTRIC:
    3612       43413 :         if (CompLoadFlag) thisSysLoadRepVars.HumidHTNG += std::abs(CompLoad);
    3613       43413 :         if (EnergyType == Constant::eResource::Water) {
    3614       10802 :             thisSysLoadRepVars.DomesticH2O += std::abs(CompEnergy);
    3615       32611 :         } else if (EnergyType == Constant::eResource::Electricity) {
    3616       10802 :             thisSysLoadRepVars.HumidElec += CompEnergy;
    3617       21809 :         } else if (EnergyType == Constant::eResource::NaturalGas) {
    3618         205 :             thisSysLoadRepVars.HumidNaturalGas += CompEnergy;
    3619       21604 :         } else if (EnergyType == Constant::eResource::Propane) {
    3620           0 :             thisSysLoadRepVars.HumidPropane += CompEnergy;
    3621             :         }
    3622             : 
    3623             :         // Evap Cooler Types for the air system simulation
    3624       43413 :         break;
    3625       53936 :     case EVAPORATIVECOOLER_DIRECT_CELDEKPAD:
    3626             :     case EVAPORATIVECOOLER_INDIRECT_CELDEKPAD:
    3627             :     case EVAPORATIVECOOLER_INDIRECT_WETCOIL:
    3628             :     case EVAPORATIVECOOLER_DIRECT_RESEARCHSPECIAL:
    3629             :     case EVAPORATIVECOOLER_INDIRECT_RESEARCHSPECIAL:
    3630       53936 :         if (CompLoadFlag) thisSysLoadRepVars.EvapCLNG += std::abs(CompLoad);
    3631       53936 :         if (EnergyType == Constant::eResource::Water) {
    3632       13484 :             thisSysLoadRepVars.DomesticH2O += std::abs(CompEnergy);
    3633       40452 :         } else if (EnergyType == Constant::eResource::Electricity) {
    3634       13484 :             thisSysLoadRepVars.EvapElec += CompEnergy;
    3635             :         }
    3636             : 
    3637             :         // Desiccant Dehumidifier Types for the air system simulation
    3638       53936 :         break;
    3639        4244 :     case DEHUMIDIFIER_DESICCANT_NOFANS:
    3640             :     case DEHUMIDIFIER_DESICCANT_SYSTEM:
    3641        4244 :         if (CompLoadFlag) thisSysLoadRepVars.DesDehumidCLNG += std::abs(CompLoad);
    3642        4244 :         if (EnergyType == Constant::eResource::Electricity) {
    3643        1743 :             thisSysLoadRepVars.DesDehumidElec += CompEnergy;
    3644             :         }
    3645             : 
    3646             :         // Heat Exchanger Types
    3647        4244 :         break;
    3648       49520 :     case HEATEXCHANGER_AIRTOAIR_FLATPLATE:
    3649             :     case HEATEXCHANGER_AIRTOAIR_SENSIBLEANDLATENT:
    3650             :     case HEATEXCHANGER_DESICCANT_BALANCEDFLOW:
    3651       49520 :         if (CompLoadFlag) {
    3652       12380 :             if (CompLoad > 0.0) {
    3653        4219 :                 thisSysLoadRepVars.HeatExCLNG += std::abs(CompLoad);
    3654             :             } else {
    3655        8161 :                 thisSysLoadRepVars.HeatExHTNG += std::abs(CompLoad);
    3656             :             }
    3657             :         }
    3658             : 
    3659             :         // Air Terminal Types
    3660       49520 :         break;
    3661     4778450 :     case AIRTERMINAL_DUALDUCT_CONSTANTVOLUME_COOL:
    3662             :     case AIRTERMINAL_DUALDUCT_CONSTANTVOLUME_HEAT:
    3663             :     case AIRTERMINAL_DUALDUCT_VAV_COOL:
    3664             :     case AIRTERMINAL_DUALDUCT_VAV_HEAT:
    3665             :     case AIRTERMINAL_DUALDUCT_VAV_OUTDOORAIR_OUTDOORAIR:
    3666             :     case AIRTERMINAL_DUALDUCT_VAV_OUTDOORAIR_RECIRCULATEDAIR:
    3667             :     case AIRTERMINAL_SINGLEDUCT_CONSTANTVOLUME_FOURPIPEINDUCTION:
    3668             :     case AIRTERMINAL_SINGLEDUCT_CONSTANTVOLUME_REHEAT:
    3669             :     case AIRTERMINAL_SINGLEDUCT_CONSTANTVOLUME_NOREHEAT:
    3670             :     case AIRTERMINAL_SINGLEDUCT_PARALLELPIU_REHEAT:
    3671             :     case AIRTERMINAL_SINGLEDUCT_SERIESPIU_REHEAT:
    3672             :     case AIRTERMINAL_SINGLEDUCT_VAV_HEATANDCOOL_NOREHEAT:
    3673             :     case AIRTERMINAL_SINGLEDUCT_VAV_HEATANDCOOL_REHEAT:
    3674             :     case AIRTERMINAL_SINGLEDUCT_VAV_NOREHEAT:
    3675             :     case AIRTERMINAL_SINGLEDUCT_VAV_REHEAT:
    3676             :     case AIRTERMINAL_SINGLEDUCT_VAV_REHEAT_VARIABLESPEEDFAN:
    3677             :     case AIRTERMINAL_SINGLEDUCT_CONSTANTVOLUME_COOLEDBEAM:
    3678             :     case AIRTERMINAL_SINGLEDUCT_CONSTANTVOLUME_FOURPIPEBEAM:
    3679             :     case ZONEHVAC_AIRDISTRIBUTIONUNIT:
    3680             :         // All energy transfers accounted for in component models
    3681             : 
    3682             :         // Duct Types
    3683     4778450 :         break;
    3684         881 :     case DUCT:
    3685             :         // duct losses should be accounted for here ???
    3686             :         // requires addition of a new variable to sum duct losses
    3687             :         // Example:
    3688             :         //      IF(CompLoad > 0.0d0)THEN
    3689             :         //        SysDuctHTNG =  SysDuctHTNG + ABS(CompLoad)
    3690             :         //      ELSE
    3691             :         //        SysDuctCLNG =  SysDuctCLNG + ABS(CompLoad)
    3692             :         //      ENDIF
    3693             : 
    3694             :         // Solar Collector Types
    3695         881 :         break;
    3696       10556 :     case SOLARCOLLECTOR_FLATPLATE_PHOTOVOLTAICTHERMAL:
    3697             :     case SOLARCOLLECTOR_UNGLAZEDTRANSPIRED:
    3698       10556 :         if (CompLoadFlag) {
    3699        5278 :             if (CompLoad > 0.0) {
    3700         886 :                 thisSysLoadRepVars.SolarCollectCooling += std::abs(CompLoad);
    3701             :             } else {
    3702        4392 :                 thisSysLoadRepVars.SolarCollectHeating += std::abs(CompLoad);
    3703             :             }
    3704             :         }
    3705             : 
    3706       10556 :         break;
    3707        7560 :     case AIRTERMINAL_SINGLEDUCT_USERDEFINED:
    3708             :         // User component model energy use should be accounted for here
    3709        7560 :         if (CompLoadFlag) {
    3710        7560 :             if (CompLoad > 0.0) {
    3711           0 :                 thisSysLoadRepVars.UserDefinedTerminalCooling += std::abs(CompLoad);
    3712             :             } else {
    3713        7560 :                 thisSysLoadRepVars.UserDefinedTerminalHeating += std::abs(CompLoad);
    3714             :             }
    3715             :         }
    3716        7560 :         if ((EnergyType == Constant::eResource::PlantLoopHeatingDemand) || (EnergyType == Constant::eResource::DistrictHeatingWater)) {
    3717           0 :             thisSysLoadRepVars.HCCompH2OHOT += CompEnergy;
    3718        7560 :         } else if ((EnergyType == Constant::eResource::PlantLoopCoolingDemand) || (EnergyType == Constant::eResource::DistrictCooling)) {
    3719           0 :             thisSysLoadRepVars.CCCompH2OCOLD += CompEnergy;
    3720        7560 :         } else if (EnergyType == Constant::eResource::DistrictHeatingSteam) {
    3721           0 :             thisSysLoadRepVars.HCCompSteam += CompEnergy;
    3722        7560 :         } else if (EnergyType == Constant::eResource::Electricity) {
    3723           0 :             if (CompLoad > 0.0) {
    3724           0 :                 thisSysLoadRepVars.CCCompElec += CompEnergy;
    3725             :             } else {
    3726           0 :                 thisSysLoadRepVars.HCCompElec += CompEnergy;
    3727             :             }
    3728        7560 :         } else if (EnergyType == Constant::eResource::NaturalGas) {
    3729           0 :             thisSysLoadRepVars.HCCompNaturalGas += CompEnergy;
    3730        7560 :         } else if (EnergyType == Constant::eResource::Propane) {
    3731           0 :             thisSysLoadRepVars.HCCompPropane += CompEnergy;
    3732             :         }
    3733             :         // Recurring warning for unaccounted equipment types
    3734             :         // (should never happen, when this does happen enter appropriate equipment CASE statement above)
    3735        7560 :         break;
    3736         612 :     case COIL_INTEGRATED_DX_VARIABLESPEED:
    3737             :         // All energy transfers accounted for in component models
    3738         612 :         break;
    3739           0 :     default:
    3740           0 :         int found = 0;
    3741           0 :         if (state.dataSysRpts->NumCompTypes > 0) {
    3742           0 :             found = Util::FindItemInList(CompType, state.dataSysRpts->CompTypeErrors, &CompTypeError::CompType, state.dataSysRpts->NumCompTypes);
    3743             :         }
    3744           0 :         if (found == 0) {
    3745           0 :             state.dataSysRpts->CompTypeErrors(++state.dataSysRpts->NumCompTypes).CompType = CompType;
    3746           0 :             found = state.dataSysRpts->NumCompTypes;
    3747             :         }
    3748           0 :         ShowRecurringSevereErrorAtEnd(state,
    3749           0 :                                       "CalcSystemEnergyUse: Component Type=" + CompType + " not logged as one of allowable Component Types.",
    3750           0 :                                       state.dataSysRpts->CompTypeErrors(found).CompErrIndex);
    3751           0 :         break;
    3752             :     } // switch
    3753    18069050 : }
    3754             : 
    3755      615229 : void ReportVentilationLoads(EnergyPlusData &state)
    3756             : {
    3757             :     // SUBROUTINE INFORMATION:
    3758             :     //       AUTHOR         Dan Fisher (with minor assistance from RKS)
    3759             :     //       DATE WRITTEN   July 2004
    3760             :     //       MODIFIED       Dec. 2006, BG. reengineered to add zone forced air units to vent rates and loads
    3761             : 
    3762             :     // PURPOSE OF THIS SUBROUTINE:
    3763             :     // calculate and report zone ventilation loads
    3764             : 
    3765             :     // METHODOLOGY EMPLOYED:
    3766             :     // calculate energy contribution of outside air through mixing box and pro-rate to
    3767             :     // zones according to zone mass flow rates.
    3768             : 
    3769      615229 :     Real64 constexpr SmallLoad(0.1); // (W)
    3770             : 
    3771      615229 :     auto &Node = state.dataLoopNodes->Node;
    3772      615229 :     Real64 TimeStepSys = state.dataHVACGlobal->TimeStepSys;
    3773      615229 :     Real64 TimeStepSysSec = state.dataHVACGlobal->TimeStepSysSec;
    3774             : 
    3775      615229 :     if (!state.dataSysRpts->VentReportStructureCreated) return;
    3776      615229 :     if (!state.dataSysRpts->VentLoadsReportEnabled) return;
    3777             :     // following inits are array assignments across all controlled zones.
    3778     4001607 :     for (int zoneNum = 1; zoneNum <= state.dataGlobal->NumOfZones; ++zoneNum) {
    3779     3386378 :         auto &thisZoneVentRepVars = state.dataSysRpts->ZoneVentRepVars(zoneNum);
    3780     3386378 :         if (!state.dataZoneEquip->ZoneEquipConfig(zoneNum).IsControlled) continue;
    3781     2913258 :         thisZoneVentRepVars.OAMassFlow = 0.0;
    3782     2913258 :         thisZoneVentRepVars.OAMass = 0.0;
    3783     2913258 :         thisZoneVentRepVars.OAVolFlowStdRho = 0.0;
    3784     2913258 :         thisZoneVentRepVars.OAVolStdRho = 0.0;
    3785     2913258 :         thisZoneVentRepVars.OAVolFlowCrntRho = 0.0;
    3786     2913258 :         thisZoneVentRepVars.OAVolCrntRho = 0.0;
    3787     2913258 :         thisZoneVentRepVars.MechACH = 0.0;
    3788     2913258 :         thisZoneVentRepVars.TargetVentilationFlowVoz = 0.0;
    3789     2913258 :         thisZoneVentRepVars.TimeBelowVozDyn = 0.0;
    3790     2913258 :         thisZoneVentRepVars.TimeAtVozDyn = 0.0;
    3791     2913258 :         thisZoneVentRepVars.TimeAboveVozDyn = 0.0;
    3792     2913258 :         thisZoneVentRepVars.TimeVentUnocc = 0.0;
    3793     2913258 :         thisZoneVentRepVars.CoolingLoadMetByVent = 0.0;
    3794     2913258 :         thisZoneVentRepVars.CoolingLoadAddedByVent = 0.0;
    3795     2913258 :         thisZoneVentRepVars.OvercoolingByVent = 0.0;
    3796     2913258 :         thisZoneVentRepVars.HeatingLoadMetByVent = 0.0;
    3797     2913258 :         thisZoneVentRepVars.HeatingLoadAddedByVent = 0.0;
    3798     2913258 :         thisZoneVentRepVars.OverheatingByVent = 0.0;
    3799     2913258 :         thisZoneVentRepVars.NoLoadHeatingByVent = 0.0;
    3800     2913258 :         thisZoneVentRepVars.NoLoadCoolingByVent = 0.0;
    3801             :     }
    3802             : 
    3803      615229 :     state.dataSysRpts->AnyZoneTimeBelowVozDyn = 0.0;
    3804      615229 :     state.dataSysRpts->AllZonesTimeAtVozDyn = 0.0;
    3805      615229 :     state.dataSysRpts->AnyZoneTimeAboveVozDyn = 0.0;
    3806      615229 :     state.dataSysRpts->AnyZoneTimeVentUnocc = 0.0;
    3807      615229 :     state.dataSysRpts->AnyZoneTimeBelowVozDynOcc = 0.0;
    3808      615229 :     state.dataSysRpts->AllZonesTimeAtVozDynOcc = 0.0;
    3809      615229 :     state.dataSysRpts->AnyZoneTimeAboveVozDynOcc = 0.0;
    3810             : 
    3811     1462657 :     for (int sysNum = 1; sysNum <= state.dataHVACGlobal->NumPrimaryAirSys; ++sysNum) {
    3812      847428 :         auto &thisSysVentRepVars = state.dataSysRpts->SysVentRepVars(sysNum);
    3813      847428 :         thisSysVentRepVars.MechVentFlow = 0.0;
    3814      847428 :         thisSysVentRepVars.NatVentFlow = 0.0;
    3815      847428 :         thisSysVentRepVars.TargetVentilationFlowVoz = 0.0;
    3816      847428 :         thisSysVentRepVars.TimeBelowVozDyn = 0.0;
    3817      847428 :         thisSysVentRepVars.TimeAtVozDyn = 0.0;
    3818      847428 :         thisSysVentRepVars.TimeAboveVozDyn = 0.0;
    3819      847428 :         thisSysVentRepVars.TimeVentUnocc = 0.0;
    3820      847428 :         thisSysVentRepVars.AnyZoneOccupied = false;
    3821             :     }
    3822             : 
    3823     4001607 :     for (int CtrlZoneNum = 1; CtrlZoneNum <= state.dataGlobal->NumOfZones; ++CtrlZoneNum) {
    3824     3386378 :         auto &thisZoneEquipConfig = state.dataZoneEquip->ZoneEquipConfig(CtrlZoneNum);
    3825     3386378 :         if (!thisZoneEquipConfig.IsControlled) continue;
    3826             : 
    3827     2913258 :         Real64 ZAirSysZoneVentLoad = 0.0; // ventilation load attributed to a particular zone from all primary air systems serving the zone [J]
    3828     2913258 :         Real64 ZAirSysOutAirFlow = 0.0;   // outside air flow rate for zone from all primary air systems serving thezone [kg/s]
    3829     2913258 :         Real64 ZFAUFlowRate = 0.0;        // Zone forced Air unit air mass flow rate [kg/s]
    3830     2913258 :         Real64 ZFAUZoneVentLoad = 0.0;    // ventilation load attributed to a particular zone from zone forced air units [J]
    3831     2913258 :         Real64 ZFAUOutAirFlow = 0.0;      // outside air flow rate for zone from zone forced air units. [kg/s]
    3832     2913258 :         Real64 OutAirFlow = 0.0;          // Total outside air mass flow from zone equipment and air loop equipment [kg/s]
    3833     2913258 :         Real64 ZoneFlowFrac = 0.0;        // fraction of mixed air flowing to a zone
    3834     2913258 :         Real64 ZFAUEnthReturnAir = 0.0;   // Zone forced Air unit enthalpy of the return air [kJ/kgK]
    3835     2913258 :         Real64 ZFAUTempMixedAir = 0.0;    // Zone forced Air unit dry-bulb temperature of the mixed air [C]
    3836     2913258 :         Real64 ZFAUHumRatMixedAir = 0.0;  // Zone forced Air unit humidity ratio of the mixed air [kg/kg]
    3837     2913258 :         Real64 ZFAUEnthMixedAir = 0.0;    // Zone forced Air unit enthalpy of the mixed air [kJ/kgK]
    3838     2913258 :         Real64 ZFAUEnthOutdoorAir = 0.0;  // Zone forced Air unit enthalpy of the outdoor air [kJ/kgK]
    3839             : 
    3840             :         // retrieve the zone load for each zone
    3841     2913258 :         Real64 ZoneLoad = state.dataZoneEnergyDemand->ZoneSysEnergyDemand(CtrlZoneNum).TotalOutputRequired;
    3842     2913258 :         Real64 ZoneVolume = state.dataHeatBal->Zone(CtrlZoneNum).Volume * state.dataHeatBal->Zone(CtrlZoneNum).Multiplier *
    3843     2913258 :                             state.dataHeatBal->Zone(CtrlZoneNum).ListMultiplier; // CR 7170
    3844             : 
    3845     2913258 :         bool constexpr UseOccSchFlag = true;
    3846     2913258 :         bool constexpr UseMinOASchFlag = true;
    3847             : 
    3848     2913258 :         auto &thisZonePredefRep = state.dataHeatBal->ZonePreDefRep(CtrlZoneNum);
    3849     2913258 :         auto &thisZoneVentRepVars = state.dataSysRpts->ZoneVentRepVars(CtrlZoneNum);
    3850     2913258 :         thisZoneVentRepVars.TargetVentilationFlowVoz = DataSizing::calcDesignSpecificationOutdoorAir(
    3851             :             state, thisZoneEquipConfig.ZoneDesignSpecOAIndex, CtrlZoneNum, UseOccSchFlag, UseMinOASchFlag);
    3852     2913258 :         if (thisZoneEquipConfig.ZoneAirDistributionIndex > 0) {
    3853      420081 :             thisZoneVentRepVars.TargetVentilationFlowVoz =
    3854      840162 :                 thisZoneVentRepVars.TargetVentilationFlowVoz /
    3855      420081 :                 state.dataSize->ZoneAirDistribution(thisZoneEquipConfig.ZoneAirDistributionIndex).calculateEz(state, CtrlZoneNum);
    3856             :         }
    3857             : 
    3858             :         // if system operating in deadband reset zone load
    3859     2913258 :         if (state.dataZoneEnergyDemand->DeadBandOrSetback(CtrlZoneNum)) ZoneLoad = 0.0;
    3860             : 
    3861             :         // first deal with any (and all) Zone Forced Air Units that might have outside air.
    3862     2913258 :         auto &thisZoneEquipList = state.dataZoneEquip->ZoneEquipList(thisZoneEquipConfig.EquipListIndex);
    3863     6023115 :         for (int thisZoneEquipNum = 1; thisZoneEquipNum <= thisZoneEquipList.NumOfEquipTypes; ++thisZoneEquipNum) {
    3864     3109857 :             auto &thisEquipIndex = thisZoneEquipList.EquipIndex(thisZoneEquipNum);
    3865             : 
    3866     3109857 :             switch (thisZoneEquipList.EquipType(thisZoneEquipNum)) {
    3867             :                 // case statement to cover all possible zone forced air units that could have outside air
    3868             : 
    3869       16914 :             case DataZoneEquipment::ZoneEquipType::WindowAirConditioner: { // Window Air Conditioner
    3870       16914 :                 int OutAirNode = WindowAC::GetWindowACOutAirNode(state, thisEquipIndex);
    3871       16914 :                 if (OutAirNode > 0) ZFAUOutAirFlow += Node(OutAirNode).MassFlowRate;
    3872             : 
    3873       16914 :                 int ZoneInletAirNode = WindowAC::GetWindowACZoneInletAirNode(state, thisEquipIndex);
    3874       16914 :                 if (ZoneInletAirNode > 0) ZFAUFlowRate = max(Node(ZoneInletAirNode).MassFlowRate, 0.0);
    3875       16914 :                 int MixedAirNode = WindowAC::GetWindowACMixedAirNode(state, thisEquipIndex);
    3876       16914 :                 int ReturnAirNode = WindowAC::GetWindowACReturnAirNode(state, thisEquipIndex);
    3877       16914 :                 if ((MixedAirNode > 0) && (ReturnAirNode > 0)) {
    3878       16914 :                     ZFAUEnthMixedAir = Psychrometrics::PsyHFnTdbW(Node(MixedAirNode).Temp, Node(MixedAirNode).HumRat);
    3879       16914 :                     ZFAUEnthReturnAir = Psychrometrics::PsyHFnTdbW(Node(ReturnAirNode).Temp, Node(ReturnAirNode).HumRat);
    3880             :                     // Calculate the zone ventilation load for this supply air path (i.e. zone inlet)
    3881       16914 :                     ZFAUZoneVentLoad += (ZFAUFlowRate) * (ZFAUEnthMixedAir - ZFAUEnthReturnAir) * TimeStepSysSec; //*KJperJ
    3882             :                 } else {
    3883           0 :                     ZFAUZoneVentLoad += 0.0;
    3884             :                 }
    3885       16914 :             } break;
    3886             : 
    3887       15145 :             case DataZoneEquipment::ZoneEquipType::VariableRefrigerantFlowTerminal: {
    3888       15145 :                 int OutAirNode = HVACVariableRefrigerantFlow::GetVRFTUOutAirNode(state, thisEquipIndex);
    3889       15145 :                 if (OutAirNode > 0) ZFAUOutAirFlow += Node(OutAirNode).MassFlowRate;
    3890       15145 :                 int ZoneInletAirNode = HVACVariableRefrigerantFlow::GetVRFTUZoneInletAirNode(state, thisEquipIndex);
    3891       15145 :                 if (ZoneInletAirNode > 0) ZFAUFlowRate = max(Node(ZoneInletAirNode).MassFlowRate, 0.0);
    3892       15145 :                 int MixedAirNode = HVACVariableRefrigerantFlow::GetVRFTUMixedAirNode(state, thisEquipIndex);
    3893       15145 :                 int ReturnAirNode = HVACVariableRefrigerantFlow::GetVRFTUReturnAirNode(state, thisEquipIndex);
    3894       15145 :                 if ((MixedAirNode > 0) && (ReturnAirNode > 0)) {
    3895       13125 :                     ZFAUEnthMixedAir = Psychrometrics::PsyHFnTdbW(Node(MixedAirNode).Temp, Node(MixedAirNode).HumRat);
    3896       13125 :                     ZFAUEnthReturnAir = Psychrometrics::PsyHFnTdbW(Node(ReturnAirNode).Temp, Node(ReturnAirNode).HumRat);
    3897             :                     // Calculate the zone ventilation load for this supply air path (i.e. zone inlet)
    3898       13125 :                     ZFAUZoneVentLoad += (ZFAUFlowRate) * (ZFAUEnthMixedAir - ZFAUEnthReturnAir) * TimeStepSysSec; //*KJperJ
    3899             :                 } else {
    3900        2020 :                     ZFAUZoneVentLoad += 0.0;
    3901             :                 }
    3902       15145 :             } break;
    3903             : 
    3904       70540 :             case DataZoneEquipment::ZoneEquipType::PackagedTerminalHeatPump:
    3905             :             case DataZoneEquipment::ZoneEquipType::PackagedTerminalAirConditioner:
    3906             :             case DataZoneEquipment::ZoneEquipType::PackagedTerminalHeatPumpWaterToAir: {
    3907             :                 // loop index accesses correct pointer to equipment on this equipment list, DataZoneEquipment::GetZoneEquipmentData
    3908             :                 // thisEquipIndex (EquipIndex) is used to access specific equipment for a single class of equipment (e.g., PTAC 1, 2 and 3)
    3909       70540 :                 int OutAirNode = thisZoneEquipList.compPointer[thisZoneEquipNum]->getMixerOANode();
    3910       70540 :                 if (OutAirNode > 0) ZFAUOutAirFlow += Node(OutAirNode).MassFlowRate;
    3911       70540 :                 int ZoneInletAirNode = thisZoneEquipList.compPointer[thisZoneEquipNum]->getAirOutletNode();
    3912       70540 :                 if (ZoneInletAirNode > 0) ZFAUFlowRate = max(Node(ZoneInletAirNode).MassFlowRate, 0.0);
    3913       70540 :                 int MixedAirNode = thisZoneEquipList.compPointer[thisZoneEquipNum]->getMixerMixNode();
    3914       70540 :                 int ReturnAirNode = thisZoneEquipList.compPointer[thisZoneEquipNum]->getMixerRetNode();
    3915       70540 :                 if ((MixedAirNode > 0) && (ReturnAirNode > 0)) {
    3916       63935 :                     ZFAUEnthMixedAir = Psychrometrics::PsyHFnTdbW(Node(MixedAirNode).Temp, Node(MixedAirNode).HumRat);
    3917       63935 :                     ZFAUEnthReturnAir = Psychrometrics::PsyHFnTdbW(Node(ReturnAirNode).Temp, Node(ReturnAirNode).HumRat);
    3918             :                     // Calculate the zone ventilation load for this supply air path (i.e. zone inlet)
    3919       63935 :                     ZFAUZoneVentLoad += (ZFAUFlowRate) * (ZFAUEnthMixedAir - ZFAUEnthReturnAir) * TimeStepSysSec; //*KJperJ
    3920             :                 }
    3921       70540 :             } break;
    3922             : 
    3923       25404 :             case DataZoneEquipment::ZoneEquipType::FourPipeFanCoil: {
    3924       25404 :                 int OutAirNode = FanCoilUnits::GetFanCoilOutAirNode(state, thisEquipIndex);
    3925       25404 :                 if (OutAirNode > 0) ZFAUOutAirFlow += Node(OutAirNode).MassFlowRate;
    3926             : 
    3927       25404 :                 int ZoneInletAirNode = FanCoilUnits::GetFanCoilZoneInletAirNode(state, thisEquipIndex);
    3928       25404 :                 if (ZoneInletAirNode > 0) ZFAUFlowRate = max(Node(ZoneInletAirNode).MassFlowRate, 0.0);
    3929       25404 :                 int MixedAirNode = FanCoilUnits::GetFanCoilMixedAirNode(state, thisEquipIndex);
    3930       25404 :                 int ReturnAirNode = FanCoilUnits::GetFanCoilReturnAirNode(state, thisEquipIndex);
    3931       25404 :                 if ((MixedAirNode > 0) && (ReturnAirNode > 0)) {
    3932       23174 :                     ZFAUEnthMixedAir = Psychrometrics::PsyHFnTdbW(Node(MixedAirNode).Temp, Node(MixedAirNode).HumRat);
    3933       23174 :                     ZFAUEnthReturnAir = Psychrometrics::PsyHFnTdbW(Node(ReturnAirNode).Temp, Node(ReturnAirNode).HumRat);
    3934             :                     // Calculate the zone ventilation load for this supply air path (i.e. zone inlet)
    3935       23174 :                     ZFAUZoneVentLoad += (ZFAUFlowRate) * (ZFAUEnthMixedAir - ZFAUEnthReturnAir) * TimeStepSysSec; //*KJperJ
    3936             :                 } else {
    3937        2230 :                     ZFAUZoneVentLoad += 0.0;
    3938             :                 }
    3939       25404 :             } break;
    3940             : 
    3941        8595 :             case DataZoneEquipment::ZoneEquipType::UnitVentilator: {
    3942        8595 :                 int OutAirNode = UnitVentilator::GetUnitVentilatorOutAirNode(state, thisEquipIndex);
    3943        8595 :                 if (OutAirNode > 0) ZFAUOutAirFlow += Node(OutAirNode).MassFlowRate;
    3944             : 
    3945        8595 :                 int ZoneInletAirNode = UnitVentilator::GetUnitVentilatorZoneInletAirNode(state, thisEquipIndex);
    3946        8595 :                 if (ZoneInletAirNode > 0) ZFAUFlowRate = max(Node(ZoneInletAirNode).MassFlowRate, 0.0);
    3947        8595 :                 int MixedAirNode = UnitVentilator::GetUnitVentilatorMixedAirNode(state, thisEquipIndex);
    3948        8595 :                 int ReturnAirNode = UnitVentilator::GetUnitVentilatorReturnAirNode(state, thisEquipIndex);
    3949        8595 :                 if ((MixedAirNode > 0) && (ReturnAirNode > 0)) {
    3950        8595 :                     ZFAUEnthMixedAir = Psychrometrics::PsyHFnTdbW(Node(MixedAirNode).Temp, Node(MixedAirNode).HumRat);
    3951        8595 :                     ZFAUEnthReturnAir = Psychrometrics::PsyHFnTdbW(Node(ReturnAirNode).Temp, Node(ReturnAirNode).HumRat);
    3952             :                     // Calculate the zone ventilation load for this supply air path (i.e. zone inlet)
    3953        8595 :                     ZFAUZoneVentLoad += (ZFAUFlowRate) * (ZFAUEnthMixedAir - ZFAUEnthReturnAir) * TimeStepSysSec; //*KJperJ
    3954             :                 } else {
    3955           0 :                     ZFAUZoneVentLoad += 0.0;
    3956             :                 }
    3957        8595 :             } break;
    3958             : 
    3959      457856 :             case DataZoneEquipment::ZoneEquipType::PurchasedAir: {
    3960      457856 :                 ZFAUOutAirFlow += PurchasedAirManager::GetPurchasedAirOutAirMassFlow(state, thisEquipIndex);
    3961      457856 :                 int ZoneInletAirNode = PurchasedAirManager::GetPurchasedAirZoneInletAirNode(state, thisEquipIndex);
    3962      457856 :                 if (ZoneInletAirNode > 0) ZFAUFlowRate = max(Node(ZoneInletAirNode).MassFlowRate, 0.0);
    3963      457856 :                 ZFAUTempMixedAir = PurchasedAirManager::GetPurchasedAirMixedAirTemp(state, thisEquipIndex);
    3964      457856 :                 ZFAUHumRatMixedAir = PurchasedAirManager::GetPurchasedAirMixedAirHumRat(state, thisEquipIndex);
    3965      457856 :                 int ReturnAirNode = PurchasedAirManager::GetPurchasedAirReturnAirNode(state, thisEquipIndex);
    3966      457856 :                 if ((ZFAUFlowRate > 0) && (ReturnAirNode > 0)) {
    3967      241277 :                     ZFAUEnthMixedAir = Psychrometrics::PsyHFnTdbW(ZFAUTempMixedAir, ZFAUHumRatMixedAir);
    3968      241277 :                     ZFAUEnthReturnAir = Psychrometrics::PsyHFnTdbW(Node(ReturnAirNode).Temp, Node(ReturnAirNode).HumRat);
    3969             :                     // Calculate the zone ventilation load for this supply air path (i.e. zone inlet)
    3970      241277 :                     ZFAUZoneVentLoad += (ZFAUFlowRate) * (ZFAUEnthMixedAir - ZFAUEnthReturnAir) * TimeStepSysSec; //*KJperJ
    3971             :                 } else {
    3972      216579 :                     ZFAUZoneVentLoad += 0.0;
    3973             :                 }
    3974      457856 :             } break;
    3975             : 
    3976       21418 :             case DataZoneEquipment::ZoneEquipType::EnergyRecoveryVentilator: {
    3977       21418 :                 int OutAirNode = HVACStandAloneERV::GetStandAloneERVOutAirNode(state, thisEquipIndex);
    3978       21418 :                 if (OutAirNode > 0) ZFAUOutAirFlow += Node(OutAirNode).MassFlowRate;
    3979             : 
    3980       21418 :                 int ZoneInletAirNode = HVACStandAloneERV::GetStandAloneERVZoneInletAirNode(state, thisEquipIndex);
    3981       21418 :                 if (ZoneInletAirNode > 0) ZFAUFlowRate = max(Node(ZoneInletAirNode).MassFlowRate, 0.0);
    3982       21418 :                 int MixedAirNode = ZoneInletAirNode;
    3983       21418 :                 int ReturnAirNode = HVACStandAloneERV::GetStandAloneERVReturnAirNode(state, thisEquipIndex);
    3984       21418 :                 if ((MixedAirNode > 0) && (ReturnAirNode > 0)) {
    3985       21418 :                     ZFAUEnthMixedAir = Psychrometrics::PsyHFnTdbW(Node(MixedAirNode).Temp, Node(MixedAirNode).HumRat);
    3986       21418 :                     ZFAUEnthReturnAir = Psychrometrics::PsyHFnTdbW(Node(ReturnAirNode).Temp, Node(ReturnAirNode).HumRat);
    3987             :                     // Calculate the zone ventilation load for this supply air path (i.e. zone inlet)
    3988       21418 :                     ZFAUZoneVentLoad += (ZFAUFlowRate) * (ZFAUEnthMixedAir - ZFAUEnthReturnAir) * TimeStepSysSec; //*KJperJ
    3989             :                 } else {
    3990           0 :                     ZFAUZoneVentLoad += 0.0;
    3991             :                 }
    3992       21418 :             } break;
    3993             : 
    3994        9780 :             case DataZoneEquipment::ZoneEquipType::UnitarySystem: {
    3995             :                 // add accounting for OA when unitary system is used as zone equipment
    3996        9780 :             } break;
    3997             : 
    3998        3474 :             case DataZoneEquipment::ZoneEquipType::OutdoorAirUnit: {
    3999        3474 :                 int OutAirNode = OutdoorAirUnit::GetOutdoorAirUnitOutAirNode(state, thisEquipIndex);
    4000        3474 :                 if (OutAirNode > 0) ZFAUOutAirFlow += Node(OutAirNode).MassFlowRate;
    4001             : 
    4002        3474 :                 int ZoneInletAirNode = OutdoorAirUnit::GetOutdoorAirUnitZoneInletNode(state, thisEquipIndex);
    4003        3474 :                 if (ZoneInletAirNode > 0) ZFAUFlowRate = max(Node(ZoneInletAirNode).MassFlowRate, 0.0);
    4004        3474 :                 int ReturnAirNode = OutdoorAirUnit::GetOutdoorAirUnitReturnAirNode(state, thisEquipIndex);
    4005        3474 :                 if ((OutAirNode > 0) && (ReturnAirNode > 0)) {
    4006        3474 :                     ZFAUEnthReturnAir = Psychrometrics::PsyHFnTdbW(Node(ReturnAirNode).Temp, Node(ReturnAirNode).HumRat);
    4007        3474 :                     ZFAUEnthOutdoorAir = Psychrometrics::PsyHFnTdbW(Node(OutAirNode).Temp, Node(OutAirNode).HumRat);
    4008             :                     // Calculate the zone ventilation load for this supply air path (i.e. zone inlet)
    4009        3474 :                     ZFAUZoneVentLoad += (ZFAUFlowRate) * (ZFAUEnthOutdoorAir - ZFAUEnthReturnAir) * TimeStepSysSec; //*KJperJ
    4010             :                 } else {
    4011           0 :                     ZFAUZoneVentLoad += 0.0;
    4012             :                 }
    4013        3474 :             } break;
    4014             : 
    4015         771 :             case DataZoneEquipment::ZoneEquipType::HybridEvaporativeCooler: {
    4016         771 :                 int OutAirNode = HybridUnitaryAirConditioners::GetHybridUnitaryACOutAirNode(state, thisEquipIndex);
    4017         771 :                 if (OutAirNode > 0) ZFAUOutAirFlow += Node(OutAirNode).MassFlowRate;
    4018             : 
    4019         771 :                 int ZoneInletAirNode = HybridUnitaryAirConditioners::GetHybridUnitaryACZoneInletNode(state, thisEquipIndex);
    4020         771 :                 if (ZoneInletAirNode > 0) ZFAUFlowRate = max(Node(ZoneInletAirNode).MassFlowRate, 0.0);
    4021             : 
    4022         771 :                 int ReturnAirNode = HybridUnitaryAirConditioners::GetHybridUnitaryACReturnAirNode(state, thisEquipIndex);
    4023         771 :                 if ((OutAirNode > 0) && (ReturnAirNode > 0)) {
    4024         771 :                     ZFAUEnthReturnAir = Psychrometrics::PsyHFnTdbW(Node(ReturnAirNode).Temp, Node(ReturnAirNode).HumRat);
    4025         771 :                     ZFAUEnthOutdoorAir = Psychrometrics::PsyHFnTdbW(Node(OutAirNode).Temp, Node(OutAirNode).HumRat);
    4026             :                     // Calculate the zone ventilation load for this supply air path (i.e. zone inlet)
    4027             : 
    4028         771 :                     ZFAUZoneVentLoad += (ZFAUFlowRate) * (ZFAUEnthOutdoorAir - ZFAUEnthReturnAir) * TimeStepSysSec; //*KJperJ
    4029             :                 } else {
    4030           0 :                     ZFAUZoneVentLoad += 0.0;
    4031             :                 }
    4032         771 :             } break;
    4033             : 
    4034     2479960 :             case DataZoneEquipment::ZoneEquipType::UnitHeater:
    4035             :             case DataZoneEquipment::ZoneEquipType::VentilatedSlab:
    4036             :                 //    ZoneHVAC:EvaporativeCoolerUnit ?????
    4037             :             case DataZoneEquipment::ZoneEquipType::EvaporativeCooler:
    4038             :             case DataZoneEquipment::ZoneEquipType::AirDistributionUnit:
    4039             :             case DataZoneEquipment::ZoneEquipType::BaseboardConvectiveWater:
    4040             :             case DataZoneEquipment::ZoneEquipType::BaseboardConvectiveElectric:
    4041             :             case DataZoneEquipment::ZoneEquipType::HighTemperatureRadiant:
    4042             :                 //    not sure how HeatExchanger:* could be used as zone equipment ?????
    4043             :             case DataZoneEquipment::ZoneEquipType::LowTemperatureRadiant:
    4044             :             case DataZoneEquipment::ZoneEquipType::ExhaustFan:
    4045             :             case DataZoneEquipment::ZoneEquipType::HeatExchanger:
    4046             :                 // HPWaterHeater can be used as zone equipment
    4047             :             case DataZoneEquipment::ZoneEquipType::HeatPumpWaterHeater:
    4048             :             case DataZoneEquipment::ZoneEquipType::BaseboardWater:
    4049             :             case DataZoneEquipment::ZoneEquipType::DehumidifierDX:
    4050             :             case DataZoneEquipment::ZoneEquipType::BaseboardSteam:
    4051             :             case DataZoneEquipment::ZoneEquipType::BaseboardElectric:
    4052             :             case DataZoneEquipment::ZoneEquipType::RefrigerationChillerSet:
    4053             :             case DataZoneEquipment::ZoneEquipType::UserDefinedHVACForcedAir:
    4054             :             case DataZoneEquipment::ZoneEquipType::CoolingPanel: {
    4055             :                 // do nothing, OA not included
    4056     2479960 :             } break;
    4057             : 
    4058           0 :             default: {
    4059           0 :                 ShowFatalError(state,
    4060             :                                "ReportMaxVentilationLoads: Developer must either create accounting for OA or include in final else if "
    4061             :                                "to do nothing");
    4062             : 
    4063           0 :                 break;
    4064             :             }
    4065             :             }
    4066             :         }
    4067             : 
    4068             :         // loop over the zone supply air path inlet nodes
    4069     5837020 :         for (int ZoneInNum = 1; ZoneInNum <= thisZoneEquipConfig.NumInletNodes; ++ZoneInNum) {
    4070     2923762 :             Real64 AirSysEnthReturnAir = 0.0;    // enthalpy of the return air (mixing box inlet node, return side) [kJ/kgK]
    4071     2923762 :             Real64 AirSysEnthMixedAir = 0.0;     // enthalpy of the mixed air (mixing box outlet node, mixed air side) [kJ/kgK]
    4072     2923762 :             Real64 AirSysZoneVentLoad = 0.0;     // ventilation load attributed to a particular zone from primary air system [J]
    4073     2923762 :             Real64 ADUCoolFlowrate = 0.0;        // Air distribution unit cooling air mass flow rate [kg/s]
    4074     2923762 :             Real64 ADUHeatFlowrate = 0.0;        // Air distribution unit heating air mass flow rate [kg/s]
    4075     2923762 :             Real64 AirSysTotalMixFlowRate = 0.0; // Mixed air mass flow rate [kg/s]
    4076     2923762 :             Real64 AirSysOutAirFlow = 0.0;       // outside air flow rate for zone from primary air system [kg/s]
    4077             :             // retrieve air loop index
    4078     2923762 :             int AirLoopNum = thisZoneEquipConfig.InletNodeAirLoopNum(ZoneInNum);
    4079     2923762 :             int MixedAirNode = 0;
    4080     2923762 :             int ReturnAirNode = 0;
    4081     2923762 :             int AirDistCoolInletNodeNum = 0;
    4082     2923762 :             int AirDistHeatInletNodeNum = 0;
    4083     2923762 :             if (AirLoopNum != 0) { // deal with primary air system
    4084     2255099 :                 AirDistCoolInletNodeNum = max(thisZoneEquipConfig.AirDistUnitCool(ZoneInNum).InNode, 0);
    4085     2255099 :                 AirDistHeatInletNodeNum = max(thisZoneEquipConfig.AirDistUnitHeat(ZoneInNum).InNode, 0);
    4086             :                 // Set for cooling or heating path
    4087     2255099 :                 if (AirDistCoolInletNodeNum > 0 && AirDistHeatInletNodeNum == 0) {
    4088     2203002 :                     ADUCoolFlowrate = max(Node(thisZoneEquipConfig.AirDistUnitCool(ZoneInNum).InNode).MassFlowRate,
    4089             :                                           0.0); // CR7244 need to accumulate flow across multiple inlets
    4090       52097 :                 } else if (AirDistHeatInletNodeNum > 0 && AirDistCoolInletNodeNum == 0) {
    4091           0 :                     ADUHeatFlowrate = max(Node(thisZoneEquipConfig.AirDistUnitHeat(ZoneInNum).InNode).MassFlowRate,
    4092             :                                           0.0); // CR7244 need to accumulate flow across multiple inlets
    4093       52097 :                 } else if (AirDistCoolInletNodeNum > 0 && AirDistHeatInletNodeNum > 0 && AirDistCoolInletNodeNum != AirDistHeatInletNodeNum) {
    4094             :                     // dual ducts! CR7244 need to accumulate flow across multiple inlets (don't count same inlet twice)
    4095       15913 :                     ADUHeatFlowrate = max(Node(thisZoneEquipConfig.AirDistUnitHeat(ZoneInNum).InNode).MassFlowRate,
    4096             :                                           0.0); // CR7244 need to accumulate flow across multiple inlets
    4097       15913 :                     ADUCoolFlowrate = max(Node(thisZoneEquipConfig.AirDistUnitCool(ZoneInNum).InNode).MassFlowRate,
    4098             :                                           0.0); // CR7244 need to accumulate flow across multiple inlets
    4099       36184 :                 } else if (AirDistCoolInletNodeNum > 0 && AirDistHeatInletNodeNum > 0) {
    4100             :                     // dual ducts! CR7244 need to accumulate flow across multiple inlets (don't count same inlet twice)
    4101       36184 :                     ADUCoolFlowrate = max(Node(thisZoneEquipConfig.AirDistUnitCool(ZoneInNum).InNode).MassFlowRate,
    4102             :                                           0.0); // CR7244 need to accumulate flow across multiple inlets
    4103             :                 } else {
    4104             :                     // do nothing (already inits)
    4105             :                 }
    4106             :                 // Find the mixed air node and return air node of the system that supplies the zone
    4107     2255099 :                 MixedAirNode = state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum).OASysOutletNodeNum;
    4108     2255099 :                 ReturnAirNode = state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum).OASysInletNodeNum;
    4109             : 
    4110             :                 // Collect air loop Voz-dyn and natural ventilation
    4111     2255099 :                 int ADUNum = thisZoneEquipConfig.InletNodeADUNum(ZoneInNum);
    4112     2255099 :                 Real64 termUnitOAFrac = 1.0;
    4113     2255099 :                 if (ADUNum > 0) {
    4114     2247008 :                     int termUnitSizingNum = state.dataDefineEquipment->AirDistUnit(ADUNum).TermUnitSizingNum;
    4115     2247008 :                     if (termUnitSizingNum > 0) {
    4116     2247008 :                         termUnitOAFrac = state.dataSize->TermUnitSizing(termUnitSizingNum).SpecMinOAFrac;
    4117             :                     }
    4118             :                 }
    4119     2255099 :                 state.dataSysRpts->SysVentRepVars(AirLoopNum).TargetVentilationFlowVoz +=
    4120     2255099 :                     termUnitOAFrac * thisZoneVentRepVars.TargetVentilationFlowVoz;
    4121             :                 Real64 naturalVentFlow =
    4122     2255099 :                     (state.dataHeatBal->ZnAirRpt(CtrlZoneNum).VentilVolumeStdDensity + thisZonePredefRep.AFNVentVolStdDen) / TimeStepSysSec;
    4123     2255099 :                 state.dataSysRpts->SysVentRepVars(AirLoopNum).NatVentFlow += termUnitOAFrac * naturalVentFlow;
    4124             : 
    4125     2255099 :                 if (thisZonePredefRep.isOccupied) {
    4126      805385 :                     state.dataSysRpts->SysVentRepVars(AirLoopNum).AnyZoneOccupied = true;
    4127             :                 }
    4128             :             }
    4129             : 
    4130     2923762 :             if (MixedAirNode == 0 || ReturnAirNode == 0) {
    4131      814679 :                 AirSysZoneVentLoad = 0.0;
    4132      814679 :                 AirSysOutAirFlow = 0.0;
    4133             :             } else {
    4134             :                 // Calculate return and mixed air ethalpies
    4135     2109083 :                 AirSysEnthReturnAir = Psychrometrics::PsyHFnTdbW(Node(ReturnAirNode).Temp, Node(ReturnAirNode).HumRat);
    4136     2109083 :                 AirSysEnthMixedAir = Psychrometrics::PsyHFnTdbW(Node(MixedAirNode).Temp, Node(MixedAirNode).HumRat);
    4137             : 
    4138     2109083 :                 if (state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum).OASysExists) {
    4139     2109083 :                     int OutAirNode = state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum).OAMixOAInNodeNum;
    4140     2109083 :                     AirSysOutAirFlow = Node(OutAirNode).MassFlowRate;
    4141             :                 } else {
    4142           0 :                     AirSysOutAirFlow = 0.0;
    4143             :                 }
    4144             : 
    4145     2109083 :                 AirSysTotalMixFlowRate = Node(MixedAirNode).MassFlowRate;
    4146             : 
    4147     2109083 :                 if (AirSysTotalMixFlowRate != 0.0) {
    4148     1595181 :                     ZoneFlowFrac = (ADUCoolFlowrate + ADUHeatFlowrate) / AirSysTotalMixFlowRate;
    4149     1595181 :                     AirSysOutAirFlow *= ZoneFlowFrac;
    4150             :                 } else {
    4151      513902 :                     ZoneFlowFrac = 0.0;
    4152      513902 :                     AirSysOutAirFlow = 0.0;
    4153             :                 }
    4154             :                 // Calculate the zone ventilation load for this supply air path (i.e. zone inlet)
    4155     2109083 :                 AirSysZoneVentLoad = (ADUCoolFlowrate + ADUHeatFlowrate) * (AirSysEnthMixedAir - AirSysEnthReturnAir) * TimeStepSysSec; //*KJperJ
    4156             :             }
    4157     2923762 :             ZAirSysZoneVentLoad += AirSysZoneVentLoad;
    4158     2923762 :             ZAirSysOutAirFlow += AirSysOutAirFlow;
    4159             :         } // primary air system present
    4160             : 
    4161             :         // now combine OA flow from zone forced air units with primary air system
    4162     2913258 :         OutAirFlow = ZAirSysOutAirFlow + ZFAUOutAirFlow;
    4163             :         // assign report variables
    4164     2913258 :         thisZoneVentRepVars.OAMassFlow = OutAirFlow;
    4165     2913258 :         thisZoneVentRepVars.OAMass = thisZoneVentRepVars.OAMassFlow * TimeStepSysSec;
    4166             : 
    4167             :         // determine volumetric values from mass flow using standard density (adjusted for elevation)
    4168     2913258 :         thisZoneVentRepVars.OAVolFlowStdRho = thisZoneVentRepVars.OAMassFlow / state.dataEnvrn->StdRhoAir;
    4169     2913258 :         thisZoneVentRepVars.OAVolStdRho = thisZoneVentRepVars.OAVolFlowStdRho * TimeStepSysSec;
    4170             : 
    4171             :         // set time mechanical+natural ventilation is below, at, or above target Voz-dyn
    4172             :         Real64 totMechNatVentVolStdRho =
    4173     2913258 :             thisZoneVentRepVars.OAVolStdRho + state.dataHeatBal->ZnAirRpt(CtrlZoneNum).VentilVolumeStdDensity + thisZonePredefRep.AFNVentVolStdDen;
    4174     2913258 :         Real64 targetVoz = thisZoneVentRepVars.TargetVentilationFlowVoz * TimeStepSysSec;
    4175             :         // Allow 1% tolerance
    4176     2913258 :         if (totMechNatVentVolStdRho < (0.99 * targetVoz)) {
    4177      748085 :             thisZoneVentRepVars.TimeBelowVozDyn = TimeStepSys;
    4178      748085 :             state.dataSysRpts->AnyZoneTimeBelowVozDyn = TimeStepSys;
    4179     2165173 :         } else if (totMechNatVentVolStdRho > (1.01 * targetVoz)) {
    4180      923883 :             thisZoneVentRepVars.TimeAboveVozDyn = TimeStepSys;
    4181      923883 :             state.dataSysRpts->AnyZoneTimeAboveVozDyn = TimeStepSys;
    4182     1241290 :         } else if (totMechNatVentVolStdRho > HVAC::SmallAirVolFlow) {
    4183      185977 :             thisZoneVentRepVars.TimeAtVozDyn = TimeStepSys;
    4184      185977 :             state.dataSysRpts->AllZonesTimeAtVozDyn = TimeStepSys;
    4185             :         }
    4186             : 
    4187             :         // determine volumetric values from mass flow using current air density for zone (adjusted for elevation)
    4188             :         Real64 currentZoneAirDensity =
    4189     5826516 :             Psychrometrics::PsyRhoAirFnPbTdbW(state,
    4190     2913258 :                                               state.dataEnvrn->OutBaroPress,
    4191     2913258 :                                               state.dataZoneTempPredictorCorrector->zoneHeatBalance(CtrlZoneNum).MAT,
    4192     2913258 :                                               state.dataZoneTempPredictorCorrector->zoneHeatBalance(CtrlZoneNum).airHumRatAvg);
    4193     2913258 :         if (currentZoneAirDensity > 0.0) thisZoneVentRepVars.OAVolFlowCrntRho = thisZoneVentRepVars.OAMassFlow / currentZoneAirDensity;
    4194     2913258 :         thisZoneVentRepVars.OAVolCrntRho = thisZoneVentRepVars.OAVolFlowCrntRho * TimeStepSysSec;
    4195     2913258 :         if (ZoneVolume > 0.0) thisZoneVentRepVars.MechACH = (thisZoneVentRepVars.OAVolCrntRho / TimeStepSys) / ZoneVolume;
    4196             : 
    4197             :         // store data for predefined tabular report on outside air
    4198     2913258 :         if (thisZonePredefRep.isOccupied) {
    4199             :             // accumulate the occupied time
    4200     1071522 :             thisZonePredefRep.TotTimeOcc += TimeStepSys;
    4201             :             // mechanical ventilation
    4202     1071522 :             thisZonePredefRep.MechVentVolTotalOcc += thisZoneVentRepVars.OAVolCrntRho;
    4203     1071522 :             if ((thisZoneVentRepVars.OAVolCrntRho / TimeStepSys) < thisZonePredefRep.MechVentVolMin) {
    4204       46424 :                 thisZonePredefRep.MechVentVolMin = thisZoneVentRepVars.OAVolCrntRho / TimeStepSys;
    4205             :             }
    4206     1071522 :             thisZonePredefRep.MechVentVolTotalOccStdDen += thisZoneVentRepVars.OAVolStdRho;
    4207             :             // infiltration
    4208     1071522 :             thisZonePredefRep.InfilVolTotalOcc += state.dataHeatBal->ZnAirRpt(CtrlZoneNum).InfilVolumeCurDensity;
    4209     1071522 :             if (state.dataHeatBal->ZnAirRpt(CtrlZoneNum).InfilVolumeCurDensity < thisZonePredefRep.InfilVolMin) {
    4210       25587 :                 thisZonePredefRep.InfilVolMin = state.dataHeatBal->ZnAirRpt(CtrlZoneNum).InfilVolumeCurDensity;
    4211             :             }
    4212     1071522 :             thisZonePredefRep.InfilVolTotalOccStdDen += state.dataHeatBal->ZnAirRpt(CtrlZoneNum).InfilVolumeStdDensity;
    4213             :             // 'simple' natural ventilation
    4214     1071522 :             thisZonePredefRep.SimpVentVolTotalOcc += state.dataHeatBal->ZnAirRpt(CtrlZoneNum).VentilVolumeCurDensity;
    4215     1071522 :             if (state.dataHeatBal->ZnAirRpt(CtrlZoneNum).VentilVolumeCurDensity < thisZonePredefRep.SimpVentVolMin) {
    4216        3817 :                 thisZonePredefRep.SimpVentVolMin = state.dataHeatBal->ZnAirRpt(CtrlZoneNum).VentilVolumeCurDensity;
    4217             :             }
    4218     1071522 :             thisZonePredefRep.SimpVentVolTotalOccStdDen += state.dataHeatBal->ZnAirRpt(CtrlZoneNum).VentilVolumeStdDensity;
    4219             :             // target ventilation Voz-dyn
    4220     1071522 :             state.dataSysRpts->AnyZoneTimeBelowVozDynOcc = state.dataSysRpts->AnyZoneTimeBelowVozDyn;
    4221     1071522 :             state.dataSysRpts->AllZonesTimeAtVozDynOcc = state.dataSysRpts->AllZonesTimeAtVozDyn;
    4222     1071522 :             state.dataSysRpts->AnyZoneTimeAboveVozDynOcc = state.dataSysRpts->AnyZoneTimeAboveVozDyn;
    4223     1071522 :             thisZonePredefRep.VozTargetTotalOcc += targetVoz;
    4224             : 
    4225             :             // time mechanical+natural ventilation is below, at, or above target Voz-dyn
    4226     1071522 :             thisZonePredefRep.VozTargetTimeBelowOcc += thisZoneVentRepVars.TimeBelowVozDyn;
    4227     1071522 :             thisZonePredefRep.VozTargetTimeAtOcc += thisZoneVentRepVars.TimeAtVozDyn;
    4228     1071522 :             thisZonePredefRep.VozTargetTimeAboveOcc += thisZoneVentRepVars.TimeAboveVozDyn;
    4229     1841736 :         } else if (totMechNatVentVolStdRho > HVAC::SmallAirVolFlow) {
    4230      822688 :             thisZoneVentRepVars.TimeVentUnocc = TimeStepSys;
    4231      822688 :             state.dataSysRpts->AnyZoneTimeVentUnocc = TimeStepSys;
    4232      822688 :             thisZonePredefRep.TotVentTimeNonZeroUnocc += thisZoneVentRepVars.TimeVentUnocc;
    4233             :         }
    4234             :         // accumulate during occupancy or not
    4235     2913258 :         thisZonePredefRep.MechVentVolTotalStdDen += thisZoneVentRepVars.OAVolStdRho;
    4236     2913258 :         thisZonePredefRep.InfilVolTotalStdDen += state.dataHeatBal->ZnAirRpt(CtrlZoneNum).InfilVolumeStdDensity;
    4237     2913258 :         thisZonePredefRep.SimpVentVolTotalStdDen += state.dataHeatBal->ZnAirRpt(CtrlZoneNum).VentilVolumeStdDensity;
    4238     2913258 :         thisZonePredefRep.VozTargetTotal += targetVoz;
    4239     2913258 :         thisZonePredefRep.VozTargetTimeBelow += thisZoneVentRepVars.TimeBelowVozDyn;
    4240     2913258 :         thisZonePredefRep.VozTargetTimeAt += thisZoneVentRepVars.TimeAtVozDyn;
    4241     2913258 :         thisZonePredefRep.VozTargetTimeAbove += thisZoneVentRepVars.TimeAboveVozDyn;
    4242             : 
    4243             :         // now combine Vent load from zone forced air units with primary air system
    4244     2913258 :         Real64 ZoneVentLoad = ZAirSysZoneVentLoad + ZFAUZoneVentLoad;
    4245             :         // cycle if ZoneVentLoad is small
    4246     2913258 :         if (std::abs(ZoneVentLoad) < SmallLoad) continue; // orig. had RETURN here, BG changed to CYCLE for next controlled zone in do loop.
    4247             : 
    4248             :         // Ventilation Heating
    4249     1557245 :         if (ZoneVentLoad > SmallLoad) {
    4250             :             // Zone cooling load
    4251      581041 :             if (ZoneLoad < -SmallLoad) {
    4252      386789 :                 thisZoneVentRepVars.CoolingLoadAddedByVent += std::abs(ZoneVentLoad);
    4253             :                 // Zone heating load
    4254      194252 :             } else if (ZoneLoad > SmallLoad) {
    4255        3431 :                 if (ZoneVentLoad > ZoneLoad) {
    4256        3419 :                     thisZoneVentRepVars.HeatingLoadMetByVent += std::abs(ZoneLoad);
    4257        3419 :                     thisZoneVentRepVars.OverheatingByVent += (ZoneVentLoad - ZoneLoad);
    4258             :                 } else {
    4259          12 :                     thisZoneVentRepVars.HeatingLoadMetByVent += std::abs(ZoneVentLoad);
    4260             :                 }
    4261             :                 // No Zone Load
    4262             :             } else {
    4263      190821 :                 thisZoneVentRepVars.NoLoadHeatingByVent += std::abs(ZoneVentLoad);
    4264             :             }
    4265             : 
    4266             :             // Ventilation Cooling
    4267      976204 :         } else if (ZoneVentLoad < -SmallLoad) {
    4268             :             // Zone cooling load
    4269      976204 :             if (ZoneLoad < -SmallLoad) {
    4270      174252 :                 if (ZoneVentLoad < ZoneLoad) {
    4271      172703 :                     thisZoneVentRepVars.CoolingLoadMetByVent += std::abs(ZoneLoad);
    4272      172703 :                     thisZoneVentRepVars.OvercoolingByVent += std::abs(ZoneVentLoad - ZoneLoad);
    4273             :                 } else {
    4274        1549 :                     thisZoneVentRepVars.CoolingLoadMetByVent += std::abs(ZoneVentLoad);
    4275             :                 }
    4276             :                 // Zone heating load
    4277      801952 :             } else if (ZoneLoad > SmallLoad) {
    4278      556894 :                 thisZoneVentRepVars.HeatingLoadAddedByVent += std::abs(ZoneVentLoad);
    4279             :                 // No Zone Load
    4280             :             } else {
    4281      245058 :                 thisZoneVentRepVars.NoLoadCoolingByVent += std::abs(ZoneVentLoad);
    4282             :             }
    4283             : 
    4284             :             // Ventilation No Load
    4285             :         } else {
    4286             :         }
    4287             :     } // loop over controlled zones
    4288             : 
    4289             :     // loop over air loops
    4290     1462657 :     for (int sysNum = 1; sysNum <= state.dataHVACGlobal->NumPrimaryAirSys; ++sysNum) {
    4291      847428 :         auto &thisSysVentRepVars = state.dataSysRpts->SysVentRepVars(sysNum);
    4292      847428 :         auto &thisSysPreDefRep = state.dataSysRpts->SysPreDefRep(sysNum);
    4293      847428 :         Real64 mechVentFlow = state.dataAirLoop->AirLoopFlow(sysNum).OAFlow / state.dataEnvrn->StdRhoAir;
    4294      847428 :         thisSysVentRepVars.MechVentFlow = mechVentFlow;
    4295      847428 :         thisSysPreDefRep.MechVentTotal += mechVentFlow * TimeStepSysSec;
    4296      847428 :         thisSysPreDefRep.NatVentTotal += thisSysVentRepVars.NatVentFlow * TimeStepSysSec;
    4297             : 
    4298             :         // set time mechanical+natural ventilation is below, at, or above target Voz-dyn
    4299      847428 :         Real64 totMechNatVentVolFlowStdRho = mechVentFlow + thisSysVentRepVars.NatVentFlow;
    4300             : 
    4301      847428 :         Real64 targetFlowVoz = thisSysVentRepVars.TargetVentilationFlowVoz;
    4302      847428 :         thisSysPreDefRep.TargetVentTotalVoz += targetFlowVoz * TimeStepSysSec;
    4303             :         // Allow 1% tolerance
    4304      847428 :         if (totMechNatVentVolFlowStdRho < (0.99 * targetFlowVoz)) {
    4305      195369 :             thisSysVentRepVars.TimeBelowVozDyn = TimeStepSys;
    4306      195369 :             thisSysPreDefRep.TimeBelowVozDynTotal += TimeStepSys;
    4307      652059 :         } else if (totMechNatVentVolFlowStdRho > (1.01 * targetFlowVoz)) {
    4308      233653 :             thisSysVentRepVars.TimeAboveVozDyn = TimeStepSys;
    4309      233653 :             thisSysPreDefRep.TimeAboveVozDynTotal += TimeStepSys;
    4310      418406 :         } else if (totMechNatVentVolFlowStdRho > HVAC::SmallAirVolFlow) {
    4311      125432 :             thisSysVentRepVars.TimeAtVozDyn = TimeStepSys;
    4312      125432 :             thisSysPreDefRep.TimeAtVozDynTotal += TimeStepSys;
    4313             :         }
    4314             : 
    4315      847428 :         if (thisSysVentRepVars.AnyZoneOccupied) {
    4316      325099 :             thisSysPreDefRep.TimeOccupiedTotal += TimeStepSys;
    4317      325099 :             thisSysPreDefRep.MechVentTotalOcc += mechVentFlow * TimeStepSysSec;
    4318      325099 :             thisSysPreDefRep.NatVentTotalOcc += thisSysVentRepVars.NatVentFlow * TimeStepSysSec;
    4319      325099 :             thisSysPreDefRep.TargetVentTotalVozOcc += targetFlowVoz * TimeStepSysSec;
    4320      325099 :             thisSysPreDefRep.TimeBelowVozDynTotalOcc += thisSysVentRepVars.TimeBelowVozDyn;
    4321      325099 :             thisSysPreDefRep.TimeAboveVozDynTotalOcc += thisSysVentRepVars.TimeAboveVozDyn;
    4322      325099 :             thisSysPreDefRep.TimeAtVozDynTotalOcc += thisSysVentRepVars.TimeAtVozDyn;
    4323      522329 :         } else if (totMechNatVentVolFlowStdRho > HVAC::SmallAirVolFlow) {
    4324      191807 :             thisSysVentRepVars.TimeVentUnocc = TimeStepSys;
    4325      191807 :             thisSysPreDefRep.TimeVentUnoccTotal += TimeStepSys;
    4326             :         }
    4327             : 
    4328             :         // set time at OA limiting factors
    4329      847428 :         if (mechVentFlow > HVAC::SmallAirVolFlow) {
    4330      443227 :             int thisOAControlNum = state.dataAirLoop->AirLoopControlInfo(sysNum).OACtrlNum;
    4331      443227 :             if (thisOAControlNum > 0) {
    4332      442987 :                 int limitFactorIndex = static_cast<int>(state.dataMixedAir->OAController(thisOAControlNum).OALimitingFactor);
    4333      442987 :                 thisSysPreDefRep.TimeAtOALimit[limitFactorIndex] += TimeStepSys;
    4334      442987 :                 if (thisSysVentRepVars.AnyZoneOccupied) {
    4335      255670 :                     thisSysPreDefRep.TimeAtOALimitOcc[limitFactorIndex] += TimeStepSys;
    4336      255670 :                     thisSysPreDefRep.MechVentTotAtLimitOcc[limitFactorIndex] += mechVentFlow * TimeStepSysSec;
    4337             :                 }
    4338             :             }
    4339             :         }
    4340             :     }
    4341             :     // Accumulate facility totals
    4342      615229 :     state.dataOutRptPredefined->TotalAnyZoneBelowVozDynForOA += state.dataSysRpts->AnyZoneTimeBelowVozDyn;
    4343      615229 :     state.dataOutRptPredefined->TotalAllZonesAtVozDynForOA += state.dataSysRpts->AllZonesTimeAtVozDyn;
    4344      615229 :     state.dataOutRptPredefined->TotalAnyZoneAboveVozDynForOA += state.dataSysRpts->AnyZoneTimeAboveVozDyn;
    4345      615229 :     state.dataOutRptPredefined->TotalAnyZoneVentUnoccForOA += state.dataSysRpts->AnyZoneTimeVentUnocc;
    4346      615229 :     state.dataOutRptPredefined->TotalAnyZoneBelowVozDynOccForOA += state.dataSysRpts->AnyZoneTimeBelowVozDynOcc;
    4347      615229 :     state.dataOutRptPredefined->TotalAllZonesAtVozDynOccForOA += state.dataSysRpts->AllZonesTimeAtVozDynOcc;
    4348      615229 :     state.dataOutRptPredefined->TotalAnyZoneAboveVozDynOccForOA += state.dataSysRpts->AnyZoneTimeAboveVozDynOcc;
    4349             : }
    4350             : 
    4351        3717 : void MatchPlantSys(EnergyPlusData &state,
    4352             :                    int const AirLoopNum, // counter for zone air distribution inlets
    4353             :                    int const BranchNum   // counter for zone air distribution inlets
    4354             : )
    4355             : {
    4356             :     // SUBROUTINE INFORMATION:
    4357             :     //       AUTHOR         Dan Fisher
    4358             :     //       DATE WRITTEN   May 2005
    4359             : 
    4360             :     // PURPOSE OF THIS SUBROUTINE:
    4361             :     // calculate and report zone ventilation loads
    4362             : 
    4363             :     // METHODOLOGY EMPLOYED:
    4364             :     // calculate energy contribution of outside air through mixing box and pro-rate to
    4365             :     // zones according to zone mass flow rates.
    4366             : 
    4367        3717 :     int constexpr EnergyTrans(1);
    4368             : 
    4369       18038 :     for (int CompNum = 1; CompNum <= state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum).Branch(BranchNum).TotalComponents; ++CompNum) {
    4370             :         {
    4371       14321 :             auto &thisComp = state.dataAirSystemsData->PrimaryAirSystems(AirLoopNum).Branch(BranchNum).Comp(CompNum);
    4372       19265 :             for (int VarNum = 1; VarNum <= thisComp.NumMeteredVars; ++VarNum) {
    4373       10980 :                 if (thisComp.MeteredVar(VarNum).resource == Constant::eResource::EnergyTransfer) {
    4374        6036 :                     thisComp.EnergyTransComp = EnergyTrans;
    4375        6036 :                     const std::string &CompType = thisComp.TypeOf;
    4376        6036 :                     const std::string &CompName = thisComp.Name;
    4377        6036 :                     bool MatchFound = false; // Set to .TRUE. when a match is found
    4378        6036 :                     int MatchLoop = 0;       // Loop number of the match
    4379        6036 :                     int MatchBranch = 0;     // Branch number of the match
    4380        6036 :                     int MatchComp = 0;       // Component number of the match
    4381        6036 :                     int MatchLoopType = 0;
    4382        6036 :                     int Idx = 0;
    4383        6036 :                     FindDemandSideMatch(state, CompType, CompName, MatchFound, MatchLoopType, MatchLoop, MatchBranch, MatchComp);
    4384        6036 :                     if (MatchFound)
    4385        5459 :                         UpdateAirSysCompPtrArray(state, Idx, AirLoopNum, BranchNum, CompNum, MatchLoopType, MatchLoop, MatchBranch, MatchComp);
    4386        6036 :                     thisComp.AirSysToPlantPtr = Idx;
    4387        6036 :                     break;
    4388             :                 }
    4389             :             }
    4390       21204 :             for (int SubCompNum = 1; SubCompNum <= thisComp.NumSubComps; ++SubCompNum) {
    4391             :                 //!!!!          IF(SysVentLoad == 0.0d0)EXIT
    4392             :                 {
    4393        6883 :                     auto &thisSubComp(thisComp.SubComp(SubCompNum));
    4394        7959 :                     for (int VarNum = 1; VarNum <= thisSubComp.NumMeteredVars; ++VarNum) {
    4395        3927 :                         if (thisSubComp.MeteredVar(VarNum).resource == Constant::eResource::EnergyTransfer) {
    4396        2851 :                             thisSubComp.EnergyTransComp = EnergyTrans;
    4397        2851 :                             const std::string &CompType = thisComp.TypeOf;
    4398        2851 :                             const std::string &CompName = thisComp.Name;
    4399        2851 :                             bool MatchFound = false; // Set to .TRUE. when a match is found
    4400        2851 :                             int MatchLoop = 0;       // Loop number of the match
    4401        2851 :                             int MatchBranch = 0;     // Branch number of the match
    4402        2851 :                             int MatchComp = 0;       // Component number of the match
    4403        2851 :                             int MatchLoopType = 0;
    4404        2851 :                             int Idx = 0;
    4405        2851 :                             FindDemandSideMatch(state, CompType, CompName, MatchFound, MatchLoopType, MatchLoop, MatchBranch, MatchComp);
    4406        2851 :                             if (MatchFound)
    4407           0 :                                 UpdateAirSysSubCompPtrArray(
    4408             :                                     state, Idx, AirLoopNum, BranchNum, CompNum, SubCompNum, MatchLoopType, MatchLoop, MatchBranch, MatchComp);
    4409        2851 :                             thisSubComp.AirSysToPlantPtr = Idx;
    4410        2851 :                             break;
    4411             :                         }
    4412             :                     }
    4413        7000 :                     for (int SubSubCompNum = 1; SubSubCompNum <= thisSubComp.NumSubSubComps; ++SubSubCompNum) {
    4414             :                         //!!!!            IF(SysVentLoad == 0.0d0)EXIT
    4415             :                         {
    4416         117 :                             auto &thisSubSubComp = thisSubComp.SubSubComp(SubSubCompNum);
    4417         157 :                             for (int VarNum = 1; VarNum <= thisSubSubComp.NumMeteredVars; ++VarNum) {
    4418         140 :                                 if (thisSubSubComp.MeteredVar(VarNum).resource == Constant::eResource::EnergyTransfer) {
    4419         100 :                                     thisSubSubComp.EnergyTransComp = EnergyTrans;
    4420         100 :                                     const std::string &CompType = thisComp.TypeOf;
    4421         100 :                                     const std::string &CompName = thisComp.Name;
    4422         100 :                                     bool MatchFound = false; // Set to .TRUE. when a match is found
    4423         100 :                                     int MatchLoop = 0;       // Loop number of the match
    4424         100 :                                     int MatchBranch = 0;     // Branch number of the match
    4425         100 :                                     int MatchComp = 0;       // Component number of the match
    4426         100 :                                     int MatchLoopType = 0;
    4427         100 :                                     int Idx = 0;
    4428         100 :                                     FindDemandSideMatch(state, CompType, CompName, MatchFound, MatchLoopType, MatchLoop, MatchBranch, MatchComp);
    4429         100 :                                     if (MatchFound)
    4430           0 :                                         UpdateAirSysSubSubCompPtrArray(state,
    4431             :                                                                        Idx,
    4432             :                                                                        AirLoopNum,
    4433             :                                                                        BranchNum,
    4434             :                                                                        CompNum,
    4435             :                                                                        SubCompNum,
    4436             :                                                                        SubSubCompNum,
    4437             :                                                                        MatchLoopType,
    4438             :                                                                        MatchLoop,
    4439             :                                                                        MatchBranch,
    4440             :                                                                        MatchComp);
    4441         100 :                                     thisSubSubComp.AirSysToPlantPtr = Idx;
    4442         100 :                                     break;
    4443             :                                 }
    4444             :                             }
    4445             :                         }
    4446             :                     }
    4447             :                 }
    4448             :             }
    4449             :         }
    4450             :     }
    4451        3717 : }
    4452             : 
    4453       53289 : void FindDemandSideMatch(EnergyPlusData &state,
    4454             :                          std::string const &CompType, // Inlet node of the component to find the match of
    4455             :                          std::string_view CompName,   // Outlet node of the component to find the match of
    4456             :                          bool &MatchFound,            // Set to .TRUE. when a match is found
    4457             :                          int &MatchLoopType,          // Loop number of the match
    4458             :                          int &MatchLoop,              // Loop number of the match
    4459             :                          int &MatchBranch,            // Branch number of the match
    4460             :                          int &MatchComp               // Component number of the match
    4461             : )
    4462             : {
    4463             : 
    4464             :     // SUBROUTINE INFORMATION:
    4465             :     //       AUTHOR         Rick Strand
    4466             :     //       DATE WRITTEN   September 2004
    4467             : 
    4468             :     // PURPOSE OF THIS SUBROUTINE:
    4469             :     // This subroutine intializes the connections between various loops.
    4470             :     // Due to the fact that this requires numerous string compares, it
    4471             :     // is much more efficient to find this information once and then
    4472             :     // store it in module level variables (LoopConnect derived type).
    4473             : 
    4474             :     // METHODOLOGY EMPLOYED:
    4475             :     // Simply cycles through the plant and condenser demand sides until
    4476             :     // a component is found that matches the component type and name
    4477             : 
    4478             :     // Initialize all of the output variables
    4479             : 
    4480       53289 :     MatchFound = false;
    4481       53289 :     MatchLoopType = 0;
    4482       53289 :     MatchLoop = 0;
    4483       53289 :     MatchLoop = 0;
    4484       53289 :     MatchBranch = 0;
    4485       53289 :     MatchComp = 0;
    4486             : 
    4487             :     // Now cycle through all of the demand side loops to see if we can find
    4488             :     // a match for the component type and name.  Once a match is found,
    4489             :     // record the type of loop and the loop, branch, and component numbers.
    4490       53289 :     if (!MatchFound) { // Go through the plant demand side loops
    4491      179836 :         for (int PassLoopNum = 1; PassLoopNum <= state.dataHVACGlobal->NumPlantLoops; ++PassLoopNum) {
    4492     3893116 :             for (int PassBranchNum = 1;
    4493     3893116 :                  PassBranchNum <= state.dataPlnt->VentRepPlant[static_cast<int>(LoopSideLocation::Demand)](PassLoopNum).TotalBranches;
    4494             :                  ++PassBranchNum) {
    4495     7526498 :                 for (int PassCompNum = 1;
    4496     7526498 :                      PassCompNum <=
    4497     7526498 :                      state.dataPlnt->VentRepPlant[static_cast<int>(LoopSideLocation::Demand)](PassLoopNum).Branch(PassBranchNum).TotalComponents;
    4498             :                      ++PassCompNum) {
    4499     3768424 :                     if (Util::SameString(CompType,
    4500     3768424 :                                          state.dataPlnt->VentRepPlant[static_cast<int>(LoopSideLocation::Demand)](PassLoopNum)
    4501     3768424 :                                              .Branch(PassBranchNum)
    4502     3768424 :                                              .Comp(PassCompNum)
    4503     4162141 :                                              .TypeOf) &&
    4504      393717 :                         Util::SameString(CompName,
    4505      393717 :                                          state.dataPlnt->VentRepPlant[static_cast<int>(LoopSideLocation::Demand)](PassLoopNum)
    4506      393717 :                                              .Branch(PassBranchNum)
    4507      393717 :                                              .Comp(PassCompNum)
    4508             :                                              .Name)) {
    4509             :                         // Found a match on the plant demand side--increment the counter
    4510        8495 :                         MatchFound = true;
    4511        8495 :                         MatchLoopType = 1;
    4512        8495 :                         MatchLoop = PassLoopNum;
    4513        8495 :                         MatchBranch = PassBranchNum;
    4514        8495 :                         MatchComp = PassCompNum;
    4515        8495 :                         break; // PassCompNum DO loop
    4516             :                     }
    4517             :                 }
    4518     3766569 :                 if (MatchFound) break; // PassBranchNum DO loop
    4519             :             }
    4520      135042 :             if (MatchFound) break; // PassLoopNum DO loop
    4521             :         }
    4522             :     }
    4523             : 
    4524       53289 :     if (!MatchFound) { // Go through the condenser demand side loops
    4525       69224 :         for (int PassLoopNum = 1; PassLoopNum <= state.dataHVACGlobal->NumCondLoops; ++PassLoopNum) {
    4526      143054 :             for (int PassBranchNum = 1;
    4527      143054 :                  PassBranchNum <= state.dataPlnt->VentRepCond[static_cast<int>(LoopSideLocation::Demand)](PassLoopNum).TotalBranches;
    4528             :                  ++PassBranchNum) {
    4529      234956 :                 for (int PassCompNum = 1;
    4530      234956 :                      PassCompNum <=
    4531      234956 :                      state.dataPlnt->VentRepCond[static_cast<int>(LoopSideLocation::Demand)](PassLoopNum).Branch(PassBranchNum).TotalComponents;
    4532             :                      ++PassCompNum) {
    4533      118624 :                     if (Util::SameString(CompType,
    4534      118624 :                                          state.dataPlnt->VentRepCond[static_cast<int>(LoopSideLocation::Demand)](PassLoopNum)
    4535      118624 :                                              .Branch(PassBranchNum)
    4536      118624 :                                              .Comp(PassCompNum)
    4537      159304 :                                              .TypeOf) &&
    4538       40680 :                         Util::SameString(CompName,
    4539       40680 :                                          state.dataPlnt->VentRepCond[static_cast<int>(LoopSideLocation::Demand)](PassLoopNum)
    4540       40680 :                                              .Branch(PassBranchNum)
    4541       40680 :                                              .Comp(PassCompNum)
    4542             :                                              .Name)) {
    4543             :                         // Found a match on the plant demand side--increment the counter
    4544        2292 :                         MatchFound = true;
    4545        2292 :                         MatchLoopType = 2;
    4546        2292 :                         MatchLoop = PassLoopNum;
    4547        2292 :                         MatchBranch = PassBranchNum;
    4548        2292 :                         MatchComp = PassCompNum;
    4549        2292 :                         break; // PassCompNum DO loop
    4550             :                     }
    4551             :                 }
    4552      118624 :                 if (MatchFound) break; // PassBranchNum DO loop
    4553             :             }
    4554       26722 :             if (MatchFound) break; // PassLoopNum DO loop
    4555             :         }
    4556             :     }
    4557       53289 : }
    4558             : 
    4559         795 : void ReportAirLoopConnections(EnergyPlusData &state)
    4560             : {
    4561             : 
    4562             :     // SUBROUTINE INFORMATION:
    4563             :     //       AUTHOR         Michael J. Witte, Linda K. Lawrie
    4564             :     //       DATE WRITTEN   February 2004 (moved from BranchInputManager ReportLoopConnections)
    4565             : 
    4566             :     // PURPOSE OF THIS SUBROUTINE:
    4567             :     // Report air loop splitter connections to the BND file.
    4568             : 
    4569             :     static constexpr std::string_view errstring("**error**");
    4570             : 
    4571             :     static constexpr std::string_view Format_706("! <#AirLoopHVACs>,<Number of AirLoopHVACs>");
    4572             :     static constexpr std::string_view Format_708(
    4573             :         "! <AirLoopHVAC>,<Air Loop Name>,<# Return Nodes>,<# Supply Nodes>,<# Zones Cooled>,<# Zones Heated>,<Outdoor Air Used>");
    4574             :     static constexpr std::string_view Format_709(
    4575             :         "! <AirLoop Return Connections>,<Connection Count>,<AirLoopHVAC Name>,<Zn Eqp Return Node #>,<Zn Eqp Return "
    4576             :         "Node Name>,<AirLoop Return Node #>,<Air Loop Return Node Name>");
    4577             :     static constexpr std::string_view Format_710(
    4578             :         "! <AirLoop Supply Connections>,<Connection Count>,<AirLoopHVAC Name>,<Zn Eqp Supply Node #>,<Zn Eqp Supply "
    4579             :         "Node Name>,<AirLoop Supply Node #>,<Air Loop Supply Node Name>");
    4580             :     static constexpr std::string_view Format_711(
    4581             :         "! <Cooled Zone Info>,<Cooled Zone Count>,<Cooled Zone Name>,<Cooled Zone Inlet Node #>,<Cooled Zone Inlet "
    4582             :         "Node Name>,<AirLoopHVAC Name>");
    4583             :     static constexpr std::string_view Format_712(
    4584             :         "! <Heated Zone Info>,<Heated Zone Count>,<Heated Zone Name>,<Heated Zone Inlet Node #>,<Heated Zone Inlet "
    4585             :         "Node Name>,<AirLoopHVAC Name>");
    4586             :     static constexpr std::string_view Format_714(
    4587             :         "! <Outdoor Air Connections>,<OA Inlet Node #>,<OA Return Air Inlet Node Name>,<OA Outlet Node #>,<OA Mixed "
    4588             :         "Air Outlet Node Name>,<AirLoopHVAC Name>");
    4589             : 
    4590         795 :     auto &NodeID = state.dataLoopNodes->NodeID;
    4591             : 
    4592         795 :     print(state.files.bnd, "{}\n", "! ===============================================================");
    4593         795 :     print(state.files.bnd, "{}\n", Format_706);
    4594         795 :     print(state.files.bnd, " #AirLoopHVACs,{}\n", state.dataHVACGlobal->NumPrimaryAirSys);
    4595         795 :     print(state.files.bnd, "{}\n", Format_708);
    4596         795 :     print(state.files.bnd, "{}\n", Format_709);
    4597         795 :     print(state.files.bnd, "{}\n", Format_710);
    4598         795 :     print(state.files.bnd, "{}\n", Format_711);
    4599         795 :     print(state.files.bnd, "{}\n", Format_712);
    4600         795 :     print(state.files.bnd, "{}\n", Format_714);
    4601         795 :     print(state.files.bnd, "{}\n", "! <AirLoopHVAC Connector>,<Connector Type>,<Connector Name>,<Loop Name>,<Loop Type>,<Number of Inlets/Outlets>");
    4602         795 :     print(state.files.bnd,
    4603             :           "{}\n",
    4604             :           "! <AirLoopHVAC Connector Branches>,<Connector Node Count>,<Connector Type>,<Connector Name>,<Inlet Branch>,<Outlet Branch>,<Loop "
    4605             :           "Name>,<Loop Type>");
    4606         795 :     print(state.files.bnd,
    4607             :           "{}\n",
    4608             :           "! <AirLoopHVAC Connector Nodes>,<Connector Node Count>,<Connector Type>,<Connector Name>,<Inlet Node>,<Outlet Node>,<Loop Name>,<Loop "
    4609             :           "Type>");
    4610        2002 :     for (int Count = 1; Count <= state.dataHVACGlobal->NumPrimaryAirSys; ++Count) {
    4611        1207 :         const auto oaSysExists = [&]() {
    4612        1207 :             if (state.dataAirLoop->AirToOANodeInfo(Count).OASysExists) {
    4613        1059 :                 return "Yes";
    4614             :             } else {
    4615         148 :                 return "No";
    4616             :             }
    4617        1207 :         }();
    4618             : 
    4619        1207 :         print(state.files.bnd,
    4620             :               " AirLoopHVAC,{},{},{},{},{},{}\n",
    4621        1207 :               state.dataAirLoop->AirToZoneNodeInfo(Count).AirLoopName,
    4622        1207 :               state.dataAirLoop->AirToZoneNodeInfo(Count).NumReturnNodes,
    4623        1207 :               state.dataAirLoop->AirToZoneNodeInfo(Count).NumSupplyNodes,
    4624        1207 :               state.dataAirLoop->AirToZoneNodeInfo(Count).NumZonesCooled,
    4625        1207 :               state.dataAirLoop->AirToZoneNodeInfo(Count).NumZonesHeated,
    4626             :               oaSysExists);
    4627        2414 :         for (int Count1 = 1; Count1 <= state.dataAirLoop->AirToZoneNodeInfo(Count).NumReturnNodes; ++Count1) {
    4628        1207 :             print(state.files.bnd, "   AirLoop Return Connections,{},{},", Count1, state.dataAirLoop->AirToZoneNodeInfo(Count).AirLoopName);
    4629        1207 :             if (state.dataAirLoop->AirToZoneNodeInfo(Count).ZoneEquipReturnNodeNum(Count1) > 0) {
    4630        1203 :                 print(state.files.bnd,
    4631             :                       "{},{},",
    4632        1203 :                       state.dataAirLoop->AirToZoneNodeInfo(Count).ZoneEquipReturnNodeNum(Count1),
    4633        1203 :                       NodeID(state.dataAirLoop->AirToZoneNodeInfo(Count).ZoneEquipReturnNodeNum(Count1)));
    4634             :             } else {
    4635           4 :                 print(state.files.bnd, "{},{},", errstring, errstring);
    4636             :             }
    4637        1207 :             if (state.dataAirLoop->AirToZoneNodeInfo(Count).AirLoopReturnNodeNum(Count1) > 0) {
    4638        1207 :                 print(state.files.bnd,
    4639             :                       "{},{}\n",
    4640        1207 :                       state.dataAirLoop->AirToZoneNodeInfo(Count).AirLoopReturnNodeNum(Count1),
    4641        1207 :                       NodeID(state.dataAirLoop->AirToZoneNodeInfo(Count).AirLoopReturnNodeNum(Count1)));
    4642             :             } else {
    4643           0 :                 print(state.files.bnd, "{},{}\n", errstring, errstring);
    4644             :             }
    4645             :         }
    4646        2422 :         for (int Count1 = 1; Count1 <= state.dataAirLoop->AirToZoneNodeInfo(Count).NumSupplyNodes; ++Count1) {
    4647        1215 :             print(state.files.bnd, "   AirLoop Supply Connections,{},{},", Count1, state.dataAirLoop->AirToZoneNodeInfo(Count).AirLoopName);
    4648        1215 :             if (state.dataAirLoop->AirToZoneNodeInfo(Count).ZoneEquipSupplyNodeNum(Count1) > 0) {
    4649        1215 :                 print(state.files.bnd,
    4650             :                       "{},{},",
    4651        1215 :                       state.dataAirLoop->AirToZoneNodeInfo(Count).ZoneEquipSupplyNodeNum(Count1),
    4652        1215 :                       NodeID(state.dataAirLoop->AirToZoneNodeInfo(Count).ZoneEquipSupplyNodeNum(Count1)));
    4653             :             } else {
    4654           0 :                 print(state.files.bnd, "{},{},", errstring, errstring);
    4655             :             }
    4656        1215 :             if (state.dataAirLoop->AirToZoneNodeInfo(Count).AirLoopSupplyNodeNum(Count1) > 0) {
    4657        1215 :                 print(state.files.bnd,
    4658             :                       "{},{}\n",
    4659        1215 :                       state.dataAirLoop->AirToZoneNodeInfo(Count).AirLoopSupplyNodeNum(Count1),
    4660        1215 :                       NodeID(state.dataAirLoop->AirToZoneNodeInfo(Count).AirLoopSupplyNodeNum(Count1)));
    4661             :             } else {
    4662           0 :                 print(state.files.bnd, "{},{}\n", errstring, errstring);
    4663             :             }
    4664             :         }
    4665             : 
    4666        4866 :         for (int Count1 = 1; Count1 <= state.dataAirLoop->AirToZoneNodeInfo(Count).NumZonesCooled; ++Count1) {
    4667        3659 :             const int CtrldZoneNum = state.dataAirLoop->AirToZoneNodeInfo(Count).CoolCtrlZoneNums(Count1);
    4668        3659 :             print(state.files.bnd, "   Cooled Zone Info,{},{},", Count1, state.dataHeatBal->Zone(CtrldZoneNum).Name);
    4669        3659 :             if (state.dataAirLoop->AirToZoneNodeInfo(Count).CoolZoneInletNodes(Count1) > 0) {
    4670        3659 :                 print(state.files.bnd,
    4671             :                       "{},{},{}\n",
    4672        3659 :                       state.dataAirLoop->AirToZoneNodeInfo(Count).CoolZoneInletNodes(Count1),
    4673        3659 :                       NodeID(state.dataAirLoop->AirToZoneNodeInfo(Count).CoolZoneInletNodes(Count1)),
    4674        3659 :                       state.dataAirLoop->AirToZoneNodeInfo(Count).AirLoopName);
    4675             :             } else {
    4676           0 :                 print(state.files.bnd, "{},{},{}\n", errstring, errstring, state.dataAirLoop->AirToZoneNodeInfo(Count).AirLoopName);
    4677             :             }
    4678             :         }
    4679        1236 :         for (int Count1 = 1; Count1 <= state.dataAirLoop->AirToZoneNodeInfo(Count).NumZonesHeated; ++Count1) {
    4680          29 :             const int CtrldZoneNum = state.dataAirLoop->AirToZoneNodeInfo(Count).HeatCtrlZoneNums(Count1);
    4681          29 :             print(state.files.bnd, "   Heated Zone Info,{},{},", Count1, state.dataHeatBal->Zone(CtrldZoneNum).Name);
    4682          29 :             if (state.dataAirLoop->AirToZoneNodeInfo(Count).HeatZoneInletNodes(Count1) > 0) {
    4683          29 :                 print(state.files.bnd,
    4684             :                       "{},{},{}\n",
    4685          29 :                       state.dataAirLoop->AirToZoneNodeInfo(Count).HeatZoneInletNodes(Count1),
    4686          29 :                       NodeID(state.dataAirLoop->AirToZoneNodeInfo(Count).HeatZoneInletNodes(Count1)),
    4687          29 :                       state.dataAirLoop->AirToZoneNodeInfo(Count).AirLoopName);
    4688             :             } else {
    4689           0 :                 print(state.files.bnd, "{},{},{}\n", errstring, errstring, state.dataAirLoop->AirToZoneNodeInfo(Count).AirLoopName);
    4690             :             }
    4691             :         }
    4692        1207 :         if (state.dataAirLoop->AirToOANodeInfo(Count).OASysExists) {
    4693        1059 :             std::string ChrOut;
    4694        1059 :             std::string ChrOut2;
    4695        1059 :             if (state.dataAirLoop->AirToOANodeInfo(Count).OASysInletNodeNum > 0) {
    4696        1059 :                 ChrOut = fmt::to_string(state.dataAirLoop->AirToOANodeInfo(Count).OASysInletNodeNum);
    4697             :             } else {
    4698           0 :                 ChrOut = errstring;
    4699             :             }
    4700        1059 :             if (state.dataAirLoop->AirToOANodeInfo(Count).OASysOutletNodeNum > 0) {
    4701        1059 :                 ChrOut2 = fmt::to_string(state.dataAirLoop->AirToOANodeInfo(Count).OASysOutletNodeNum);
    4702             :             } else {
    4703           0 :                 ChrOut2 = errstring;
    4704             :             }
    4705             : 
    4706        1059 :             print(state.files.bnd, "   Outdoor Air Connections,{},", ChrOut);
    4707        1059 :             if (ChrOut != errstring) {
    4708        1059 :                 print(state.files.bnd, "{},", NodeID(state.dataAirLoop->AirToOANodeInfo(Count).OASysInletNodeNum));
    4709             :             } else {
    4710           0 :                 print(state.files.bnd, "{},", errstring);
    4711             :             }
    4712        1059 :             if (ChrOut2 != errstring) {
    4713        1059 :                 print(state.files.bnd,
    4714             :                       "{},{},{}\n",
    4715             :                       ChrOut2,
    4716        1059 :                       NodeID(state.dataAirLoop->AirToOANodeInfo(Count).OASysOutletNodeNum),
    4717        1059 :                       state.dataAirLoop->AirToZoneNodeInfo(Count).AirLoopName);
    4718             :             } else {
    4719           0 :                 print(state.files.bnd, "{},{},{}\n", errstring, errstring, state.dataAirLoop->AirToZoneNodeInfo(Count).AirLoopName);
    4720             :             }
    4721        1059 :         }
    4722             :         //  Report HVAC Air Loop Splitter to BND file
    4723        1207 :         if (state.dataAirSystemsData->PrimaryAirSystems(Count).Splitter.Exists) {
    4724           9 :             print(state.files.bnd,
    4725             :                   "   AirLoopHVAC Connector,Splitter,{},{},Air,{}\n",
    4726           9 :                   state.dataAirSystemsData->PrimaryAirSystems(Count).Splitter.Name,
    4727           9 :                   state.dataAirSystemsData->PrimaryAirSystems(Count).Name,
    4728           9 :                   state.dataAirSystemsData->PrimaryAirSystems(Count).Splitter.TotalOutletNodes);
    4729          27 :             for (int Count1 = 1; Count1 <= state.dataAirSystemsData->PrimaryAirSystems(Count).Splitter.TotalOutletNodes; ++Count1) {
    4730          18 :                 print(state.files.bnd,
    4731             :                       "     AirLoopHVAC Connector Branches,{},Splitter,{},",
    4732             :                       Count1,
    4733          18 :                       state.dataAirSystemsData->PrimaryAirSystems(Count).Splitter.Name);
    4734             : 
    4735          18 :                 if (state.dataAirSystemsData->PrimaryAirSystems(Count).Splitter.BranchNumIn <= 0) {
    4736           0 :                     print(state.files.bnd, "{},", errstring);
    4737             :                 } else {
    4738          18 :                     print(state.files.bnd,
    4739             :                           "{},",
    4740          18 :                           state.dataAirSystemsData->PrimaryAirSystems(Count)
    4741          18 :                               .Branch(state.dataAirSystemsData->PrimaryAirSystems(Count).Splitter.BranchNumIn)
    4742          18 :                               .Name);
    4743             :                 }
    4744             : 
    4745          18 :                 if (state.dataAirSystemsData->PrimaryAirSystems(Count).Splitter.BranchNumOut(Count1) <= 0) {
    4746           0 :                     print(state.files.bnd, "{},{},Air\n", errstring, state.dataAirSystemsData->PrimaryAirSystems(Count).Name);
    4747             :                 } else {
    4748          18 :                     print(state.files.bnd,
    4749             :                           "{},{},Air\n",
    4750          18 :                           state.dataAirSystemsData->PrimaryAirSystems(Count)
    4751          18 :                               .Branch(state.dataAirSystemsData->PrimaryAirSystems(Count).Splitter.BranchNumOut(Count1))
    4752          18 :                               .Name,
    4753          18 :                           state.dataAirSystemsData->PrimaryAirSystems(Count).Name);
    4754             :                 }
    4755             : 
    4756          18 :                 print(state.files.bnd,
    4757             :                       "     AirLoopHVAC Connector Nodes,   {},Splitter,{},{},{},{},Air\n",
    4758             :                       Count1,
    4759          18 :                       state.dataAirSystemsData->PrimaryAirSystems(Count).Splitter.Name,
    4760          18 :                       state.dataAirSystemsData->PrimaryAirSystems(Count).Splitter.NodeNameIn,
    4761          18 :                       state.dataAirSystemsData->PrimaryAirSystems(Count).Splitter.NodeNameOut(Count1),
    4762          18 :                       state.dataAirSystemsData->PrimaryAirSystems(Count).Name);
    4763             :             }
    4764             :         }
    4765             :     }
    4766         795 : }
    4767             : 
    4768         794 : void reportAirLoopToplogy(EnergyPlusData &state)
    4769             : {
    4770             :     // s->pdstTopAirLoop = newPreDefSubTable(state, s->pdrTopology, "Air Loop Supply Side Component Arrangement");
    4771             :     // s->pdchTopAirLoopName = newPreDefColumn(state, s->pdstTopAirLoop, "Airloop Name");
    4772             :     // s->pdchTopAirSplitName = newPreDefColumn(state, s->pdstTopAirLoop, "Splitter Name");
    4773             :     // s->pdchTopAirBranchName = newPreDefColumn(state, s->pdstTopAirLoop, "Supply Branch Name");
    4774             :     // s->pdchTopAirSupplyBranchType = newPreDefColumn(state, s->pdstTopAirLoop, "Supply Branch Type");
    4775             :     // s->pdchTopAirCompType = newPreDefColumn(state, s->pdstTopAirLoop, "Component Type");
    4776             :     // s->pdchTopAirCompName = newPreDefColumn(state, s->pdstTopAirLoop, "Component Name");
    4777             :     // s->pdchTopAirSubCompType = newPreDefColumn(state, s->pdstTopAirLoop, "Sub-Component Type");
    4778             :     // s->pdchTopAirSubCompName = newPreDefColumn(state, s->pdstTopAirLoop, "Sub-Component Name");
    4779             :     // s->pdchTopAirSubSubCompType = newPreDefColumn(state, s->pdstTopAirLoop, "Sub-Sub-Component Type");
    4780             :     // s->pdchTopAirSubSubCompName = newPreDefColumn(state, s->pdstTopAirLoop, "Sub-Sub-Component Name");
    4781             :     // s->pdchTopAirMixName = newPreDefColumn(state, s->pdstTopAirLoop, "Mixer Name");
    4782             : 
    4783         794 :     auto &orp = state.dataOutRptPredefined;
    4784         794 :     int rowCounter = 1;
    4785        1996 :     for (int airLoopNum = 1; airLoopNum <= state.dataHVACGlobal->NumPrimaryAirSys; ++airLoopNum) {
    4786        1202 :         auto &pas = state.dataAirSystemsData->PrimaryAirSystems(airLoopNum);
    4787        1202 :         OutputReportPredefined::PreDefTableEntry(state, orp->pdchTopAirLoopName, format("{}", rowCounter), pas.Name);
    4788        1202 :         ++rowCounter;
    4789        2423 :         for (int BranchNum = 1; BranchNum <= pas.NumBranches; ++BranchNum) {
    4790        1221 :             auto &pasBranch = pas.Branch(BranchNum);
    4791        1221 :             if (pas.Splitter.Exists) {
    4792          57 :                 for (int outNum : pas.Splitter.BranchNumOut) {
    4793          47 :                     if (outNum == BranchNum) {
    4794          18 :                         OutputReportPredefined::PreDefTableEntry(state, orp->pdchTopAirSplitName, format("{}", rowCounter), pas.Splitter.Name);
    4795          18 :                         break;
    4796             :                     }
    4797             :                 }
    4798             :             }
    4799        4927 :             for (int CompNum = 1; CompNum <= pasBranch.TotalComponents; ++CompNum) {
    4800        3706 :                 auto &pasBranchComp = pasBranch.Comp(CompNum);
    4801        3706 :                 fillAirloopToplogyComponentRow(
    4802             :                     state, pas.Name, pasBranch.Name, pasBranch.DuctType, pasBranchComp.TypeOf, pasBranchComp.Name, rowCounter);
    4803        6891 :                 for (int SubCompNum = 1; SubCompNum <= pasBranchComp.NumSubComps; ++SubCompNum) {
    4804        3185 :                     auto &pasBranchSubComp = pasBranchComp.SubComp(SubCompNum);
    4805        3185 :                     OutputReportPredefined::PreDefTableEntry(state, orp->pdchTopAirSubCompType, format("{}", rowCounter), pasBranchSubComp.TypeOf);
    4806        3185 :                     OutputReportPredefined::PreDefTableEntry(state, orp->pdchTopAirSubCompName, format("{}", rowCounter), pasBranchSubComp.Name);
    4807        3185 :                     fillAirloopToplogyComponentRow(
    4808             :                         state, pas.Name, pasBranch.Name, pasBranch.DuctType, pasBranchComp.TypeOf, pasBranchComp.Name, rowCounter);
    4809        3218 :                     for (int SubSubCompNum = 1; SubSubCompNum <= pasBranchSubComp.NumSubSubComps; ++SubSubCompNum) {
    4810          33 :                         auto &pasBranchSubSubComp = pasBranchSubComp.SubSubComp(SubSubCompNum);
    4811          99 :                         OutputReportPredefined::PreDefTableEntry(
    4812          99 :                             state, orp->pdchTopAirSubCompType, format("{}", rowCounter), pasBranchSubComp.TypeOf);
    4813          33 :                         OutputReportPredefined::PreDefTableEntry(state, orp->pdchTopAirSubCompName, format("{}", rowCounter), pasBranchSubComp.Name);
    4814          99 :                         OutputReportPredefined::PreDefTableEntry(
    4815          99 :                             state, orp->pdchTopAirSubSubCompType, format("{}", rowCounter), pasBranchSubSubComp.TypeOf);
    4816          99 :                         OutputReportPredefined::PreDefTableEntry(
    4817          99 :                             state, orp->pdchTopAirSubSubCompName, format("{}", rowCounter), pasBranchSubSubComp.Name);
    4818          33 :                         fillAirloopToplogyComponentRow(
    4819             :                             state, pas.Name, pasBranch.Name, pasBranch.DuctType, pasBranchComp.TypeOf, pasBranchComp.Name, rowCounter);
    4820             :                     }
    4821             :                 }
    4822             :             }
    4823        1221 :             if (pas.Mixer.Exists) {
    4824           9 :                 for (int inNum : pas.Mixer.BranchNumIn) {
    4825           7 :                     if (inNum == BranchNum) {
    4826           2 :                         OutputReportPredefined::PreDefTableEntry(state, orp->pdchTopAirMixName, format("{}", rowCounter - 1), pas.Mixer.Name);
    4827           2 :                         break;
    4828             :                     }
    4829             :                 }
    4830             :             }
    4831             :         }
    4832             :     }
    4833             : 
    4834             :     // s->pdstTopAirDemand = newPreDefSubTable(state, s->pdrTopology, "Air Loop Demand Side Component Arrangement");
    4835             :     // s->pdchTopAirDemandName = newPreDefColumn(state, s->pdstTopAirDemand, "Airloop Name");
    4836             :     // s->pdchTopAirSupplyBranchName = newPreDefColumn(state, s->pdstTopAirDemand, "Supply Branch Name");
    4837             :     // s->pdchTopAirSupplyPCompType = newPreDefColumn(state, s->pdstTopAirDemand, "Supply Path Component Type");
    4838             :     // s->pdchTopAirSupplyPCompName = newPreDefColumn(state, s->pdstTopAirDemand, "Supply Path Component Name");
    4839             :     // s->pdchTopAirZoneName = newPreDefColumn(state, s->pdstTopAirDemand, "Zone Name");
    4840             :     // s->pdchTopAirTermUnitType = newPreDefColumn(state, s->pdstTopAirDemand, "Terminal Unit Type");
    4841             :     // s->pdchTopAirTermUnitName = newPreDefColumn(state, s->pdstTopAirDemand, "Terminal Unit Name");
    4842             :     // s->pdchTopAirReturnPCompType = newPreDefColumn(state, s->pdstTopAirDemand, "Return Path Component Type");
    4843             :     // s->pdchTopAirReturnPCompName = newPreDefColumn(state, s->pdstTopAirDemand, "Return Path Component Name");
    4844             : 
    4845         794 :     rowCounter = 1;
    4846        1996 :     for (int airLoopNum = 1; airLoopNum <= state.dataHVACGlobal->NumPrimaryAirSys; ++airLoopNum) {
    4847        1202 :         auto &pas = state.dataAirSystemsData->PrimaryAirSystems(airLoopNum);
    4848        1202 :         auto &thisAtoZInfo = state.dataAirLoop->AirToZoneNodeInfo(airLoopNum);
    4849        1202 :         OutputReportPredefined::PreDefTableEntry(state, orp->pdchTopAirDemandName, format("{}", rowCounter), thisAtoZInfo.AirLoopName);
    4850        1202 :         ++rowCounter;
    4851        2412 :         for (int ductNum = 1; ductNum <= thisAtoZInfo.NumSupplyNodes; ++ductNum) {
    4852        1210 :             auto &thisBranch = pas.Branch(thisAtoZInfo.SupplyDuctBranchNum(ductNum));
    4853        1210 :             if (thisAtoZInfo.SupplyAirPathNum(ductNum) > 0) {
    4854        1206 :                 auto &thisSupplyPath = state.dataZoneEquip->SupplyAirPath(thisAtoZInfo.SupplyAirPathNum(ductNum));
    4855        2419 :                 for (int compNum = 1; compNum <= thisSupplyPath.NumOfComponents; ++compNum) {
    4856        1213 :                     OutputReportPredefined::PreDefTableEntry(state, orp->pdchTopAirDemandName, format("{}", rowCounter), thisAtoZInfo.AirLoopName);
    4857        1213 :                     OutputReportPredefined::PreDefTableEntry(state, orp->pdchTopAirSupplyBranchName, format("{}", rowCounter), thisBranch.Name);
    4858        2426 :                     OutputReportPredefined::PreDefTableEntry(
    4859        3639 :                         state, orp->pdchTopAirSupplyDuctType, format("{}", rowCounter), HVAC::airDuctTypeNames[(int)thisBranch.DuctType]);
    4860        2426 :                     OutputReportPredefined::PreDefTableEntry(
    4861        3639 :                         state, orp->pdchTopAirSupplyPCompType, format("{}", rowCounter), thisSupplyPath.ComponentType(compNum));
    4862        2426 :                     OutputReportPredefined::PreDefTableEntry(
    4863        3639 :                         state, orp->pdchTopAirSupplyPCompName, format("{}", rowCounter), thisSupplyPath.ComponentName(compNum));
    4864        1213 :                     ++rowCounter;
    4865             :                 }
    4866        1206 :                 if (thisBranch.DuctType == HVAC::AirDuctType::Cooling || thisBranch.DuctType == HVAC::AirDuctType::Main) {
    4867        4848 :                     for (int zoneNum : thisAtoZInfo.CoolCtrlZoneNums) {
    4868        3650 :                         auto &thisZoneEquipConfig = state.dataZoneEquip->ZoneEquipConfig(zoneNum);
    4869        3650 :                         auto &zel = state.dataZoneEquip->ZoneEquipList(zoneNum);
    4870        7550 :                         for (auto &thisCoolADU : thisZoneEquipConfig.AirDistUnitCool) {
    4871        3900 :                             if (thisCoolADU.SupplyBranchIndex != thisAtoZInfo.SupplyDuctBranchNum(ductNum)) continue;
    4872        3690 :                             if (thisCoolADU.SupplyAirPathExists) {
    4873        3690 :                                 int spCompNum = thisSupplyPath.OutletNodeSupplyPathCompNum(thisCoolADU.SupplyAirPathOutNodeIndex);
    4874        7380 :                                 OutputReportPredefined::PreDefTableEntry(
    4875       11070 :                                     state, orp->pdchTopAirSupplyPCompType, format("{}", rowCounter), thisSupplyPath.ComponentType(spCompNum));
    4876        7380 :                                 OutputReportPredefined::PreDefTableEntry(
    4877       11070 :                                     state, orp->pdchTopAirSupplyPCompName, format("{}", rowCounter), thisSupplyPath.ComponentName(spCompNum));
    4878             :                             }
    4879       11070 :                             OutputReportPredefined::PreDefTableEntry(
    4880       11070 :                                 state, orp->pdchTopAirDemandName, format("{}", rowCounter), thisAtoZInfo.AirLoopName);
    4881       11070 :                             OutputReportPredefined::PreDefTableEntry(
    4882       11070 :                                 state, orp->pdchTopAirSupplyBranchName, format("{}", rowCounter), thisBranch.Name);
    4883        7380 :                             OutputReportPredefined::PreDefTableEntry(
    4884       11070 :                                 state, orp->pdchTopAirSupplyDuctType, format("{}", rowCounter), HVAC::airDuctTypeNames[(int)thisBranch.DuctType]);
    4885       11070 :                             OutputReportPredefined::PreDefTableEntry(
    4886       11070 :                                 state, orp->pdchTopAirZoneName, format("{}", rowCounter), thisZoneEquipConfig.ZoneName);
    4887        3690 :                             auto &aduIndex = zel.EquipIndex(thisCoolADU.AirDistUnitIndex);
    4888        7380 :                             OutputReportPredefined::PreDefTableEntry(state,
    4889        3690 :                                                                      orp->pdchTopAirTermUnitType,
    4890        7380 :                                                                      format("{}", rowCounter),
    4891        3690 :                                                                      state.dataDefineEquipment->AirDistUnit(aduIndex).EquipType(1));
    4892        7380 :                             OutputReportPredefined::PreDefTableEntry(state,
    4893        3690 :                                                                      orp->pdchTopAirTermUnitName,
    4894        7380 :                                                                      format("{}", rowCounter),
    4895        3690 :                                                                      state.dataDefineEquipment->AirDistUnit(aduIndex).EquipName(1));
    4896        3690 :                             if (thisAtoZInfo.ReturnAirPathNum(1) > 0) {
    4897        3650 :                                 auto &thisReturnPath = state.dataZoneEquip->ReturnAirPath(thisAtoZInfo.ReturnAirPathNum(1));
    4898        3660 :                                 for (int retNodeNum = 1; retNodeNum <= thisZoneEquipConfig.NumReturnNodes; ++retNodeNum) {
    4899        3660 :                                     if (thisZoneEquipConfig.ReturnNodeAirLoopNum(retNodeNum) == airLoopNum) {
    4900        3650 :                                         int retPathCompNum = thisZoneEquipConfig.ReturnNodeRetPathCompNum(retNodeNum);
    4901        3650 :                                         if (retPathCompNum > 0) {
    4902        7300 :                                             OutputReportPredefined::PreDefTableEntry(state,
    4903        3650 :                                                                                      orp->pdchTopAirReturnPCompType,
    4904        7300 :                                                                                      format("{}", rowCounter),
    4905        3650 :                                                                                      thisReturnPath.ComponentType(retPathCompNum));
    4906        7300 :                                             OutputReportPredefined::PreDefTableEntry(state,
    4907        3650 :                                                                                      orp->pdchTopAirReturnPCompName,
    4908        7300 :                                                                                      format("{}", rowCounter),
    4909        3650 :                                                                                      thisReturnPath.ComponentName(retPathCompNum));
    4910             :                                         }
    4911        3650 :                                         break;
    4912             :                                     }
    4913             :                                 }
    4914             :                             }
    4915        3690 :                             ++rowCounter;
    4916             :                         }
    4917             :                     }
    4918        1206 :                 } else if (thisBranch.DuctType == HVAC::AirDuctType::Heating) {
    4919          37 :                     for (int zoneNum : thisAtoZInfo.HeatCtrlZoneNums) {
    4920          29 :                         auto &thisZoneEquipConfig = state.dataZoneEquip->ZoneEquipConfig(zoneNum);
    4921          29 :                         auto &zel = state.dataZoneEquip->ZoneEquipList(zoneNum);
    4922          58 :                         for (auto &thisHeatADU : thisZoneEquipConfig.AirDistUnitHeat) {
    4923          29 :                             if (thisHeatADU.SupplyBranchIndex != thisAtoZInfo.SupplyDuctBranchNum(ductNum)) continue;
    4924          29 :                             if (thisHeatADU.SupplyAirPathExists) {
    4925          29 :                                 int spCompNum = thisSupplyPath.OutletNodeSupplyPathCompNum(thisHeatADU.SupplyAirPathOutNodeIndex);
    4926          58 :                                 OutputReportPredefined::PreDefTableEntry(
    4927          87 :                                     state, orp->pdchTopAirSupplyPCompType, format("{}", rowCounter), thisSupplyPath.ComponentType(spCompNum));
    4928          58 :                                 OutputReportPredefined::PreDefTableEntry(
    4929          87 :                                     state, orp->pdchTopAirSupplyPCompName, format("{}", rowCounter), thisSupplyPath.ComponentName(spCompNum));
    4930             :                             }
    4931          87 :                             OutputReportPredefined::PreDefTableEntry(
    4932          87 :                                 state, orp->pdchTopAirDemandName, format("{}", rowCounter), thisAtoZInfo.AirLoopName);
    4933          87 :                             OutputReportPredefined::PreDefTableEntry(
    4934          87 :                                 state, orp->pdchTopAirSupplyBranchName, format("{}", rowCounter), thisBranch.Name);
    4935          58 :                             OutputReportPredefined::PreDefTableEntry(
    4936          87 :                                 state, orp->pdchTopAirSupplyDuctType, format("{}", rowCounter), HVAC::airDuctTypeNames[(int)thisBranch.DuctType]);
    4937          87 :                             OutputReportPredefined::PreDefTableEntry(
    4938          87 :                                 state, orp->pdchTopAirZoneName, format("{}", rowCounter), thisZoneEquipConfig.ZoneName);
    4939          29 :                             auto &aduIndex = zel.EquipIndex(thisHeatADU.AirDistUnitIndex);
    4940          58 :                             OutputReportPredefined::PreDefTableEntry(state,
    4941          29 :                                                                      orp->pdchTopAirTermUnitType,
    4942          58 :                                                                      format("{}", rowCounter),
    4943          29 :                                                                      state.dataDefineEquipment->AirDistUnit(aduIndex).EquipType(1));
    4944          58 :                             OutputReportPredefined::PreDefTableEntry(state,
    4945          29 :                                                                      orp->pdchTopAirTermUnitName,
    4946          58 :                                                                      format("{}", rowCounter),
    4947          29 :                                                                      state.dataDefineEquipment->AirDistUnit(aduIndex).EquipName(1));
    4948          29 :                             if (thisAtoZInfo.ReturnAirPathNum(1) > 0) {
    4949          29 :                                 auto &thisReturnPath = state.dataZoneEquip->ReturnAirPath(thisAtoZInfo.ReturnAirPathNum(1));
    4950          58 :                                 for (int retNodeNum = 1; retNodeNum <= thisZoneEquipConfig.NumReturnNodes; ++retNodeNum) {
    4951          29 :                                     int retPathCompNum = thisZoneEquipConfig.ReturnNodeRetPathCompNum(retNodeNum);
    4952          29 :                                     if (retPathCompNum > 0) {
    4953          58 :                                         OutputReportPredefined::PreDefTableEntry(state,
    4954          29 :                                                                                  orp->pdchTopAirReturnPCompType,
    4955          58 :                                                                                  format("{}", rowCounter),
    4956          29 :                                                                                  thisReturnPath.ComponentType(retPathCompNum));
    4957          58 :                                         OutputReportPredefined::PreDefTableEntry(state,
    4958          29 :                                                                                  orp->pdchTopAirReturnPCompName,
    4959          58 :                                                                                  format("{}", rowCounter),
    4960          29 :                                                                                  thisReturnPath.ComponentName(retPathCompNum));
    4961             :                                     }
    4962             :                                 }
    4963             :                             }
    4964          29 :                             ++rowCounter;
    4965             :                         }
    4966             :                     }
    4967             :                 }
    4968             : 
    4969             :             } else {
    4970           4 :                 OutputReportPredefined::PreDefTableEntry(state, orp->pdchTopAirDemandName, format("{}", rowCounter), thisAtoZInfo.AirLoopName);
    4971           4 :                 OutputReportPredefined::PreDefTableEntry(state, orp->pdchTopAirSupplyBranchName, format("{}", rowCounter), thisBranch.Name);
    4972           8 :                 OutputReportPredefined::PreDefTableEntry(
    4973          12 :                     state, orp->pdchTopAirSupplyDuctType, format("{}", rowCounter), HVAC::airDuctTypeNames[(int)thisBranch.DuctType]);
    4974           4 :                 ++rowCounter;
    4975             :             }
    4976             :         }
    4977        1202 :         if (thisAtoZInfo.ReturnAirPathNum(1) > 0) {
    4978        1189 :             auto &thisReturnPath = state.dataZoneEquip->ReturnAirPath(thisAtoZInfo.ReturnAirPathNum(1));
    4979        2493 :             for (int compNum = 1; compNum <= thisReturnPath.NumOfComponents; ++compNum) {
    4980        1304 :                 OutputReportPredefined::PreDefTableEntry(state, orp->pdchTopAirDemandName, format("{}", rowCounter), thisAtoZInfo.AirLoopName);
    4981        1304 :                 if (compNum == thisReturnPath.OutletRetPathCompNum) {
    4982        1189 :                     auto &thisBranch = pas.Branch(pas.InletBranchNum[0]);
    4983        1189 :                     OutputReportPredefined::PreDefTableEntry(state, orp->pdchTopAirSupplyBranchName, format("{}", rowCounter), thisBranch.Name);
    4984        2378 :                     OutputReportPredefined::PreDefTableEntry(
    4985        3567 :                         state, orp->pdchTopAirSupplyDuctType, format("{}", rowCounter), HVAC::airDuctTypeNames[(int)thisBranch.DuctType]);
    4986             :                 }
    4987        2608 :                 OutputReportPredefined::PreDefTableEntry(
    4988        3912 :                     state, orp->pdchTopAirReturnPCompType, format("{}", rowCounter), thisReturnPath.ComponentType(compNum));
    4989        2608 :                 OutputReportPredefined::PreDefTableEntry(
    4990        3912 :                     state, orp->pdchTopAirReturnPCompName, format("{}", rowCounter), thisReturnPath.ComponentName(compNum));
    4991        1304 :                 ++rowCounter;
    4992             :             }
    4993             :         }
    4994             :     }
    4995         794 : }
    4996             : 
    4997        6924 : void fillAirloopToplogyComponentRow(EnergyPlusData &state,
    4998             :                                     const std::string_view &loopName,
    4999             :                                     const std::string_view &branchName,
    5000             :                                     const HVAC::AirDuctType ductType,
    5001             :                                     const std::string_view &compType,
    5002             :                                     const std::string_view &compName,
    5003             :                                     int &rowCounter)
    5004             : {
    5005        6924 :     auto &orp = state.dataOutRptPredefined;
    5006             :     // s->pdchTopAirLoopName = newPreDefColumn(state, s->pdstTopAirLoop, "Airloop Name");
    5007             :     // s->pdchTopAirBranchName = newPreDefColumn(state, s->pdstTopAirLoop, "Branch Name");
    5008             :     // s->pdchTopAirCompType = newPreDefColumn(state, s->pdstTopAirLoop, "Component Type");
    5009             :     // s->pdchTopAirCompName = newPreDefColumn(state, s->pdstTopAirLoop, "Component Name");
    5010        6924 :     OutputReportPredefined::PreDefTableEntry(state, orp->pdchTopAirLoopName, format("{}", rowCounter), loopName);
    5011        6924 :     OutputReportPredefined::PreDefTableEntry(state, orp->pdchTopAirBranchName, format("{}", rowCounter), branchName);
    5012        6924 :     OutputReportPredefined::PreDefTableEntry(state, orp->pdchTopAirSupplyBranchType, format("{}", rowCounter), HVAC::airDuctTypeNames[(int)ductType]);
    5013        6924 :     OutputReportPredefined::PreDefTableEntry(state, orp->pdchTopAirCompType, format("{}", rowCounter), compType);
    5014        6924 :     OutputReportPredefined::PreDefTableEntry(state, orp->pdchTopAirCompName, format("{}", rowCounter), compName);
    5015        6924 :     ++rowCounter;
    5016        6924 : }
    5017             : 
    5018         794 : void reportZoneEquipmentToplogy(EnergyPlusData &state)
    5019             : {
    5020             :     // s->pdstTopZnEqp = newPreDefSubTable(state, s->pdrTopology, "Zone Equipment Component Arrangement");
    5021             :     // s->pdchTopZnEqpName = newPreDefColumn(state, s->pdstTopZnEqp, "Zone Name");
    5022             :     // s->pdchTopZnEqpCompType = newPreDefColumn(state, s->pdstTopZnEqp, "Component Type");
    5023             :     // s->pdchTopZnEqpCompName = newPreDefColumn(state, s->pdstTopZnEqp, "Component Name");
    5024             :     // s->pdchTopZnEqpSubCompType = newPreDefColumn(state, s->pdstTopZnEqp, "Sub-Component Type");
    5025             :     // s->pdchTopZnEqpSubCompName = newPreDefColumn(state, s->pdstTopZnEqp, "Sub-Component Name");
    5026             :     // s->pdchTopZnEqpSubSubCompType = newPreDefColumn(state, s->pdstTopZnEqp, "Sub-Sub-Component Type");
    5027             :     // s->pdchTopZnEqpSubSubCompName = newPreDefColumn(state, s->pdstTopZnEqp, "Sub-Sub-Component Name");
    5028             : 
    5029         794 :     auto &orp = state.dataOutRptPredefined;
    5030         794 :     int rowCounter = 1;
    5031        5838 :     for (int zoneNum = 1; zoneNum <= state.dataGlobal->NumOfZones; ++zoneNum) {
    5032        5044 :         const std::string_view zoneName = state.dataHeatBal->Zone(zoneNum).Name;
    5033        5044 :         OutputReportPredefined::PreDefTableEntry(state, orp->pdchTopZnEqpName, format("{}", rowCounter), zoneName);
    5034        5044 :         ++rowCounter;
    5035        5044 :         if (!state.dataZoneEquip->ZoneEquipConfig(zoneNum).IsControlled) continue;
    5036        4309 :         auto &zel = state.dataZoneEquip->ZoneEquipList(zoneNum);
    5037        9197 :         for (int CompNum = 1; CompNum <= zel.NumOfEquipTypes; ++CompNum) {
    5038        4888 :             auto &zelEquipData = zel.EquipData(CompNum);
    5039        4888 :             fillZoneEquipToplogyComponentRow(state, zoneName, zelEquipData.TypeOf, zelEquipData.Name, rowCounter);
    5040       10770 :             for (int SubCompNum = 1; SubCompNum <= zelEquipData.NumSubEquip; ++SubCompNum) {
    5041        5882 :                 auto &zelSubEquipData = zelEquipData.SubEquipData(SubCompNum);
    5042        5882 :                 OutputReportPredefined::PreDefTableEntry(state, orp->pdchTopZnEqpSubCompType, format("{}", rowCounter), zelSubEquipData.TypeOf);
    5043        5882 :                 OutputReportPredefined::PreDefTableEntry(state, orp->pdchTopZnEqpSubCompName, format("{}", rowCounter), zelSubEquipData.Name);
    5044        5882 :                 fillZoneEquipToplogyComponentRow(state, zoneName, zelEquipData.TypeOf, zelEquipData.Name, rowCounter);
    5045        8551 :                 for (int SubSubCompNum = 1; SubSubCompNum <= zelSubEquipData.NumSubSubEquip; ++SubSubCompNum) {
    5046        2669 :                     auto &zelSubSubEquipData = zelSubEquipData.SubSubEquipData(SubSubCompNum);
    5047        2669 :                     OutputReportPredefined::PreDefTableEntry(state, orp->pdchTopZnEqpSubCompType, format("{}", rowCounter), zelSubEquipData.TypeOf);
    5048        2669 :                     OutputReportPredefined::PreDefTableEntry(state, orp->pdchTopZnEqpSubCompName, format("{}", rowCounter), zelSubEquipData.Name);
    5049        8007 :                     OutputReportPredefined::PreDefTableEntry(
    5050        8007 :                         state, orp->pdchTopZnEqpSubSubCompType, format("{}", rowCounter), zelSubSubEquipData.TypeOf);
    5051        8007 :                     OutputReportPredefined::PreDefTableEntry(
    5052        8007 :                         state, orp->pdchTopZnEqpSubSubCompName, format("{}", rowCounter), zelSubSubEquipData.Name);
    5053        2669 :                     fillZoneEquipToplogyComponentRow(state, zoneName, zelEquipData.TypeOf, zelEquipData.Name, rowCounter);
    5054             :                 }
    5055             :             }
    5056             :         }
    5057             :     }
    5058         794 : }
    5059             : 
    5060       13439 : void fillZoneEquipToplogyComponentRow(
    5061             :     EnergyPlusData &state, const std::string_view &zoneName, const std::string_view &compType, const std::string_view &compName, int &rowCounter)
    5062             : {
    5063       13439 :     auto &orp = state.dataOutRptPredefined;
    5064             :     // s->pdstTopZnEqp = newPreDefSubTable(state, s->pdrTopology, "Zone Equipment Component Arrangement");
    5065             :     // s->pdchTopZnEqpName = newPreDefColumn(state, s->pdstTopZnEqp, "Zone Name");
    5066             :     // s->pdchTopZnEqpCompType = newPreDefColumn(state, s->pdstTopZnEqp, "Component Type");
    5067             :     // s->pdchTopZnEqpCompName = newPreDefColumn(state, s->pdstTopZnEqp, "Component Name");
    5068       13439 :     OutputReportPredefined::PreDefTableEntry(state, orp->pdchTopZnEqpName, format("{}", rowCounter), zoneName);
    5069       13439 :     OutputReportPredefined::PreDefTableEntry(state, orp->pdchTopZnEqpCompType, format("{}", rowCounter), compType);
    5070       13439 :     OutputReportPredefined::PreDefTableEntry(state, orp->pdchTopZnEqpCompName, format("{}", rowCounter), compName);
    5071       13439 :     ++rowCounter;
    5072       13439 : }
    5073             : 
    5074         794 : void reportAirDistributionUnits(EnergyPlusData &state)
    5075             : {
    5076             :     // populate the predefined tabular report for Equipment Summary - Air Terminals
    5077             : 
    5078         794 :     auto &orp = state.dataOutRptPredefined;
    5079        4448 :     for (auto &adu : state.dataDefineEquipment->AirDistUnit) {
    5080        3654 :         auto &airTerminal = adu.airTerminalPtr;
    5081        3654 :         constexpr int aduCompNum = 1;
    5082        3654 :         OutputReportPredefined::PreDefTableEntry(state, orp->pdchAirTermZoneName, adu.Name, state.dataHeatBal->Zone(adu.ZoneNum).Name);
    5083        3654 :         switch (adu.EquipTypeEnum(aduCompNum)) {
    5084          34 :         case DataDefineEquip::ZnAirLoopEquipType::DualDuctConstVolume:
    5085             :         case DataDefineEquip::ZnAirLoopEquipType::DualDuctVAV:
    5086             :         case DataDefineEquip::ZnAirLoopEquipType::DualDuctVAVOutdoorAir:
    5087          34 :             state.dataDualDuct->dd_airterminal(adu.EquipIndex(aduCompNum)).reportTerminalUnit(state);
    5088          34 :             break;
    5089        3455 :         case DataDefineEquip::ZnAirLoopEquipType::SingleDuctConstVolReheat:
    5090             :         case DataDefineEquip::ZnAirLoopEquipType::SingleDuctConstVolNoReheat:
    5091             :         case DataDefineEquip::ZnAirLoopEquipType::SingleDuctVAVReheat:
    5092             :         case DataDefineEquip::ZnAirLoopEquipType::SingleDuctVAVNoReheat:
    5093             :         case DataDefineEquip::ZnAirLoopEquipType::SingleDuctVAVReheatVSFan:
    5094             :         case DataDefineEquip::ZnAirLoopEquipType::SingleDuctCBVAVReheat:
    5095             :         case DataDefineEquip::ZnAirLoopEquipType::SingleDuctCBVAVNoReheat:
    5096        3455 :             state.dataSingleDuct->sd_airterminal(adu.EquipIndex(aduCompNum)).reportTerminalUnit(state);
    5097        3455 :             break;
    5098          57 :         case DataDefineEquip::ZnAirLoopEquipType::SingleDuct_SeriesPIU_Reheat:
    5099             :         case DataDefineEquip::ZnAirLoopEquipType::SingleDuct_ParallelPIU_Reheat:
    5100          57 :             state.dataPowerInductionUnits->PIU(adu.EquipIndex(aduCompNum)).reportTerminalUnit(state);
    5101          57 :             break;
    5102           4 :         case DataDefineEquip::ZnAirLoopEquipType::SingleDuct_ConstVol_4PipeInduc:
    5103           4 :             state.dataHVACSingleDuctInduc->IndUnit(adu.EquipIndex(aduCompNum)).reportTerminalUnit(state);
    5104           4 :             break;
    5105           5 :         case DataDefineEquip::ZnAirLoopEquipType::SingleDuctConstVolCooledBeam:
    5106           5 :             state.dataHVACCooledBeam->CoolBeam(adu.EquipIndex(aduCompNum)).reportTerminalUnit(state);
    5107           5 :             break;
    5108          30 :         case DataDefineEquip::ZnAirLoopEquipType::SingleDuctConstVolFourPipeBeam:
    5109          30 :             adu.airTerminalPtr->reportTerminalUnit(state);
    5110          30 :             break;
    5111          69 :         case DataDefineEquip::ZnAirLoopEquipType::SingleDuctUserDefined:
    5112             :         case DataDefineEquip::ZnAirLoopEquipType::SingleDuctATMixer:
    5113          69 :             break;
    5114           0 :         default:
    5115           0 :             break;
    5116             :         } // end switch
    5117             :     }
    5118         794 : }
    5119             : 
    5120             : //        End of Reporting subroutines for the SimAir Module
    5121             : // *****************************************************************************
    5122             : 
    5123             : } // namespace EnergyPlus::SystemReports

Generated by: LCOV version 1.14