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

Generated by: LCOV version 2.0-1