LCOV - code coverage report
Current view: top level - EnergyPlus - SystemReports.cc (source / functions) Hit Total Coverage
Test: lcov.output.filtered Lines: 2196 2649 82.9 %
Date: 2023-01-17 19:17:23 Functions: 16 19 84.2 %

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

Generated by: LCOV version 1.13