LCOV - code coverage report
Current view: top level - EnergyPlus - SystemReports.cc (source / functions) Coverage Total Hit
Test: lcov.output.filtered Lines: 63.1 % 2856 1803
Test Date: 2025-06-02 12:03:30 Functions: 81.8 % 22 18

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

Generated by: LCOV version 2.0-1