LCOV - code coverage report
Current view: top level - EnergyPlus - ZoneEquipmentManager.cc (source / functions) Coverage Total Hit
Test: lcov.output.filtered Lines: 77.8 % 4390 3414
Test Date: 2025-06-02 07:23:51 Functions: 100.0 % 44 44

            Line data    Source code
       1              : // EnergyPlus, Copyright (c) 1996-2025, The Board of Trustees of the University of Illinois,
       2              : // The Regents of the University of California, through Lawrence Berkeley National Laboratory
       3              : // (subject to receipt of any required approvals from the U.S. Dept. of Energy), Oak Ridge
       4              : // National Laboratory, managed by UT-Battelle, Alliance for Sustainable Energy, LLC, and other
       5              : // contributors. All rights reserved.
       6              : //
       7              : // NOTICE: This Software was developed under funding from the U.S. Department of Energy and the
       8              : // U.S. Government consequently retains certain rights. As such, the U.S. Government has been
       9              : // granted for itself and others acting on its behalf a paid-up, nonexclusive, irrevocable,
      10              : // worldwide license in the Software to reproduce, distribute copies to the public, prepare
      11              : // derivative works, and perform publicly and display publicly, and to permit others to do so.
      12              : //
      13              : // Redistribution and use in source and binary forms, with or without modification, are permitted
      14              : // provided that the following conditions are met:
      15              : //
      16              : // (1) Redistributions of source code must retain the above copyright notice, this list of
      17              : //     conditions and the following disclaimer.
      18              : //
      19              : // (2) Redistributions in binary form must reproduce the above copyright notice, this list of
      20              : //     conditions and the following disclaimer in the documentation and/or other materials
      21              : //     provided with the distribution.
      22              : //
      23              : // (3) Neither the name of the University of California, Lawrence Berkeley National Laboratory,
      24              : //     the University of Illinois, U.S. Dept. of Energy nor the names of its contributors may be
      25              : //     used to endorse or promote products derived from this software without specific prior
      26              : //     written permission.
      27              : //
      28              : // (4) Use of EnergyPlus(TM) Name. If Licensee (i) distributes the software in stand-alone form
      29              : //     without changes from the version obtained under this License, or (ii) Licensee makes a
      30              : //     reference solely to the software portion of its product, Licensee must refer to the
      31              : //     software as "EnergyPlus version X" software, where "X" is the version number Licensee
      32              : //     obtained under this License and may not use a different name for the software. Except as
      33              : //     specifically required in this Section (4), Licensee shall not use in a company name, a
      34              : //     product name, in advertising, publicity, or other promotional activities any name, trade
      35              : //     name, trademark, logo, or other designation of "EnergyPlus", "E+", "e+" or confusingly
      36              : //     similar designation, without the U.S. Department of Energy's prior written consent.
      37              : //
      38              : // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR
      39              : // IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
      40              : // AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
      41              : // CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
      42              : // CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
      43              : // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
      44              : // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
      45              : // OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
      46              : // POSSIBILITY OF SUCH DAMAGE.
      47              : 
      48              : // C++ Headers
      49              : #include <algorithm>
      50              : #include <cmath>
      51              : #include <string>
      52              : 
      53              : // ObjexxFCL Headers
      54              : #include <ObjexxFCL/Array.functions.hh>
      55              : 
      56              : // EnergyPlus Headers
      57              : #include <AirflowNetwork/Solver.hpp>
      58              : #include <EnergyPlus/BaseboardElectric.hh>
      59              : #include <EnergyPlus/BaseboardRadiator.hh>
      60              : #include <EnergyPlus/ChilledCeilingPanelSimple.hh>
      61              : #include <EnergyPlus/CoolTower.hh>
      62              : #include <EnergyPlus/Data/EnergyPlusData.hh>
      63              : #include <EnergyPlus/DataAirLoop.hh>
      64              : #include <EnergyPlus/DataAirSystems.hh>
      65              : #include <EnergyPlus/DataContaminantBalance.hh>
      66              : #include <EnergyPlus/DataConvergParams.hh>
      67              : #include <EnergyPlus/DataDefineEquip.hh>
      68              : #include <EnergyPlus/DataEnvironment.hh>
      69              : #include <EnergyPlus/DataHVACGlobals.hh>
      70              : #include <EnergyPlus/DataHeatBalFanSys.hh>
      71              : #include <EnergyPlus/DataLoopNode.hh>
      72              : #include <EnergyPlus/DataRoomAirModel.hh>
      73              : #include <EnergyPlus/DataSurfaces.hh>
      74              : #include <EnergyPlus/DataZoneEquipment.hh>
      75              : #include <EnergyPlus/DisplayRoutines.hh>
      76              : #include <EnergyPlus/EMSManager.hh>
      77              : #include <EnergyPlus/EarthTube.hh>
      78              : #include <EnergyPlus/ElectricBaseboardRadiator.hh>
      79              : #include <EnergyPlus/EvaporativeCoolers.hh>
      80              : #include <EnergyPlus/ExhaustAirSystemManager.hh>
      81              : #include <EnergyPlus/FanCoilUnits.hh>
      82              : #include <EnergyPlus/Fans.hh>
      83              : #include <EnergyPlus/General.hh>
      84              : #include <EnergyPlus/HVACInterfaceManager.hh>
      85              : #include <EnergyPlus/HVACStandAloneERV.hh>
      86              : #include <EnergyPlus/HVACVariableRefrigerantFlow.hh>
      87              : #include <EnergyPlus/HWBaseboardRadiator.hh>
      88              : #include <EnergyPlus/HeatRecovery.hh>
      89              : #include <EnergyPlus/HighTempRadiantSystem.hh>
      90              : #include <EnergyPlus/HybridUnitaryAirConditioners.hh>
      91              : #include <EnergyPlus/InternalHeatGains.hh>
      92              : #include <EnergyPlus/LowTempRadiantSystem.hh>
      93              : #include <EnergyPlus/OutdoorAirUnit.hh>
      94              : #include <EnergyPlus/Psychrometrics.hh>
      95              : #include <EnergyPlus/PurchasedAirManager.hh>
      96              : #include <EnergyPlus/RefrigeratedCase.hh>
      97              : #include <EnergyPlus/ReturnAirPathManager.hh>
      98              : #include <EnergyPlus/ScheduleManager.hh>
      99              : #include <EnergyPlus/SplitterComponent.hh>
     100              : #include <EnergyPlus/SteamBaseboardRadiator.hh>
     101              : #include <EnergyPlus/SystemAvailabilityManager.hh>
     102              : #include <EnergyPlus/ThermalChimney.hh>
     103              : #include <EnergyPlus/UnitHeater.hh>
     104              : #include <EnergyPlus/UnitVentilator.hh>
     105              : #include <EnergyPlus/UserDefinedComponents.hh>
     106              : #include <EnergyPlus/UtilityRoutines.hh>
     107              : #include <EnergyPlus/VentilatedSlab.hh>
     108              : #include <EnergyPlus/WaterThermalTanks.hh>
     109              : #include <EnergyPlus/WindowAC.hh>
     110              : #include <EnergyPlus/ZoneAirLoopEquipmentManager.hh>
     111              : #include <EnergyPlus/ZoneDehumidifier.hh>
     112              : #include <EnergyPlus/ZoneEquipmentManager.hh>
     113              : #include <EnergyPlus/ZonePlenum.hh>
     114              : #include <EnergyPlus/ZoneTempPredictorCorrector.hh>
     115              : 
     116              : namespace EnergyPlus::ZoneEquipmentManager {
     117              : 
     118              : // Module containing the routines dealing with the Zone Equipment Manager.
     119              : 
     120              : // MODULE INFORMATION:
     121              : //       AUTHOR         Russ Taylor
     122              : //       DATE WRITTEN   Unknown
     123              : //       MODIFIED       na
     124              : //       RE-ENGINEERED  na
     125              : 
     126              : // PURPOSE OF THIS MODULE:
     127              : // This module manages the zone equipment.
     128              : 
     129              : // Using/Aliasing
     130              : using namespace DataSizing;
     131              : using namespace DataZoneEquipment;
     132              : // Use statements for access to subroutines in other modules
     133              : using Psychrometrics::PsyCpAirFnW;
     134              : using Psychrometrics::PsyHFnTdbW;
     135              : using Psychrometrics::PsyHgAirFnWTdb;
     136              : using Psychrometrics::PsyRhoAirFnPbTdbW;
     137              : using Psychrometrics::PsyWFnTdbRhPb;
     138              : using Psychrometrics::PsyWFnTdpPb;
     139              : 
     140      7587463 : void ManageZoneEquipment(EnergyPlusData &state,
     141              :                          bool const FirstHVACIteration,
     142              :                          bool &SimZone, // Set to false at the end of the routine
     143              :                          bool &SimAir   // Eventually set to true via SimZoneEquipment if AirLoop must be resimulated
     144              : )
     145              : {
     146              : 
     147              :     // SUBROUTINE INFORMATION:
     148              :     //       AUTHOR         Russ Taylor
     149              :     //       DATE WRITTEN   May 1997
     150              : 
     151              :     // PURPOSE OF THIS SUBROUTINE:
     152              :     // Calls the zone thermal control simulations and the interfaces (water-air, refrigerant-air, steam-air, electric-electric, water-water, etc)
     153              : 
     154      7587463 :     InitZoneEquipment(state, FirstHVACIteration);
     155              : 
     156      7587463 :     if (state.dataGlobal->ZoneSizingCalc) {
     157      1044266 :         SizeZoneEquipment(state);
     158              :     } else {
     159      6543197 :         SimZoneEquipment(state, FirstHVACIteration, SimAir);
     160      6543197 :         state.dataZoneEquip->ZoneEquipSimulatedOnce = true;
     161              :     }
     162              : 
     163      7587463 :     UpdateZoneEquipment(state, SimAir);
     164              : 
     165      7587463 :     SimZone = false;
     166      7587463 : }
     167              : 
     168          801 : void GetZoneEquipment(EnergyPlusData &state)
     169              : {
     170              : 
     171              :     // SUBROUTINE INFORMATION:
     172              :     //       AUTHOR         Russ Taylor
     173              :     //       DATE WRITTEN   June 1997
     174              :     //       MODIFIED       Aug 2003, FCW: set ZoneEquipConfig number for each zone
     175              : 
     176              :     // PURPOSE OF THIS SUBROUTINE:
     177              :     // Get all the system related equipment which may be attached to a zone
     178              : 
     179          801 :     if (state.dataZoneEquipmentManager->GetZoneEquipmentInputFlag) {
     180          801 :         GetZoneEquipmentData(state);
     181          801 :         state.dataZoneEquipmentManager->GetZoneEquipmentInputFlag = false;
     182          801 :         state.dataZoneEquip->ZoneEquipInputsFilled = true;
     183              : 
     184          801 :         state.dataZoneEquipmentManager->NumOfTimeStepInDay = state.dataGlobal->TimeStepsInHour * Constant::iHoursInDay;
     185              : 
     186          801 :         int MaxNumOfEquipTypes = 0;
     187         6002 :         for (int Counter = 1; Counter <= state.dataGlobal->NumOfZones; ++Counter) {
     188         5201 :             if (!state.dataZoneEquip->ZoneEquipConfig(Counter).IsControlled) {
     189          740 :                 continue;
     190              :             }
     191         4461 :             MaxNumOfEquipTypes = max(MaxNumOfEquipTypes, state.dataZoneEquip->ZoneEquipList(Counter).NumOfEquipTypes);
     192              :         }
     193              : 
     194          801 :         state.dataZoneEquipmentManager->PrioritySimOrder.allocate(MaxNumOfEquipTypes);
     195              :     }
     196          801 : }
     197              : 
     198      7587463 : void InitZoneEquipment(EnergyPlusData &state, bool const FirstHVACIteration) // unused 1208
     199              : {
     200              : 
     201              :     // SUBROUTINE INFORMATION:
     202              :     //       AUTHOR         Russ Taylor
     203              :     //       DATE WRITTEN   Nov 1997
     204              : 
     205              :     // PURPOSE OF THIS SUBROUTINE:
     206              :     // This subroutine initializes the zone equipment prior to simulation.
     207              : 
     208      7587463 :     if (state.dataZoneEquipmentManager->InitZoneEquipmentOneTimeFlag) {
     209          801 :         state.dataZoneEquipmentManager->InitZoneEquipmentOneTimeFlag = false;
     210          801 :         state.dataSize->ZoneEqSizing.allocate(state.dataGlobal->NumOfZones);
     211              :         // setup zone equipment sequenced demand storage
     212         6002 :         for (int ControlledZoneNum = 1; ControlledZoneNum <= state.dataGlobal->NumOfZones; ++ControlledZoneNum) {
     213         5201 :             if (!state.dataZoneEquip->ZoneEquipConfig(ControlledZoneNum).IsControlled) {
     214          740 :                 continue;
     215              :             }
     216         4461 :             if (state.dataZoneEquip->ZoneEquipConfig(ControlledZoneNum).EquipListIndex == 0) {
     217            0 :                 continue;
     218              :             }
     219              :             int ZoneEquipCount =
     220         4461 :                 state.dataZoneEquip->ZoneEquipList(state.dataZoneEquip->ZoneEquipConfig(ControlledZoneNum).EquipListIndex).NumOfEquipTypes;
     221         4461 :             auto &thisZoneSysEnergyDemand = state.dataZoneEnergyDemand->ZoneSysEnergyDemand(ControlledZoneNum);
     222         4461 :             thisZoneSysEnergyDemand.NumZoneEquipment = ZoneEquipCount;
     223         4461 :             thisZoneSysEnergyDemand.SequencedOutputRequired.allocate(ZoneEquipCount);
     224         4461 :             thisZoneSysEnergyDemand.SequencedOutputRequiredToHeatingSP.allocate(ZoneEquipCount);
     225         4461 :             thisZoneSysEnergyDemand.SequencedOutputRequiredToCoolingSP.allocate(ZoneEquipCount);
     226         4461 :             auto &thisZoneSysMoistureDemand = state.dataZoneEnergyDemand->ZoneSysMoistureDemand(ControlledZoneNum);
     227         4461 :             thisZoneSysMoistureDemand.NumZoneEquipment = ZoneEquipCount;
     228         4461 :             thisZoneSysMoistureDemand.SequencedOutputRequired.allocate(ZoneEquipCount);
     229         4461 :             thisZoneSysMoistureDemand.SequencedOutputRequiredToHumidSP.allocate(ZoneEquipCount);
     230         4461 :             thisZoneSysMoistureDemand.SequencedOutputRequiredToDehumidSP.allocate(ZoneEquipCount);
     231         4461 :             state.dataSize->ZoneEqSizing(ControlledZoneNum).SizingMethod.allocate(HVAC::NumOfSizingTypes);
     232         4461 :             state.dataSize->ZoneEqSizing(ControlledZoneNum).SizingMethod = 0;
     233         4461 :             if (state.dataHeatBal->doSpaceHeatBalanceSimulation || state.dataHeatBal->doSpaceHeatBalanceSizing) {
     234           24 :                 for (int spaceNum : state.dataHeatBal->Zone(ControlledZoneNum).spaceIndexes) {
     235           14 :                     auto &thisSpaceSysEnergyDemand = state.dataZoneEnergyDemand->spaceSysEnergyDemand(spaceNum);
     236           14 :                     thisSpaceSysEnergyDemand.NumZoneEquipment = ZoneEquipCount;
     237           14 :                     thisSpaceSysEnergyDemand.SequencedOutputRequired.allocate(ZoneEquipCount);
     238           14 :                     thisSpaceSysEnergyDemand.SequencedOutputRequiredToHeatingSP.allocate(ZoneEquipCount);
     239           14 :                     thisSpaceSysEnergyDemand.SequencedOutputRequiredToCoolingSP.allocate(ZoneEquipCount);
     240           14 :                     auto &thisSpaceSysMoistureDemand = state.dataZoneEnergyDemand->spaceSysMoistureDemand(spaceNum);
     241           14 :                     thisSpaceSysMoistureDemand.NumZoneEquipment = ZoneEquipCount;
     242           14 :                     thisSpaceSysMoistureDemand.SequencedOutputRequired.allocate(ZoneEquipCount);
     243           14 :                     thisSpaceSysMoistureDemand.SequencedOutputRequiredToHumidSP.allocate(ZoneEquipCount);
     244           14 :                     thisSpaceSysMoistureDemand.SequencedOutputRequiredToDehumidSP.allocate(ZoneEquipCount);
     245           10 :                 }
     246              :             }
     247              :         }
     248              :     }
     249              : 
     250              :     // Do the Begin Environment initializations
     251      7587463 :     if (state.dataZoneEquipmentManager->InitZoneEquipmentEnvrnFlag && state.dataGlobal->BeginEnvrnFlag) {
     252              : 
     253         6496 :         state.dataZoneEquip->ZoneEquipAvail = Avail::Status::NoAction;
     254              : 
     255         6496 :         if (allocated(state.dataAvail->ZoneComp)) {
     256        90180 :             for (int ZoneEquipType = 1; ZoneEquipType <= NumValidSysAvailZoneComponents; ++ZoneEquipType) {
     257        84168 :                 if (allocated(state.dataAvail->ZoneComp(ZoneEquipType).ZoneCompAvailMgrs)) {
     258         1221 :                     auto &zoneComp = state.dataAvail->ZoneComp(ZoneEquipType);
     259         9366 :                     for (int ZoneCompNum = 1; ZoneCompNum <= zoneComp.TotalNumComp; ++ZoneCompNum) {
     260         8145 :                         zoneComp.ZoneCompAvailMgrs(ZoneCompNum).availStatus = Avail::Status::NoAction;
     261         8145 :                         zoneComp.ZoneCompAvailMgrs(ZoneCompNum).StartTime = 0;
     262         8145 :                         zoneComp.ZoneCompAvailMgrs(ZoneCompNum).StopTime = 0;
     263              :                     }
     264              :                 }
     265              :             }
     266              :         }
     267        57005 :         for (auto &thisZoneEquipConfig : state.dataZoneEquip->ZoneEquipConfig) {
     268        50509 :             if (!thisZoneEquipConfig.IsControlled) {
     269         6489 :                 continue;
     270              :             }
     271        44020 :             thisZoneEquipConfig.beginEnvirnInit(state);
     272              :         }
     273         6496 :         if (state.dataHeatBal->doSpaceHeatBalanceSimulation) {
     274          209 :             for (auto &thisSpaceEquipConfig : state.dataZoneEquip->spaceEquipConfig) {
     275          186 :                 if (!thisSpaceEquipConfig.IsControlled) {
     276          150 :                     continue;
     277              :                 }
     278           36 :                 thisSpaceEquipConfig.beginEnvirnInit(state);
     279              :             }
     280              :         }
     281              : 
     282         6496 :         state.dataZoneEquipmentManager->InitZoneEquipmentEnvrnFlag = false;
     283              :     }
     284              : 
     285      7587463 :     if (!state.dataGlobal->BeginEnvrnFlag) {
     286      7550943 :         state.dataZoneEquipmentManager->InitZoneEquipmentEnvrnFlag = true;
     287              :     }
     288              : 
     289              :     // do the  HVAC time step initializations
     290              : 
     291     69469467 :     for (auto &thisZoneEquipConfig : state.dataZoneEquip->ZoneEquipConfig) {
     292     61882004 :         if (!thisZoneEquipConfig.IsControlled) {
     293      8297777 :             continue;
     294              :         }
     295     53584227 :         thisZoneEquipConfig.hvacTimeStepInit(state, FirstHVACIteration);
     296              :     }
     297      7587463 :     if (state.dataHeatBal->doSpaceHeatBalanceSimulation) {
     298       138726 :         for (auto &thisSpaceEquipConfig : state.dataZoneEquip->spaceEquipConfig) {
     299       123624 :             if (!thisSpaceEquipConfig.IsControlled) {
     300        98865 :                 continue;
     301              :             }
     302        24759 :             thisSpaceEquipConfig.hvacTimeStepInit(state, FirstHVACIteration);
     303              :         }
     304              :     }
     305              : 
     306     19895297 :     for (int airLoop = 1; airLoop <= state.dataHVACGlobal->NumPrimaryAirSys; ++airLoop) {
     307     12307834 :         auto &airLoopFlow = state.dataAirLoop->AirLoopFlow(airLoop);
     308     12307834 :         airLoopFlow.SupFlow = 0.0;
     309     12307834 :         airLoopFlow.ZoneRetFlow = 0.0;
     310     12307834 :         airLoopFlow.SysRetFlow = 0.0;
     311     12307834 :         airLoopFlow.RecircFlow = 0.0;
     312     12307834 :         airLoopFlow.LeakFlow = 0.0;
     313     12307834 :         airLoopFlow.ExcessZoneExhFlow = 0.0;
     314              :     }
     315      7587463 : }
     316      9608696 : void sizeZoneSpaceEquipmentPart1(EnergyPlusData &state,
     317              :                                  DataZoneEquipment::EquipConfiguration &zoneEquipConfig,
     318              :                                  DataSizing::ZoneSizingData &zsCalcSizing,
     319              :                                  DataZoneEnergyDemands::ZoneSystemSensibleDemand &zsEnergyDemand,
     320              :                                  DataZoneEnergyDemands::ZoneSystemMoistureDemand &zsMoistureDemand,
     321              :                                  DataHeatBalance::ZoneData const &zoneOrSpace,
     322              :                                  int zoneNum,
     323              :                                  int spaceNum)
     324              : {
     325              :     static constexpr std::string_view RoutineName("sizeZoneSpaceEquipmentPart1");
     326              :     // set up references for space vs zoneHeatBalance
     327        50212 :     auto &nonAirSystemResponse = (spaceNum > 0) ? state.dataZoneTempPredictorCorrector->spaceHeatBalance(spaceNum).NonAirSystemResponse
     328      9658908 :                                                 : state.dataZoneTempPredictorCorrector->zoneHeatBalance(zoneNum).NonAirSystemResponse;
     329        50212 :     auto &sysDepZoneLoads = (spaceNum > 0) ? state.dataZoneTempPredictorCorrector->spaceHeatBalance(spaceNum).SysDepZoneLoads
     330      9658908 :                                            : state.dataZoneTempPredictorCorrector->zoneHeatBalance(zoneNum).SysDepZoneLoads;
     331              :     auto &zoneNodeNum =
     332      9608696 :         (spaceNum > 0) ? state.dataHeatBal->space(spaceNum).SystemZoneNodeNumber : state.dataHeatBal->Zone(zoneNum).SystemZoneNodeNumber;
     333      9608696 :     nonAirSystemResponse = 0.0;
     334      9608696 :     sysDepZoneLoads = 0.0;
     335      9608696 :     auto &zoneNode = state.dataLoopNodes->Node(zoneNodeNum);
     336              : 
     337              :     // InitSystemOutputRequired(state, zoneNum, true);
     338      9608696 :     initOutputRequired(state, zoneNum, zsEnergyDemand, zsMoistureDemand, true, false, spaceNum);
     339              : 
     340              :     // save raw zone loads without impact of outdoor air
     341      9608696 :     Real64 LatOutputProvidedNoDOAS = zsMoistureDemand.RemainingOutputRequired;
     342      9608696 :     Real64 SysOutputProvidedNoDOAS = zsEnergyDemand.RemainingOutputRequired;
     343              :     // if Tstat deadband is true then load will be reported as 0
     344      9608696 :     if (state.dataZoneEnergyDemand->DeadBandOrSetback(zoneNum)) {
     345      1656338 :         SysOutputProvidedNoDOAS = 0.0;
     346              :     }
     347              :     // replicate deadband flag - zone condition is either below the humidistat or above the dehumidistat set point
     348              :     // using logic: NOT (!) (there is a load)
     349              :     // Pretty sure this could just be if (OutputRequiredToHumidifyingSP < 0 && OutputRequiredToDehumidifyingSP > 0)
     350      9608696 :     if (!((zsMoistureDemand.OutputRequiredToHumidifyingSP > 0.0 && zsMoistureDemand.OutputRequiredToDehumidifyingSP > 0.0) ||
     351      9487550 :           (zsMoistureDemand.OutputRequiredToHumidifyingSP < 0.0 && zsMoistureDemand.OutputRequiredToDehumidifyingSP < 0.0))) {
     352      9354017 :         LatOutputProvidedNoDOAS = 0.0;
     353              :     }
     354              : 
     355              :     // calculate DOAS heating/cooling effect
     356      9608696 :     int supplyAirNodeNum = 0;
     357      9608696 :     if (zsCalcSizing.AccountForDOAS) {
     358       239316 :         Real64 DOASMassFlowRate = 0.0;         // DOAS air mass flow rate for sizing [kg/s]
     359       239316 :         Real64 DOASSupplyTemp = 0.0;           // DOAS supply air temperature [C]
     360       239316 :         Real64 DOASSupplyHumRat = 0.0;         // DOAS supply air humidity ratio [kgWater/kgDryAir]
     361       239316 :         Real64 DOASCpAir = 0.0;                // heat capacity of DOAS air [J/kg-C]
     362       239316 :         Real64 DOASSysOutputProvided = 0.0;    // heating / cooling provided by DOAS system [W]
     363       239316 :         Real64 DOASLatOutputProvided = 0.0;    // DOAS system latent output [kg/s]
     364       239316 :         Real64 TotDOASSysOutputProvided = 0.0; // total DOAS load on the zone [W]
     365       239316 :         Real64 HR90H = 0.0;                    // humidity ratio at DOAS high setpoint temperature and 90% relative humidity [kg Water / kg Dry Air]
     366       239316 :         Real64 HR90L = 0.0;                    // humidity ratio at DOAS low setpoint temperature and 90% relative humidity [kg Water / kg Dry Air]
     367              :         // check for adequate number of supply nodes
     368       239316 :         int supplyAirNodeNum1 = 0;
     369       239316 :         int supplyAirNodeNum2 = 0;
     370       239316 :         if (zoneEquipConfig.NumInletNodes >= 2) {
     371       193040 :             supplyAirNodeNum1 = zoneEquipConfig.InletNode(1);
     372       193040 :             supplyAirNodeNum2 = zoneEquipConfig.InletNode(2);
     373        46276 :         } else if (zoneEquipConfig.NumInletNodes >= 1) {
     374        46276 :             supplyAirNodeNum1 = zoneEquipConfig.InletNode(1);
     375        46276 :             supplyAirNodeNum2 = 0;
     376              :         } else {
     377            0 :             ShowSevereError(state, format("{}: to account for the effect a Dedicated Outside Air System on zone equipment sizing", RoutineName));
     378            0 :             ShowContinueError(state, "there must be at least one zone air inlet node");
     379            0 :             ShowFatalError(state, "Previous severe error causes abort ");
     380              :         }
     381              :         // set the DOAS mass flow rate and supply temperature and humidity ratio
     382       239316 :         HR90H = PsyWFnTdbRhPb(state, zsCalcSizing.DOASHighSetpoint, 0.9, state.dataEnvrn->StdBaroPress);
     383       239316 :         HR90L = PsyWFnTdbRhPb(state, zsCalcSizing.DOASLowSetpoint, 0.9, state.dataEnvrn->StdBaroPress);
     384       239316 :         DOASMassFlowRate = state.dataSize->CalcFinalZoneSizing(zoneNum).MinOA * state.dataEnvrn->StdRhoAir;
     385       239316 :         CalcDOASSupCondsForSizing(state,
     386       239316 :                                   state.dataEnvrn->OutDryBulbTemp,
     387       239316 :                                   state.dataEnvrn->OutHumRat,
     388              :                                   zsCalcSizing.DOASControlStrategy,
     389              :                                   zsCalcSizing.DOASLowSetpoint,
     390              :                                   zsCalcSizing.DOASHighSetpoint,
     391              :                                   HR90H,
     392              :                                   HR90L,
     393              :                                   DOASSupplyTemp,
     394              :                                   DOASSupplyHumRat);
     395       239316 :         DOASCpAir = PsyCpAirFnW(DOASSupplyHumRat);
     396       239316 :         DOASSysOutputProvided = DOASMassFlowRate * DOASCpAir * (DOASSupplyTemp - zoneNode.Temp);
     397       239316 :         TotDOASSysOutputProvided = DOASMassFlowRate * (PsyHFnTdbW(DOASSupplyTemp, DOASSupplyHumRat) - PsyHFnTdbW(zoneNode.Temp, zoneNode.HumRat));
     398       239316 :         if (zsCalcSizing.zoneLatentSizing) {
     399            0 :             DOASLatOutputProvided = DOASMassFlowRate * (DOASSupplyHumRat - zoneNode.HumRat); // kgw/s
     400              :         }
     401              : 
     402       239316 :         updateSystemOutputRequired(state, zoneNum, DOASSysOutputProvided, DOASLatOutputProvided, zsEnergyDemand, zsMoistureDemand);
     403       239316 :         auto &supplyAirNode1 = state.dataLoopNodes->Node(supplyAirNodeNum1);
     404       239316 :         supplyAirNode1.Temp = DOASSupplyTemp;
     405       239316 :         supplyAirNode1.HumRat = DOASSupplyHumRat;
     406       239316 :         supplyAirNode1.MassFlowRate = DOASMassFlowRate;
     407       239316 :         supplyAirNode1.Enthalpy = PsyHFnTdbW(DOASSupplyTemp, DOASSupplyHumRat);
     408       239316 :         zsCalcSizing.DOASHeatAdd = DOASSysOutputProvided;
     409       239316 :         zsCalcSizing.DOASLatAdd = TotDOASSysOutputProvided - DOASSysOutputProvided;
     410       239316 :         supplyAirNodeNum = supplyAirNodeNum2;
     411       239316 :         zsCalcSizing.DOASSupMassFlow = DOASMassFlowRate;
     412       239316 :         zsCalcSizing.DOASSupTemp = DOASSupplyTemp;
     413       239316 :         zsCalcSizing.DOASSupHumRat = DOASSupplyHumRat;
     414       239316 :         if (DOASSysOutputProvided > 0.0) {
     415         3487 :             zsCalcSizing.DOASHeatLoad = DOASSysOutputProvided;
     416         3487 :             zsCalcSizing.DOASCoolLoad = 0.0;
     417         3487 :             zsCalcSizing.DOASTotCoolLoad = 0.0;
     418              :         } else {
     419       235829 :             zsCalcSizing.DOASCoolLoad = DOASSysOutputProvided;
     420       235829 :             zsCalcSizing.DOASTotCoolLoad = TotDOASSysOutputProvided;
     421       235829 :             zsCalcSizing.DOASHeatLoad = 0.0;
     422              :         }
     423              : 
     424              :     } else {
     425      9369380 :         if (zoneEquipConfig.NumInletNodes > 0) {
     426      9166849 :             supplyAirNodeNum = zoneEquipConfig.InletNode(1);
     427              :         } else {
     428       202531 :             supplyAirNodeNum = 0;
     429              :         }
     430              :     }
     431              : 
     432      9608696 :     Real64 DeltaTemp = 0.0;         // difference between supply air temp and zone temp [C]
     433      9608696 :     Real64 CpAir = 0.0;             // heat capacity of air [J/kg-C]
     434      9608696 :     Real64 SysOutputProvided = 0.0; // system sensible output [W]
     435      9608696 :     Real64 LatOutputProvided = 0.0; // system latent output [kg/s]
     436      9608696 :     Real64 Temp = 0.0;              // inlet temperature [C]
     437      9608696 :     Real64 HumRat = 0.0;            // inlet humidity ratio [kg water/kg dry air]
     438      9608696 :     Real64 Enthalpy = 0.0;          // inlet specific enthalpy [J/kg]
     439      9608696 :     Real64 MassFlowRate = 0.0;      // inlet mass flow rate [kg/s]
     440              :     // Sign convention: SysOutputProvided <0 Supply air is heated on entering zone (zone is cooled)
     441              :     //                  SysOutputProvided >0 Supply air is cooled on entering zone (zone is heated)
     442      9608696 :     if (!state.dataZoneEnergyDemand->DeadBandOrSetback(zoneNum) && std::abs(zsEnergyDemand.RemainingOutputRequired) > HVAC::SmallLoad) {
     443              :         // Determine design supply air temperature and design supply air temperature difference
     444      7941874 :         if (zsEnergyDemand.RemainingOutputRequired < 0.0) { // Cooling case
     445              :             // If the user specify the design cooling supply air temperature, then
     446      4199798 :             if (zsCalcSizing.ZnCoolDgnSAMethod == SupplyAirTemperature) {
     447      4118362 :                 Temp = zsCalcSizing.CoolDesTemp;
     448      4118362 :                 HumRat = zsCalcSizing.CoolDesHumRat;
     449      4118362 :                 DeltaTemp = Temp - zoneNode.Temp;
     450      4118362 :                 if (zoneOrSpace.HasAdjustedReturnTempByITE && !(state.dataGlobal->BeginSimFlag)) {
     451         2802 :                     DeltaTemp = Temp - zoneOrSpace.AdjustedReturnTempByITE;
     452              :                 }
     453              :                 // If the user specify the design cooling supply air temperature difference, then
     454              :             } else {
     455        81436 :                 DeltaTemp = -std::abs(zsCalcSizing.CoolDesTempDiff);
     456        81436 :                 Temp = DeltaTemp + zoneNode.Temp;
     457        81436 :                 if (zoneOrSpace.HasAdjustedReturnTempByITE && !(state.dataGlobal->BeginSimFlag)) {
     458            0 :                     Temp = DeltaTemp + zoneOrSpace.AdjustedReturnTempByITE;
     459              :                 }
     460        81436 :                 HumRat = zsCalcSizing.CoolDesHumRat;
     461              :             }
     462              :         } else { // Heating Case
     463              :             // If the user specify the design heating supply air temperature, then
     464      3742076 :             if (zsCalcSizing.ZnHeatDgnSAMethod == SupplyAirTemperature) {
     465      3634588 :                 Temp = zsCalcSizing.HeatDesTemp;
     466      3634588 :                 HumRat = zsCalcSizing.HeatDesHumRat;
     467      3634588 :                 DeltaTemp = Temp - zoneNode.Temp;
     468              :                 // If the user specify the design heating supply air temperature difference, then
     469              :             } else {
     470       107488 :                 DeltaTemp = std::abs(zsCalcSizing.HeatDesTempDiff);
     471       107488 :                 Temp = DeltaTemp + zoneNode.Temp;
     472       107488 :                 HumRat = zsCalcSizing.HeatDesHumRat;
     473              :             }
     474              :         }
     475              : 
     476      7941874 :         Enthalpy = PsyHFnTdbW(Temp, HumRat);
     477      7941874 :         SysOutputProvided = zsEnergyDemand.RemainingOutputRequired;
     478      7941874 :         CpAir = PsyCpAirFnW(HumRat);
     479      7941874 :         if (std::abs(DeltaTemp) > HVAC::SmallTempDiff) {
     480              :             //!!PH/WFB/LKL (UCDV model)        MassFlowRate = SysOutputProvided / (CpAir*DeltaTemp)
     481      7941874 :             MassFlowRate = max(SysOutputProvided / (CpAir * DeltaTemp), 0.0);
     482              :         } else {
     483            0 :             MassFlowRate = 0.0;
     484              :         }
     485              : 
     486      7941874 :         if (zsCalcSizing.SupplyAirAdjustFactor > 1.0) {
     487            0 :             MassFlowRate *= zsCalcSizing.SupplyAirAdjustFactor;
     488              :         }
     489              :     } else {
     490              : 
     491      1666822 :         Temp = zoneNode.Temp;
     492      1666822 :         HumRat = zoneNode.HumRat;
     493      1666822 :         Enthalpy = zoneNode.Enthalpy;
     494      1666822 :         MassFlowRate = 0.0;
     495              :     }
     496              : 
     497      9608696 :     if (SysOutputProvided > 0.0) {
     498      3742076 :         zsCalcSizing.HeatLoad = SysOutputProvided;
     499      3742076 :         zsCalcSizing.HeatMassFlow = MassFlowRate;
     500      3742076 :         zsCalcSizing.CoolLoad = 0.0;
     501      3742076 :         zsCalcSizing.CoolMassFlow = 0.0;
     502      5866620 :     } else if (SysOutputProvided < 0.0) {
     503      4199798 :         zsCalcSizing.CoolLoad = -SysOutputProvided;
     504      4199798 :         zsCalcSizing.CoolMassFlow = MassFlowRate;
     505      4199798 :         zsCalcSizing.HeatLoad = 0.0;
     506      4199798 :         zsCalcSizing.HeatMassFlow = 0.0;
     507              :     } else {
     508      1666822 :         zsCalcSizing.CoolLoad = 0.0;
     509      1666822 :         zsCalcSizing.CoolMassFlow = 0.0;
     510      1666822 :         zsCalcSizing.HeatLoad = 0.0;
     511      1666822 :         zsCalcSizing.HeatMassFlow = 0.0;
     512              :     }
     513      9608696 :     zsCalcSizing.HeatZoneTemp = zoneNode.Temp;
     514      9608696 :     zsCalcSizing.HeatZoneHumRat = zoneNode.HumRat;
     515      9608696 :     zsCalcSizing.CoolZoneTemp = zoneNode.Temp;
     516      9608696 :     zsCalcSizing.CoolZoneHumRat = zoneNode.HumRat;
     517      9608696 :     zsCalcSizing.HeatOutTemp = state.dataEnvrn->OutDryBulbTemp;
     518      9608696 :     zsCalcSizing.HeatOutHumRat = state.dataEnvrn->OutHumRat;
     519      9608696 :     zsCalcSizing.CoolOutTemp = state.dataEnvrn->OutDryBulbTemp;
     520      9608696 :     zsCalcSizing.CoolOutHumRat = state.dataEnvrn->OutHumRat;
     521              : 
     522      9608696 :     Real64 LatentAirMassFlow = 0.0;
     523      9608696 :     Real64 MoistureLoad = 0.0;
     524      9608696 :     Real64 HgAir = PsyHgAirFnWTdb(zoneNode.HumRat, zoneNode.Temp);
     525      9608696 :     if (zsCalcSizing.zoneLatentSizing) {
     526              :         // replicate deadband flag - zone condition is either below the humidistat or above the dehumidistat set point
     527        20533 :         if ((zsMoistureDemand.OutputRequiredToHumidifyingSP > 0.0 && zsMoistureDemand.OutputRequiredToDehumidifyingSP > 0.0) ||
     528        15832 :             (zsMoistureDemand.OutputRequiredToHumidifyingSP < 0.0 && zsMoistureDemand.OutputRequiredToDehumidifyingSP < 0.0)) {
     529        18900 :             LatOutputProvided = zsMoistureDemand.RemainingOutputRequired;
     530              :         }
     531        20533 :         Real64 DeltaHumRat = 0.0;      // positive LatOutputProvided means humidification load
     532        20533 :         if (LatOutputProvided < 0.0) { // use SA humrat - zone humrat, or delta humrat based on user choice
     533        28398 :             DeltaHumRat = (zsCalcSizing.ZnLatCoolDgnSAMethod == SupplyAirHumidityRatio) ? (zsCalcSizing.LatentCoolDesHumRat - zoneNode.HumRat)
     534        14199 :                                                                                         : -zsCalcSizing.CoolDesHumRatDiff;
     535         6334 :         } else if (LatOutputProvided > 0.0) {
     536         4701 :             DeltaHumRat = (zsCalcSizing.ZnLatHeatDgnSAMethod == SupplyAirHumidityRatio) ? (zsCalcSizing.LatentHeatDesHumRat - zoneNode.HumRat)
     537              :                                                                                         : zsCalcSizing.HeatDesHumRatDiff;
     538              :         }
     539        20533 :         if (std::abs(DeltaHumRat) > HVAC::VerySmallMassFlow) {
     540        18900 :             LatentAirMassFlow = std::max(0.0, LatOutputProvided / DeltaHumRat);
     541              :         }
     542        20533 :         MoistureLoad = LatOutputProvided * HgAir;
     543              : 
     544        20533 :         if (MassFlowRate > 0.0) {
     545        16177 :             HumRat = zoneNode.HumRat + LatOutputProvided / MassFlowRate;
     546        16177 :             CpAir = PsyCpAirFnW(HumRat);
     547        16177 :             Temp = (SysOutputProvided / (MassFlowRate * CpAir)) + zoneNode.Temp;
     548        16177 :             Enthalpy = PsyHFnTdbW(Temp, HumRat);
     549         4356 :         } else if (LatentAirMassFlow > 0.0) {
     550              :             // if there is no sensible load then still need to hold zone RH at set point
     551              :             // no need to recalculate T, Sensible load = 0 so T = T,zone
     552         4351 :             HumRat = zoneNode.HumRat + LatOutputProvided / LatentAirMassFlow;
     553         4351 :             Enthalpy = PsyHFnTdbW(Temp, HumRat);
     554         4351 :             MassFlowRate = (LatentAirMassFlow > HVAC::VerySmallMassFlow) ? LatentAirMassFlow : 0.0;
     555              :         }
     556              : 
     557        20533 :         zsCalcSizing.HeatLatentLoad = (LatOutputProvided > 0.0) ? MoistureLoad : 0.0;
     558        20533 :         zsCalcSizing.ZoneHeatLatentMassFlow = (LatOutputProvided > 0.0) ? LatentAirMassFlow : 0.0;
     559        20533 :         zsCalcSizing.CoolLatentLoad = (LatOutputProvided < 0.0) ? -MoistureLoad : 0.0;
     560        20533 :         zsCalcSizing.ZoneCoolLatentMassFlow = (LatOutputProvided < 0.0) ? LatentAirMassFlow : 0.0;
     561        20533 :         zsCalcSizing.HeatLoadNoDOAS = (SysOutputProvidedNoDOAS > 0.0) ? SysOutputProvidedNoDOAS : 0.0;
     562        20533 :         zsCalcSizing.CoolLoadNoDOAS = (SysOutputProvidedNoDOAS < 0.0) ? -SysOutputProvidedNoDOAS : 0.0;
     563        20533 :         zsCalcSizing.HeatLatentLoadNoDOAS = (LatOutputProvidedNoDOAS > 0.0) ? LatOutputProvidedNoDOAS * HgAir : 0.0;
     564        20533 :         zsCalcSizing.CoolLatentLoadNoDOAS = (LatOutputProvidedNoDOAS < 0.0) ? -LatOutputProvidedNoDOAS * HgAir : 0.0;
     565              :     }
     566              : 
     567      9608696 :     if (supplyAirNodeNum > 0) {
     568      9359889 :         auto &supplyAirNode = state.dataLoopNodes->Node(supplyAirNodeNum);
     569      9359889 :         supplyAirNode.Temp = Temp;
     570      9359889 :         supplyAirNode.HumRat = HumRat;
     571      9359889 :         supplyAirNode.Enthalpy = Enthalpy;
     572      9359889 :         supplyAirNode.MassFlowRate = MassFlowRate;
     573              :     } else {
     574       248807 :         nonAirSystemResponse = SysOutputProvided;
     575       248807 :         if (zsCalcSizing.zoneLatentSizing) {
     576            0 :             int zoneMult = zoneOrSpace.Multiplier * zoneOrSpace.ListMultiplier;
     577            0 :             auto &zoneLatentGain = (spaceNum > 0) ? state.dataZoneTempPredictorCorrector->spaceHeatBalance(spaceNum).latentGain
     578            0 :                                                   : state.dataZoneTempPredictorCorrector->zoneHeatBalance(zoneNum).latentGain;
     579            0 :             zoneLatentGain += (LatOutputProvided * HgAir) / zoneMult;
     580              :         }
     581       248807 :         if (state.dataHeatBal->doSpaceHeatBalance && spaceNum == 0) {
     582            0 :             for (int spaceNum2 : state.dataHeatBal->Zone(zoneNum).spaceIndexes) {
     583              :                 // SpaceHB ToDo: For now allocate by space volume frac
     584            0 :                 auto &spHB = state.dataZoneTempPredictorCorrector->spaceHeatBalance(spaceNum2);
     585            0 :                 spHB.NonAirSystemResponse = nonAirSystemResponse * state.dataHeatBal->space(spaceNum2).fracZoneVolume;
     586            0 :                 if (zsCalcSizing.zoneLatentSizing) {
     587            0 :                     int zoneMult = zoneOrSpace.Multiplier * zoneOrSpace.ListMultiplier;
     588            0 :                     spHB.latentGain += (LatOutputProvided * HgAir) * state.dataHeatBal->space(spaceNum2).fracZoneVolume / zoneMult;
     589              :                 }
     590            0 :             }
     591              :         }
     592              :     }
     593              : 
     594      9608696 :     updateSystemOutputRequired(state, zoneNum, SysOutputProvided, LatOutputProvided, zsEnergyDemand, zsMoistureDemand);
     595      9608696 : }
     596              : 
     597      9608696 : void sizeZoneSpaceEquipmentPart2(EnergyPlusData &state,
     598              :                                  DataZoneEquipment::EquipConfiguration &zoneEquipConfig,
     599              :                                  DataSizing::ZoneSizingData &zsCalcSizing,
     600              :                                  int zoneNum,
     601              :                                  int spaceNum)
     602              : {
     603              :     // MJW for now - use first return node, make a separate commit to add a dimension to all of the sizing rettemp variables
     604      9608696 :     int returnNodeNum = (zoneEquipConfig.NumReturnNodes > 0) ? zoneEquipConfig.ReturnNode(1) : 0;
     605              :     int zoneNodeNum =
     606      9608696 :         (spaceNum > 0) ? state.dataHeatBal->space(spaceNum).SystemZoneNodeNumber : state.dataHeatBal->Zone(zoneNum).SystemZoneNodeNumber;
     607      9608696 :     Real64 RetTemp = (returnNodeNum > 0) ? state.dataLoopNodes->Node(returnNodeNum).Temp : state.dataLoopNodes->Node(zoneNodeNum).Temp;
     608              : 
     609      9608696 :     auto &zoneTstatSetpt = state.dataHeatBalFanSys->zoneTstatSetpts(zoneNum);
     610      9608696 :     if (zsCalcSizing.HeatLoad > 0.0) {
     611      3742076 :         zsCalcSizing.HeatZoneRetTemp = RetTemp;
     612      3742076 :         zsCalcSizing.HeatTstatTemp = (zoneTstatSetpt.setpt > 0.0) ? zoneTstatSetpt.setpt : zoneTstatSetpt.setptLo;
     613      3742076 :         zsCalcSizing.CoolTstatTemp = zoneTstatSetpt.setptHi;
     614      5866620 :     } else if (zsCalcSizing.CoolLoad > 0.0) {
     615      4199798 :         zsCalcSizing.CoolZoneRetTemp = RetTemp;
     616      4199798 :         zsCalcSizing.CoolTstatTemp = (zoneTstatSetpt.setpt > 0.0) ? zoneTstatSetpt.setpt : zoneTstatSetpt.setptHi;
     617      4199798 :         zsCalcSizing.HeatTstatTemp = zoneTstatSetpt.setptLo;
     618              :     } else {
     619      1666822 :         zsCalcSizing.CoolZoneRetTemp = RetTemp;
     620      1666822 :         zsCalcSizing.HeatTstatTemp = zoneTstatSetpt.setptLo;
     621      1666822 :         zsCalcSizing.CoolTstatTemp = zoneTstatSetpt.setptHi;
     622              :     }
     623      9608696 : }
     624              : 
     625      1044266 : void SizeZoneEquipment(EnergyPlusData &state)
     626              : {
     627              : 
     628              :     // SUBROUTINE INFORMATION:
     629              :     //       AUTHOR         Fred Buhl
     630              :     //       DATE WRITTEN   December 2000
     631              : 
     632              :     // PURPOSE OF THIS SUBROUTINE:
     633              :     // Performs the zone sizing calculations and fills the zone sizing
     634              :     // data arrays with the results of the calculation.
     635              : 
     636              :     // METHODOLOGY EMPLOYED:
     637              :     // Using the input from Zone Sizing objects and the Zone Equipment input,
     638              :     // for each controlled zone this subroutine performs a "purchased air" calculation
     639              :     // and saves the results in the zone sizing data arrays.
     640              : 
     641      1044266 :     if (state.dataZoneEquipmentManager->SizeZoneEquipmentOneTimeFlag) {
     642          428 :         SetUpZoneSizingArrays(state);
     643          428 :         state.dataZoneEquipmentManager->SizeZoneEquipmentOneTimeFlag = false;
     644              :     }
     645              : 
     646     11960943 :     for (int ControlledZoneNum = 1; ControlledZoneNum <= state.dataGlobal->NumOfZones; ++ControlledZoneNum) {
     647     10916677 :         auto &zoneEquipConfig = state.dataZoneEquip->ZoneEquipConfig(ControlledZoneNum);
     648     10916677 :         if (!zoneEquipConfig.IsControlled) {
     649      1358193 :             continue;
     650              :         }
     651              : 
     652              :         // use reference to eliminate lots of long lines in this function, after initial commit, so reviewers can see changes
     653      9558484 :         auto &calcZoneSizing = state.dataSize->CalcZoneSizing(state.dataSize->CurOverallSimDay, ControlledZoneNum);
     654      9558484 :         auto &zoneSysEnergyDemand = state.dataZoneEnergyDemand->ZoneSysEnergyDemand(ControlledZoneNum);
     655      9558484 :         auto &zoneSysMoistureDemand = state.dataZoneEnergyDemand->ZoneSysMoistureDemand(ControlledZoneNum);
     656      9558484 :         auto &zone = state.dataHeatBal->Zone(ControlledZoneNum);
     657              : 
     658      9558484 :         sizeZoneSpaceEquipmentPart1(state, zoneEquipConfig, calcZoneSizing, zoneSysEnergyDemand, zoneSysMoistureDemand, zone, ControlledZoneNum);
     659      9558484 :         if (state.dataHeatBal->doSpaceHeatBalance) {
     660        85272 :             for (int spaceNum : state.dataHeatBal->Zone(ControlledZoneNum).spaceIndexes) {
     661       200848 :                 sizeZoneSpaceEquipmentPart1(state,
     662        50212 :                                             state.dataZoneEquip->spaceEquipConfig(spaceNum),
     663        50212 :                                             state.dataSize->CalcSpaceSizing(state.dataSize->CurOverallSimDay, spaceNum),
     664        50212 :                                             state.dataZoneEnergyDemand->spaceSysEnergyDemand(spaceNum),
     665        50212 :                                             state.dataZoneEnergyDemand->spaceSysMoistureDemand(spaceNum),
     666              :                                             zone,
     667              :                                             ControlledZoneNum,
     668              :                                             spaceNum);
     669        35060 :             }
     670              :         }
     671              :     }
     672              : 
     673      1044266 :     CalcZoneMassBalance(state, true);
     674              : 
     675      1044266 :     CalcZoneLeavingConditions(state, true);
     676              : 
     677     11960943 :     for (int ControlledZoneNum = 1; ControlledZoneNum <= state.dataGlobal->NumOfZones; ++ControlledZoneNum) {
     678              : 
     679     10916677 :         auto &zoneEquipConfig = state.dataZoneEquip->ZoneEquipConfig(ControlledZoneNum);
     680     10916677 :         if (!zoneEquipConfig.IsControlled) {
     681      1358193 :             continue;
     682              :         }
     683      9558484 :         sizeZoneSpaceEquipmentPart2(
     684      9558484 :             state, zoneEquipConfig, state.dataSize->CalcZoneSizing(state.dataSize->CurOverallSimDay, ControlledZoneNum), ControlledZoneNum);
     685      9558484 :         if (state.dataHeatBal->doSpaceHeatBalance) {
     686        85272 :             for (int spaceNum : state.dataHeatBal->Zone(ControlledZoneNum).spaceIndexes) {
     687        50212 :                 sizeZoneSpaceEquipmentPart2(
     688        50212 :                     state, zoneEquipConfig, state.dataSize->CalcSpaceSizing(state.dataSize->CurOverallSimDay, spaceNum), ControlledZoneNum, spaceNum);
     689        35060 :             }
     690              :         }
     691              :     }
     692      1044266 : }
     693              : 
     694       239316 : void CalcDOASSupCondsForSizing(EnergyPlusData &state,
     695              :                                Real64 OutDB,                        // outside air temperature [C]
     696              :                                Real64 OutHR,                        // outside humidity ratio [kg Water / kg Dry Air]
     697              :                                DataSizing::DOASControl DOASControl, // dedicated outside air control strategy
     698              :                                Real64 DOASLowTemp,                  // DOAS low setpoint [C]
     699              :                                Real64 DOASHighTemp,                 // DOAS high setpoint [C]
     700              :                                Real64 W90H, // humidity ratio at DOAS high setpoint temperature and 90% relative humidity [kg Water / kg Dry Air]
     701              :                                Real64 W90L, // humidity ratio at DOAS low setpoint temperature and 90% relative humidity [kg Water / kg Dry Air]
     702              :                                Real64 &DOASSupTemp, // DOAS supply temperature [C]
     703              :                                Real64 &DOASSupHR    // DOAS Supply Humidity ratio [kg Water / kg Dry Air]
     704              : )
     705              : {
     706              :     // FUNCTION INFORMATION:
     707              :     //       AUTHOR         Fred Buhl
     708              :     //       DATE WRITTEN   March 2015
     709              : 
     710              :     // PURPOSE OF THIS FUNCTION:
     711              :     // This function calculates supply conditions for the direct outside air system (DOAS) sizing calculations
     712              : 
     713              :     // METHODOLOGY EMPLOYED:
     714              :     // the supply temperature and humidity ratio are set depending on the design control method and the outside air temperature
     715              : 
     716              :     // REFERENCES:
     717              :     // Consult the "DOAS Effect On Zone Sizing" new feature proposal and design documents
     718              : 
     719              :     // SUBROUTINE PARAMETER DEFINITIONS:
     720              :     static constexpr std::string_view RoutineName("CalcDOASSupCondsForSizing");
     721              : 
     722              :     // FUNCTION LOCAL VARIABLE DECLARATIONS:
     723              : 
     724       239316 :     DOASSupTemp = 0.0;
     725       239316 :     DOASSupHR = 0.0;
     726              :     // neutral supply air
     727       239316 :     if (DOASControl == DataSizing::DOASControl::NeutralSup) {
     728        10420 :         if (OutDB < DOASLowTemp) {
     729         4225 :             DOASSupTemp = DOASLowTemp;
     730         4225 :             DOASSupHR = OutHR;
     731         6195 :         } else if (OutDB > DOASHighTemp) {
     732         4655 :             DOASSupTemp = DOASHighTemp;
     733         4655 :             DOASSupHR = min(OutHR, W90H);
     734              :         } else {
     735         1540 :             DOASSupTemp = OutDB;
     736         1540 :             DOASSupHR = OutHR;
     737              :         }
     738              :     }
     739              : 
     740              :     // neutral dehumidified supply air
     741       228896 :     else if (DOASControl == DataSizing::DOASControl::NeutralDehumSup) { //
     742            0 :         if (OutDB < DOASLowTemp) {
     743            0 :             DOASSupTemp = DOASHighTemp;
     744            0 :             DOASSupHR = OutHR;
     745              :         } else {
     746            0 :             DOASSupTemp = DOASHighTemp;
     747            0 :             DOASSupHR = min(OutHR, W90L);
     748              :         }
     749              :     }
     750              : 
     751              :     // cold supply air
     752       228896 :     else if (DOASControl == DataSizing::DOASControl::CoolSup) {
     753       228896 :         if (OutDB < DOASLowTemp) {
     754        75757 :             DOASSupTemp = DOASHighTemp;
     755        75757 :             DOASSupHR = OutHR;
     756              :         } else {
     757       153139 :             DOASSupTemp = DOASLowTemp;
     758       153139 :             DOASSupHR = min(OutHR, W90L);
     759              :         }
     760              :     } else {
     761            0 :         ShowFatalError(state, format("{}:illegal DOAS design control strategy", RoutineName));
     762              :     }
     763       239316 : }
     764              : 
     765          428 : void SetUpZoneSizingArrays(EnergyPlusData &state)
     766              : {
     767              : 
     768              :     // SUBROUTINE INFORMATION:
     769              :     //       AUTHOR         Fred Buhl
     770              :     //       DATE WRITTEN   December 2000
     771              : 
     772              :     // PURPOSE OF THIS SUBROUTINE:
     773              :     // Allocate and fill the ZoneSizing data array.
     774              : 
     775              :     // METHODOLOGY EMPLOYED:
     776              :     // Obtains data from Zone Sizing and Zone Equipment objects already input.
     777              : 
     778          428 :     bool ErrorsFound(false); // Set to true if errors in input, fatal at end of routine
     779              : 
     780              :     // TODO MJW: Punt for now, sometimes unit test will get here and need these to be allocated, but simulations need them sooner
     781          428 :     if (!state.dataHeatBal->ZoneIntGain.allocated()) {
     782            0 :         DataHeatBalance::AllocateIntGains(state);
     783              :     }
     784              : 
     785         4070 :     for (int ZoneSizIndex = 1; ZoneSizIndex <= state.dataSize->NumZoneSizingInput; ++ZoneSizIndex) {
     786         3642 :         int ZoneIndex = Util::FindItemInList(state.dataSize->ZoneSizingInput(ZoneSizIndex).ZoneName, state.dataHeatBal->Zone);
     787         3642 :         if (ZoneIndex == 0) {
     788            0 :             ShowSevereError(
     789              :                 state,
     790            0 :                 format("SetUpZoneSizingArrays: Sizing:Zone=\"{}\" references unknown zone", state.dataSize->ZoneSizingInput(ZoneSizIndex).ZoneName));
     791            0 :             ErrorsFound = true;
     792              :         }
     793         3642 :         if (std::any_of(state.dataZoneEquip->ZoneEquipConfig.begin(), state.dataZoneEquip->ZoneEquipConfig.end(), [](EquipConfiguration const &e) {
     794         4657 :                 return e.IsControlled;
     795              :             })) {
     796         3642 :             ZoneIndex = Util::FindItemInList(
     797         3642 :                 state.dataSize->ZoneSizingInput(ZoneSizIndex).ZoneName, state.dataZoneEquip->ZoneEquipConfig, &EquipConfiguration::ZoneName);
     798         3642 :             if (ZoneIndex == 0) {
     799            1 :                 if (!state.dataGlobal->isPulseZoneSizing) {
     800            2 :                     ShowWarningError(state,
     801            2 :                                      format("SetUpZoneSizingArrays: Requested Sizing for Zone=\"{}\", Zone is not found in the Controlled Zones List",
     802            1 :                                             state.dataSize->ZoneSizingInput(ZoneSizIndex).ZoneName));
     803              :                 }
     804              :             } else {
     805         3641 :                 state.dataSize->ZoneSizingInput(ZoneSizIndex).ZoneNum = ZoneIndex;
     806              :             }
     807         4699 :             if (state.dataSize->ZoneSizingInput(ZoneSizIndex).CoolAirDesMethod == AirflowSizingMethod::FromDDCalc ||
     808         1057 :                 state.dataSize->ZoneSizingInput(ZoneSizIndex).HeatAirDesMethod == AirflowSizingMethod::FromDDCalc) {
     809         3642 :                 if (!ZoneTempPredictorCorrector::VerifyThermostatInZone(state, state.dataSize->ZoneSizingInput(ZoneSizIndex).ZoneName)) {
     810            4 :                     if (!state.dataGlobal->isPulseZoneSizing) {
     811            8 :                         ShowWarningError(state,
     812            8 :                                          format("SetUpZoneSizingArrays: Requested Sizing for Zone=\"{}\", Zone has no thermostat (ref: "
     813              :                                                 "ZoneControl:Thermostat, et al)",
     814            4 :                                                 state.dataSize->ZoneSizingInput(ZoneSizIndex).ZoneName));
     815              :                     }
     816              :                 }
     817              :             }
     818              :         } else {
     819            0 :             ShowSevereError(state, "SetUpZoneSizingArrays: Zone Sizing is requested but there are no ZoneHVAC:EquipmentConnections statements.");
     820            0 :             ErrorsFound = true;
     821              :         }
     822              :     }
     823              : 
     824              :     // Put Auto Sizing of Sizing:Zone inputs here!
     825          428 :     AutoCalcDOASControlStrategy(state);
     826              : 
     827          428 :     state.dataSize->ZoneSizing.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfZones);
     828          428 :     state.dataSize->FinalZoneSizing.allocate(state.dataGlobal->NumOfZones);
     829          428 :     state.dataSize->CalcZoneSizing.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->NumOfZones);
     830          428 :     state.dataSize->CalcFinalZoneSizing.allocate(state.dataGlobal->NumOfZones);
     831          428 :     if (state.dataHeatBal->doSpaceHeatBalanceSizing) {
     832            2 :         state.dataSize->SpaceSizing.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->numSpaces);
     833            2 :         state.dataSize->FinalSpaceSizing.allocate(state.dataGlobal->numSpaces);
     834            2 :         state.dataSize->CalcSpaceSizing.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays, state.dataGlobal->numSpaces);
     835            2 :         state.dataSize->CalcFinalSpaceSizing.allocate(state.dataGlobal->numSpaces);
     836              :     }
     837          428 :     state.dataSize->TermUnitFinalZoneSizing.allocate(state.dataSize->NumAirTerminalUnits);
     838         4415 :     for (auto &tufzs : state.dataSize->TermUnitFinalZoneSizing) {
     839         3987 :         tufzs.allocateMemberArrays(state.dataZoneEquipmentManager->NumOfTimeStepInDay);
     840          428 :     }
     841          428 :     state.dataSize->DesDayWeath.allocate(state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays);
     842          428 :     state.dataZoneEquipmentManager->AvgData.allocate(state.dataZoneEquipmentManager->NumOfTimeStepInDay);
     843         1347 :     for (int DesDayNum = 1; DesDayNum <= state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays; ++DesDayNum) {
     844          919 :         auto &thisDesDayWeather = state.dataSize->DesDayWeath(DesDayNum);
     845          919 :         thisDesDayWeather.Temp.allocate(state.dataGlobal->TimeStepsInHour * Constant::iHoursInDay);
     846          919 :         thisDesDayWeather.HumRat.allocate(state.dataGlobal->TimeStepsInHour * Constant::iHoursInDay);
     847          919 :         thisDesDayWeather.Press.allocate(state.dataGlobal->TimeStepsInHour * Constant::iHoursInDay);
     848          919 :         thisDesDayWeather.Temp = 0.0;
     849          919 :         thisDesDayWeather.HumRat = 0.0;
     850          919 :         thisDesDayWeather.Press = 0.0;
     851              :     }
     852              : 
     853              :     // Fill zone sizing arrays from input array
     854         4589 :     for (int CtrlZoneNum = 1; CtrlZoneNum <= state.dataGlobal->NumOfZones; ++CtrlZoneNum) {
     855         4161 :         auto &zoneEquipConfig = state.dataZoneEquip->ZoneEquipConfig(CtrlZoneNum);
     856         4161 :         if (!zoneEquipConfig.IsControlled) {
     857          491 :             continue;
     858              :         }
     859              : 
     860              :         // For each Zone Sizing object, find the corresponding controlled zone
     861         3670 :         int ZoneSizNum = Util::FindItemInList(zoneEquipConfig.ZoneName, state.dataSize->ZoneSizingInput, &ZoneSizingInputData::ZoneName);
     862         3670 :         auto &zoneSizingInput = (ZoneSizNum > 0) ? state.dataSize->ZoneSizingInput(ZoneSizNum) : state.dataSize->ZoneSizingInput(1);
     863         3670 :         if (ZoneSizNum == 0) { // LKL I think this is sufficient for warning -- no need for array
     864           29 :             if (!state.dataGlobal->isPulseZoneSizing) {
     865           58 :                 ShowWarningError(state,
     866           58 :                                  format("SetUpZoneSizingArrays: Sizing for Zone=\"{}\" will use Sizing:Zone specifications listed for Zone=\"{}\".",
     867           29 :                                         state.dataZoneEquip->ZoneEquipConfig(CtrlZoneNum).ZoneName,
     868           29 :                                         zoneSizingInput.ZoneName));
     869              :             }
     870              :         }
     871              : 
     872         7340 :         fillZoneSizingFromInput(state,
     873              :                                 zoneSizingInput,
     874         3670 :                                 state.dataSize->ZoneSizing,
     875         3670 :                                 state.dataSize->CalcZoneSizing,
     876         3670 :                                 state.dataSize->FinalZoneSizing(CtrlZoneNum),
     877         3670 :                                 state.dataSize->CalcFinalZoneSizing(CtrlZoneNum),
     878         3670 :                                 state.dataHeatBal->Zone(CtrlZoneNum).Name,
     879              :                                 CtrlZoneNum);
     880         3670 :         if (state.dataHeatBal->doSpaceHeatBalanceSizing) {
     881           24 :             for (int spaceNum : state.dataHeatBal->Zone(CtrlZoneNum).spaceIndexes) {
     882           28 :                 fillZoneSizingFromInput(state,
     883              :                                         zoneSizingInput,
     884           14 :                                         state.dataSize->SpaceSizing,
     885           14 :                                         state.dataSize->CalcSpaceSizing,
     886           14 :                                         state.dataSize->FinalSpaceSizing(spaceNum),
     887           14 :                                         state.dataSize->CalcFinalSpaceSizing(spaceNum),
     888           14 :                                         state.dataHeatBal->space(spaceNum).Name,
     889              :                                         spaceNum);
     890           10 :             }
     891              :         }
     892              : 
     893              :         // setup CalcFinalZoneSizing structure for use with EMS, some as sensors, some as actuators
     894         3670 :         if (state.dataGlobal->AnyEnergyManagementSystemInModel) {
     895         1118 :             auto &finalZoneSizing = state.dataSize->FinalZoneSizing(CtrlZoneNum);
     896         1118 :             auto &calcFinalZoneSizing = state.dataSize->CalcFinalZoneSizing(CtrlZoneNum);
     897              : 
     898         1118 :             SetupEMSInternalVariable(
     899         1118 :                 state, "Final Zone Design Heating Air Mass Flow Rate", finalZoneSizing.ZoneName, "[kg/s]", finalZoneSizing.DesHeatMassFlow);
     900         1118 :             SetupEMSInternalVariable(state,
     901              :                                      "Intermediate Zone Design Heating Air Mass Flow Rate",
     902              :                                      calcFinalZoneSizing.ZoneName,
     903              :                                      "[kg/s]",
     904         1118 :                                      calcFinalZoneSizing.DesHeatMassFlow);
     905         1118 :             SetupEMSActuator(state,
     906              :                              "Sizing:Zone",
     907              :                              calcFinalZoneSizing.ZoneName,
     908              :                              "Zone Design Heating Air Mass Flow Rate",
     909              :                              "[kg/s]",
     910         1118 :                              calcFinalZoneSizing.EMSOverrideDesHeatMassOn,
     911         1118 :                              calcFinalZoneSizing.EMSValueDesHeatMassFlow);
     912              : 
     913         1118 :             SetupEMSInternalVariable(
     914         1118 :                 state, "Final Zone Design Cooling Air Mass Flow Rate", finalZoneSizing.ZoneName, "[kg/s]", finalZoneSizing.DesCoolMassFlow);
     915         1118 :             SetupEMSInternalVariable(state,
     916              :                                      "Intermediate Zone Design Cooling Air Mass Flow Rate",
     917              :                                      calcFinalZoneSizing.ZoneName,
     918              :                                      "[kg/s]",
     919         1118 :                                      calcFinalZoneSizing.DesCoolMassFlow);
     920         1118 :             SetupEMSActuator(state,
     921              :                              "Sizing:Zone",
     922              :                              calcFinalZoneSizing.ZoneName,
     923              :                              "Zone Design Cooling Air Mass Flow Rate",
     924              :                              "[kg/s]",
     925         1118 :                              calcFinalZoneSizing.EMSOverrideDesCoolMassOn,
     926         1118 :                              calcFinalZoneSizing.EMSValueDesCoolMassFlow);
     927              : 
     928         1118 :             SetupEMSInternalVariable(state, "Final Zone Design Heating Load", finalZoneSizing.ZoneName, "[W]", finalZoneSizing.DesHeatLoad);
     929         1118 :             SetupEMSInternalVariable(
     930         1118 :                 state, "Intermediate Zone Design Heating Load", calcFinalZoneSizing.ZoneName, "[W]", calcFinalZoneSizing.DesHeatLoad);
     931         1118 :             SetupEMSActuator(state,
     932              :                              "Sizing:Zone",
     933              :                              calcFinalZoneSizing.ZoneName,
     934              :                              "Zone Design Heating Load",
     935              :                              "[W]",
     936         1118 :                              calcFinalZoneSizing.EMSOverrideDesHeatLoadOn,
     937         1118 :                              calcFinalZoneSizing.EMSValueDesHeatLoad);
     938              : 
     939         1118 :             SetupEMSInternalVariable(state, "Final Zone Design Cooling Load", finalZoneSizing.ZoneName, "[W]", finalZoneSizing.DesCoolLoad);
     940         1118 :             SetupEMSInternalVariable(
     941         1118 :                 state, "Intermediate Zone Design Cooling Load", calcFinalZoneSizing.ZoneName, "[W]", calcFinalZoneSizing.DesCoolLoad);
     942         1118 :             SetupEMSActuator(state,
     943              :                              "Sizing:Zone",
     944              :                              calcFinalZoneSizing.ZoneName,
     945              :                              "Zone Design Cooling Load",
     946              :                              "[W]",
     947         1118 :                              calcFinalZoneSizing.EMSOverrideDesCoolLoadOn,
     948         1118 :                              calcFinalZoneSizing.EMSValueDesCoolLoad);
     949              : 
     950         1118 :             SetupEMSInternalVariable(
     951         1118 :                 state, "Final Zone Design Heating Air Density", finalZoneSizing.ZoneName, "[kg/m3]", finalZoneSizing.DesHeatDens);
     952         1118 :             SetupEMSInternalVariable(
     953         1118 :                 state, "Intermediate Zone Design Heating Air Density", calcFinalZoneSizing.ZoneName, "[kg/m3]", calcFinalZoneSizing.DesHeatDens);
     954         1118 :             SetupEMSInternalVariable(
     955         1118 :                 state, "Final Zone Design Cooling Air Density", finalZoneSizing.ZoneName, "[kg/m3]", finalZoneSizing.DesCoolDens);
     956         1118 :             SetupEMSInternalVariable(
     957         1118 :                 state, "Intermediate Zone Design Cooling Air Density", calcFinalZoneSizing.ZoneName, "[kg/m3]", calcFinalZoneSizing.DesCoolDens);
     958              : 
     959         1118 :             SetupEMSInternalVariable(
     960         1118 :                 state, "Final Zone Design Heating Volume Flow", finalZoneSizing.ZoneName, "[m3/s]", finalZoneSizing.DesHeatVolFlow);
     961         1118 :             SetupEMSInternalVariable(
     962         1118 :                 state, "Intermediate Zone Design Heating Volume Flow", calcFinalZoneSizing.ZoneName, "[m3/s]", calcFinalZoneSizing.DesHeatVolFlow);
     963         1118 :             SetupEMSActuator(state,
     964              :                              "Sizing:Zone",
     965              :                              calcFinalZoneSizing.ZoneName,
     966              :                              "Zone Design Heating Vol Flow",
     967              :                              "[m3/s]",
     968         1118 :                              calcFinalZoneSizing.EMSOverrideDesHeatVolOn,
     969         1118 :                              calcFinalZoneSizing.EMSValueDesHeatVolFlow);
     970              : 
     971         1118 :             SetupEMSInternalVariable(
     972         1118 :                 state, "Final Zone Design Cooling Volume Flow", finalZoneSizing.ZoneName, "[m3/s]", finalZoneSizing.DesCoolVolFlow);
     973         1118 :             SetupEMSInternalVariable(
     974         1118 :                 state, "Intermediate Zone Design Cooling Volume Flow", calcFinalZoneSizing.ZoneName, "[m3/s]", calcFinalZoneSizing.DesCoolVolFlow);
     975         1118 :             SetupEMSActuator(state,
     976              :                              "Sizing:Zone",
     977              :                              calcFinalZoneSizing.ZoneName,
     978              :                              "Zone Design Cooling Vol Flow",
     979              :                              "[m3/s]",
     980         1118 :                              calcFinalZoneSizing.EMSOverrideDesCoolVolOn,
     981         1118 :                              calcFinalZoneSizing.EMSValueDesCoolVolFlow);
     982              : 
     983         1118 :             SetupEMSInternalVariable(
     984         1118 :                 state, "Zone Outdoor Air Design Volume Flow Rate", calcFinalZoneSizing.ZoneName, "[m3/s]", calcFinalZoneSizing.MinOA);
     985              :         }
     986              :     }
     987              : 
     988              :     // Populate DesignSpecification:OutdoorAir:SpaceList spaces
     989          428 :     bool dsoaError = false;
     990         4606 :     for (int oaIndex = 1; oaIndex <= state.dataSize->NumOARequirements; ++oaIndex) {
     991         4178 :         auto &thisOAReq = state.dataSize->OARequirements(oaIndex);
     992              :         // If this is a DesignSpecification:OutdoorAir:SpaceList check to make sure spaces are valid and belong to this zone
     993         4178 :         if (thisOAReq.numDSOA > 0) {
     994            9 :             for (int spaceCounter = 1; spaceCounter <= thisOAReq.numDSOA; ++spaceCounter) {
     995            6 :                 std::string thisSpaceName = thisOAReq.dsoaSpaceNames(spaceCounter);
     996            6 :                 int thisSpaceNum = Util::FindItemInList(thisSpaceName, state.dataHeatBal->space);
     997            6 :                 if (thisSpaceNum > 0) {
     998            6 :                     thisOAReq.dsoaSpaceIndexes.emplace_back(thisSpaceNum);
     999              :                 } else {
    1000            0 :                     ShowSevereError(state, format("SetUpZoneSizingArrays: DesignSpecification:OutdoorAir:SpaceList={}", thisOAReq.Name));
    1001            0 :                     ShowContinueError(state, format("Space Name={} not found.", thisSpaceName));
    1002            0 :                     dsoaError = true;
    1003            0 :                     ErrorsFound = true;
    1004              :                 }
    1005              :                 // Check for duplicate spaces
    1006            9 :                 for (int loop = 1; loop <= int(thisOAReq.dsoaSpaceIndexes.size()) - 1; ++loop) {
    1007            3 :                     if (thisSpaceNum == thisOAReq.dsoaSpaceIndexes(loop)) {
    1008            0 :                         ShowSevereError(state, format("SetUpZoneSizingArrays: DesignSpecification:OutdoorAir:SpaceList={}", thisOAReq.Name));
    1009            0 :                         ShowContinueError(state, format("Space Name={} appears more than once in the list.", thisSpaceName));
    1010            0 :                         dsoaError = true;
    1011            0 :                         ErrorsFound = true;
    1012              :                     }
    1013              :                 }
    1014            6 :             }
    1015              :         }
    1016              :     }
    1017              : 
    1018              :     // Use the max occupancy data from the PEOPLE structure to calculate design min OA for each zone
    1019              :     // Calculate the zone design minimum outside air flow rate from the 3 Zone Sizing OA inputs and
    1020              :     // from the specified OA method
    1021         4589 :     for (int CtrlZoneNum = 1; CtrlZoneNum <= state.dataGlobal->NumOfZones; ++CtrlZoneNum) {
    1022         4161 :         if (!state.dataZoneEquip->ZoneEquipConfig(CtrlZoneNum).IsControlled) {
    1023          491 :             continue;
    1024              :         }
    1025         3670 :         auto &finalZoneSizing = state.dataSize->FinalZoneSizing(CtrlZoneNum);
    1026         3670 :         auto &calcFinalZoneSizing = state.dataSize->CalcFinalZoneSizing(CtrlZoneNum);
    1027         3670 :         calcSizingOA(state, finalZoneSizing, calcFinalZoneSizing, dsoaError, ErrorsFound, CtrlZoneNum);
    1028              :     }
    1029          428 :     if (state.dataHeatBal->doSpaceHeatBalanceSizing) {
    1030           18 :         for (int spaceNum = 1; spaceNum <= state.dataGlobal->numSpaces; ++spaceNum) {
    1031           16 :             int zoneNum = state.dataHeatBal->space(spaceNum).zoneNum;
    1032           16 :             if (!state.dataZoneEquip->ZoneEquipConfig(zoneNum).IsControlled) {
    1033            2 :                 continue;
    1034              :             }
    1035           14 :             auto &finalSpaceSizing = state.dataSize->FinalSpaceSizing(spaceNum);
    1036           14 :             auto &calcFinalSpaceSizing = state.dataSize->CalcFinalSpaceSizing(spaceNum);
    1037           14 :             calcSizingOA(state, finalSpaceSizing, calcFinalSpaceSizing, dsoaError, ErrorsFound, zoneNum, spaceNum);
    1038              :         }
    1039              :     }
    1040              :     // Formats
    1041          428 :     print(state.files.eio, "! <Load Timesteps in Zone Design Calculation Averaging Window>, Value\n");
    1042              :     static constexpr std::string_view Format_891(" Load Timesteps in Zone Design Calculation Averaging Window, {:4}\n");
    1043          428 :     print(state.files.eio, Format_891, state.dataSize->NumTimeStepsInAvg);
    1044          428 :     print(state.files.eio, "! <Heating Sizing Factor Information>, Sizing Factor ID, Value\n");
    1045              :     static constexpr std::string_view Format_991(" Heating Sizing Factor Information, Global, {:12.5N}\n");
    1046          428 :     print(state.files.eio, Format_991, state.dataSize->GlobalHeatSizingFactor);
    1047         4589 :     for (int CtrlZoneNum = 1; CtrlZoneNum <= state.dataGlobal->NumOfZones; ++CtrlZoneNum) {
    1048         4161 :         if (!state.dataZoneEquip->ZoneEquipConfig(CtrlZoneNum).IsControlled) {
    1049          491 :             continue;
    1050              :         }
    1051         3670 :         if (state.dataSize->FinalZoneSizing(CtrlZoneNum).HeatSizingFactor != 1.0) {
    1052              :             static constexpr std::string_view Format_992(" Heating Sizing Factor Information, Zone {}, {:12.5N}\n");
    1053         2466 :             print(state.files.eio,
    1054              :                   Format_992,
    1055         2466 :                   state.dataSize->FinalZoneSizing(CtrlZoneNum).ZoneName,
    1056         2466 :                   state.dataSize->FinalZoneSizing(CtrlZoneNum).HeatSizingFactor);
    1057              :         }
    1058              :     }
    1059          428 :     print(state.files.eio, "! <Cooling Sizing Factor Information>, Sizing Factor ID, Value\n");
    1060              :     static constexpr std::string_view Format_994(" Cooling Sizing Factor Information, Global, {:12.5N}\n");
    1061          428 :     print(state.files.eio, Format_994, state.dataSize->GlobalCoolSizingFactor);
    1062         4589 :     for (int CtrlZoneNum = 1; CtrlZoneNum <= state.dataGlobal->NumOfZones; ++CtrlZoneNum) {
    1063         4161 :         if (!state.dataZoneEquip->ZoneEquipConfig(CtrlZoneNum).IsControlled) {
    1064          491 :             continue;
    1065              :         }
    1066         3670 :         if (state.dataSize->FinalZoneSizing(CtrlZoneNum).CoolSizingFactor != 1.0) {
    1067              :             static constexpr std::string_view Format_995(" Cooling Sizing Factor Information, Zone {}, {:12.5N}\n");
    1068         2458 :             print(state.files.eio,
    1069              :                   Format_995,
    1070         2458 :                   state.dataSize->FinalZoneSizing(CtrlZoneNum).ZoneName,
    1071         2458 :                   state.dataSize->FinalZoneSizing(CtrlZoneNum).CoolSizingFactor);
    1072              :         }
    1073              :     }
    1074          428 :     if (ErrorsFound) {
    1075            0 :         ShowFatalError(state, "SetUpZoneSizingArrays: Errors found in Sizing:Zone input");
    1076              :     }
    1077          428 : }
    1078              : 
    1079         3684 : void calcSizingOA(EnergyPlusData &state,
    1080              :                   DataSizing::ZoneSizingData &zsFinalSizing,
    1081              :                   DataSizing::ZoneSizingData &zsCalcFinalSizing,
    1082              :                   bool &dsoaError,
    1083              :                   bool &ErrorsFound,
    1084              :                   int const zoneNum,
    1085              :                   int const spaceNum)
    1086              : {
    1087              :     // Use the max occupancy PEOPLE structure to calculate design min OA for each zone from the outside air flow per person input
    1088         3684 :     Real64 TotPeopleInZone = 0.0;
    1089         3684 :     Real64 ZoneMinOccupancy = 0.;
    1090         3684 :     int DSOAPtr = zsFinalSizing.ZoneDesignSpecOAIndex; // index to DesignSpecification:OutdoorAir object
    1091         3684 :     auto const &thisZone = state.dataHeatBal->Zone(zoneNum);
    1092         3684 :     int zoneMult = thisZone.Multiplier * thisZone.ListMultiplier;
    1093         3684 :     Real64 floorArea = (spaceNum == 0) ? thisZone.FloorArea : state.dataHeatBal->space(spaceNum).FloorArea;
    1094         3684 :     if ((DSOAPtr > 0) && !dsoaError) {
    1095         3666 :         auto &thisOAReq = state.dataSize->OARequirements(DSOAPtr);
    1096              :         // If this is a DesignSpecification:OutdoorAir:SpaceList check to make sure spaces are valid and belong to this zone
    1097         3666 :         if (thisOAReq.numDSOA > 0) {
    1098           18 :             for (int spaceCounter = 1; spaceCounter <= thisOAReq.numDSOA; ++spaceCounter) {
    1099           12 :                 int thisSpaceNum = thisOAReq.dsoaSpaceIndexes(spaceCounter);
    1100           12 :                 if (thisSpaceNum > 0) {
    1101           12 :                     if (state.dataHeatBal->space(thisSpaceNum).zoneNum != zoneNum) {
    1102            0 :                         ShowSevereError(state, format("SetUpZoneSizingArrays: DesignSpecification:OutdoorAir:SpaceList={}", thisOAReq.Name));
    1103            0 :                         ShowContinueError(state, format("is invalid for Sizing:Zone={}", zsFinalSizing.ZoneName));
    1104            0 :                         ShowContinueError(state, "All spaces in the list must be part of this zone.");
    1105            0 :                         ErrorsFound = true;
    1106              :                     }
    1107              :                 }
    1108              :             }
    1109              :         }
    1110              : 
    1111         3666 :         zsFinalSizing.DesOAFlowPPer = thisOAReq.desFlowPerZonePerson(state, zoneNum, spaceNum);
    1112         3666 :         zsFinalSizing.DesOAFlowPerArea = thisOAReq.desFlowPerZoneArea(state, zoneNum, spaceNum);
    1113              :     }
    1114              : 
    1115       115462 :     for (int PeopleNum = 1; PeopleNum <= state.dataHeatBal->TotPeople; ++PeopleNum) {
    1116       111778 :         auto &people = state.dataHeatBal->People(PeopleNum);
    1117       111778 :         if (((spaceNum == 0) && (people.ZonePtr == zoneNum)) || ((spaceNum > 0) && (people.spaceIndex == spaceNum))) {
    1118         3497 :             Real64 numPeople = people.NumberOfPeople * zoneMult;
    1119         3497 :             TotPeopleInZone += numPeople;
    1120         3497 :             Real64 SchMax = people.sched->getMaxVal(state);
    1121         3497 :             if (SchMax > 0) {
    1122         3469 :                 zsFinalSizing.ZonePeakOccupancy += numPeople * SchMax;
    1123              :             } else {
    1124           28 :                 zsFinalSizing.ZonePeakOccupancy += numPeople;
    1125              :             }
    1126         3497 :             ZoneMinOccupancy += numPeople * people.sched->getMinVal(state);
    1127              :         }
    1128              :     }
    1129         3684 :     zsFinalSizing.TotalZoneFloorArea = (floorArea * zoneMult);
    1130         3684 :     Real64 OAFromPeople = zsFinalSizing.DesOAFlowPPer * TotPeopleInZone;
    1131         3684 :     Real64 OAFromArea = zsFinalSizing.DesOAFlowPerArea * zsFinalSizing.TotalZoneFloorArea;
    1132         3684 :     zsFinalSizing.TotPeopleInZone = TotPeopleInZone;
    1133         3684 :     zsFinalSizing.TotalOAFromPeople = OAFromPeople;
    1134         3684 :     zsFinalSizing.TotalOAFromArea = OAFromArea;
    1135              : 
    1136              :     // save Voz for predefined outdoor air summary report
    1137         3684 :     Real64 MinEz = std::min(zsFinalSizing.ZoneADEffCooling, zsFinalSizing.ZoneADEffHeating);
    1138         3684 :     if (MinEz == 0) {
    1139            0 :         MinEz = 1.0; // if not calculated assume 1.0 ventilation effectiveness
    1140              :     }
    1141         3684 :     Real64 vozMin = (ZoneMinOccupancy * zsFinalSizing.DesOAFlowPPer + OAFromArea) / MinEz;
    1142         3684 :     if (spaceNum == 0) {
    1143              :         // Space TODO: There is no equivalent for spaces
    1144         3670 :         state.dataHeatBal->ZonePreDefRep(zoneNum).VozMin = vozMin;
    1145              :     }
    1146              : 
    1147              :     // Calculate the design min OA flow rate for this zone
    1148              :     // flag to use occupancy schedule when calculating OA
    1149              :     // flag to use min OA schedule when calculating OA
    1150         3684 :     auto &equipConfig = (spaceNum == 0) ? state.dataZoneEquip->ZoneEquipConfig(zoneNum) : state.dataZoneEquip->spaceEquipConfig(spaceNum);
    1151         3684 :     equipConfig.ZoneDesignSpecOAIndex = DSOAPtr;                                   // store for later use
    1152         3684 :     equipConfig.ZoneAirDistributionIndex = zsFinalSizing.ZoneAirDistributionIndex; // store for later use
    1153         3684 :     Real64 OAVolumeFlowRate = 0.0;
    1154         3684 :     if (!dsoaError) {
    1155         3684 :         bool UseOccSchFlag = false;
    1156         3684 :         bool UseMinOASchFlag = false;
    1157         3684 :         bool PerPersonNotSet = false;
    1158         3684 :         bool MaxOAVolFlowFlag = false;
    1159         3684 :         OAVolumeFlowRate = DataSizing::calcDesignSpecificationOutdoorAir(
    1160              :             state, DSOAPtr, zoneNum, UseOccSchFlag, UseMinOASchFlag, PerPersonNotSet, MaxOAVolFlowFlag, spaceNum);
    1161              :     }
    1162              : 
    1163              :     // Zone(ZoneIndex)%Multiplier and Zone(ZoneIndex)%ListMultiplier applied in CalcDesignSpecificationOutdoorAir
    1164         3684 :     zsFinalSizing.MinOA = OAVolumeFlowRate;
    1165         3684 :     zsCalcFinalSizing.MinOA = OAVolumeFlowRate;
    1166         3684 :     if (zsFinalSizing.ZoneADEffCooling > 0.0 || zsFinalSizing.ZoneADEffHeating > 0.0) {
    1167         3684 :         zsFinalSizing.MinOA /= min(zsFinalSizing.ZoneADEffCooling, zsFinalSizing.ZoneADEffHeating);
    1168         3684 :         zsCalcFinalSizing.MinOA = zsFinalSizing.MinOA;
    1169              :     }
    1170              :     // calculated zone design flow rates automatically take into account zone multipliers, since the zone
    1171              :     // loads are multiplied (in ZoneTempPredictorCorrector.cc). Flow rates derived directly from
    1172              :     // user inputs need to be explicitly multiplied by the zone multipliers.
    1173         3684 :     zsFinalSizing.DesCoolMinAirFlow2 = zsFinalSizing.DesCoolMinAirFlowPerArea * floorArea * zoneMult;
    1174         3684 :     zsCalcFinalSizing.DesCoolMinAirFlow2 = zsCalcFinalSizing.DesCoolMinAirFlowPerArea * floorArea * zoneMult;
    1175         3684 :     zsFinalSizing.DesHeatMaxAirFlow2 = zsFinalSizing.DesHeatMaxAirFlowPerArea * floorArea * zoneMult;
    1176         3684 :     zsCalcFinalSizing.DesHeatMaxAirFlow2 = zsCalcFinalSizing.DesHeatMaxAirFlowPerArea * floorArea * zoneMult;
    1177         3684 :     int zoneMultiplier = zoneMult;
    1178         3684 :     zsFinalSizing.DesCoolMinAirFlow *= zoneMultiplier;
    1179         3684 :     zsCalcFinalSizing.DesCoolMinAirFlow *= zoneMultiplier;
    1180         3684 :     zsFinalSizing.DesHeatMaxAirFlow *= zoneMultiplier;
    1181         3684 :     zsCalcFinalSizing.DesHeatMaxAirFlow *= zoneMultiplier;
    1182         3684 :     zsFinalSizing.InpDesCoolAirFlow *= zoneMultiplier;
    1183         3684 :     zsCalcFinalSizing.InpDesCoolAirFlow *= zoneMultiplier;
    1184         3684 :     zsFinalSizing.InpDesHeatAirFlow *= zoneMultiplier;
    1185         3684 :     zsCalcFinalSizing.InpDesHeatAirFlow *= zoneMultiplier;
    1186              : 
    1187        11702 :     for (int DesDayNum = 1; DesDayNum <= state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays; ++DesDayNum) {
    1188         8018 :         auto &zoneSizing = state.dataSize->ZoneSizing(DesDayNum, zoneNum);
    1189         8018 :         zoneSizing.MinOA = zsFinalSizing.MinOA;
    1190         8018 :         state.dataSize->CalcZoneSizing(DesDayNum, zoneNum).MinOA = zsCalcFinalSizing.MinOA;
    1191         8018 :         zoneSizing.DesCoolMinAirFlow2 = zsFinalSizing.DesCoolMinAirFlow2;
    1192         8018 :         state.dataSize->CalcZoneSizing(DesDayNum, zoneNum).DesCoolMinAirFlow2 = zsCalcFinalSizing.DesCoolMinAirFlow2;
    1193         8018 :         zoneSizing.DesCoolMinAirFlow = zsFinalSizing.DesCoolMinAirFlow;
    1194         8018 :         state.dataSize->CalcZoneSizing(DesDayNum, zoneNum).DesCoolMinAirFlow = zsCalcFinalSizing.DesCoolMinAirFlow;
    1195         8018 :         zoneSizing.DesHeatMaxAirFlow2 = zsFinalSizing.DesHeatMaxAirFlow2;
    1196         8018 :         state.dataSize->CalcZoneSizing(DesDayNum, zoneNum).DesHeatMaxAirFlow2 = zsCalcFinalSizing.DesHeatMaxAirFlow2;
    1197         8018 :         zoneSizing.DesHeatMaxAirFlow = zsFinalSizing.DesHeatMaxAirFlow;
    1198         8018 :         state.dataSize->CalcZoneSizing(DesDayNum, zoneNum).DesHeatMaxAirFlow = zsCalcFinalSizing.DesHeatMaxAirFlow;
    1199              :     }
    1200         3684 : }
    1201              : 
    1202         3684 : void fillZoneSizingFromInput(EnergyPlusData &state,
    1203              :                              DataSizing::ZoneSizingInputData const &zoneSizingInput,
    1204              :                              Array2D<DataSizing::ZoneSizingData> &zsSizing,
    1205              :                              Array2D<DataSizing::ZoneSizingData> &zsCalcSizing,
    1206              :                              DataSizing::ZoneSizingData &zsFinalSizing,
    1207              :                              DataSizing::ZoneSizingData &zsCalcFinalSizing,
    1208              :                              std::string_view const zoneOrSpaceName,
    1209              :                              int const zoneOrSpaceNum)
    1210              : {
    1211        11702 :     for (int DesDayNum = 1; DesDayNum <= state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays; ++DesDayNum) {
    1212         8018 :         auto &zoneSizing = zsSizing(DesDayNum, zoneOrSpaceNum);
    1213         8018 :         auto &calcZoneSizing = zsCalcSizing(DesDayNum, zoneOrSpaceNum);
    1214         8018 :         zoneSizing.ZoneName = zoneOrSpaceName;
    1215         8018 :         zoneSizing.ZoneNum = zoneOrSpaceNum;
    1216         8018 :         calcZoneSizing.ZoneName = zoneOrSpaceName;
    1217         8018 :         calcZoneSizing.ZoneNum = zoneOrSpaceNum;
    1218              : 
    1219         8018 :         zoneSizing.ZnCoolDgnSAMethod = zoneSizingInput.ZnCoolDgnSAMethod;
    1220         8018 :         zoneSizing.ZnHeatDgnSAMethod = zoneSizingInput.ZnHeatDgnSAMethod;
    1221         8018 :         zoneSizing.CoolDesTemp = zoneSizingInput.CoolDesTemp;
    1222         8018 :         zoneSizing.HeatDesTemp = zoneSizingInput.HeatDesTemp;
    1223         8018 :         zoneSizing.CoolDesTempDiff = zoneSizingInput.CoolDesTempDiff;
    1224         8018 :         zoneSizing.HeatDesTempDiff = zoneSizingInput.HeatDesTempDiff;
    1225         8018 :         zoneSizing.CoolDesHumRat = zoneSizingInput.CoolDesHumRat;
    1226         8018 :         zoneSizing.HeatDesHumRat = zoneSizingInput.HeatDesHumRat;
    1227         8018 :         zoneSizing.CoolAirDesMethod = zoneSizingInput.CoolAirDesMethod;
    1228         8018 :         zoneSizing.HeatAirDesMethod = zoneSizingInput.HeatAirDesMethod;
    1229         8018 :         zoneSizing.InpDesCoolAirFlow = zoneSizingInput.DesCoolAirFlow;
    1230         8018 :         zoneSizing.DesCoolMinAirFlowPerArea = zoneSizingInput.DesCoolMinAirFlowPerArea;
    1231         8018 :         zoneSizing.DesCoolMinAirFlow = zoneSizingInput.DesCoolMinAirFlow;
    1232         8018 :         zoneSizing.DesCoolMinAirFlowFrac = zoneSizingInput.DesCoolMinAirFlowFrac;
    1233         8018 :         zoneSizing.InpDesHeatAirFlow = zoneSizingInput.DesHeatAirFlow;
    1234         8018 :         zoneSizing.DesHeatMaxAirFlowPerArea = zoneSizingInput.DesHeatMaxAirFlowPerArea;
    1235         8018 :         zoneSizing.DesHeatMaxAirFlow = zoneSizingInput.DesHeatMaxAirFlow;
    1236         8018 :         zoneSizing.DesHeatMaxAirFlowFrac = zoneSizingInput.DesHeatMaxAirFlowFrac;
    1237         8018 :         zoneSizing.HeatSizingFactor = zoneSizingInput.HeatSizingFactor;
    1238         8018 :         zoneSizing.CoolSizingFactor = zoneSizingInput.CoolSizingFactor;
    1239         8018 :         zoneSizing.AccountForDOAS = zoneSizingInput.AccountForDOAS;
    1240         8018 :         zoneSizing.DOASControlStrategy = zoneSizingInput.DOASControlStrategy;
    1241         8018 :         zoneSizing.DOASLowSetpoint = zoneSizingInput.DOASLowSetpoint;
    1242         8018 :         zoneSizing.DOASHighSetpoint = zoneSizingInput.DOASHighSetpoint;
    1243         8018 :         zoneSizing.spaceConcurrence = zoneSizingInput.spaceConcurrence;
    1244         8018 :         zoneSizing.zoneSizingMethod = zoneSizingInput.zoneSizingMethod;
    1245         8018 :         zoneSizing.zoneLatentSizing = zoneSizingInput.zoneLatentSizing;
    1246         8018 :         zoneSizing.zoneRHDehumidifySetPoint = zoneSizingInput.zoneRHDehumidifySetPoint;
    1247         8018 :         zoneSizing.zoneRHHumidifySetPoint = zoneSizingInput.zoneRHHumidifySetPoint;
    1248         8018 :         zoneSizing.zoneRHDehumidifySched = zoneSizingInput.zoneRHDehumidifySched;
    1249         8018 :         zoneSizing.zoneRHHumidifySched = zoneSizingInput.zoneRHHumidifySched;
    1250         8018 :         zoneSizing.ZnLatCoolDgnSAMethod = zoneSizingInput.ZnLatCoolDgnSAMethod;
    1251         8018 :         zoneSizing.ZnLatHeatDgnSAMethod = zoneSizingInput.ZnLatHeatDgnSAMethod;
    1252         8018 :         calcZoneSizing.ZnCoolDgnSAMethod = zoneSizingInput.ZnCoolDgnSAMethod;
    1253         8018 :         calcZoneSizing.ZnHeatDgnSAMethod = zoneSizingInput.ZnHeatDgnSAMethod;
    1254         8018 :         calcZoneSizing.CoolDesTemp = zoneSizingInput.CoolDesTemp;
    1255         8018 :         calcZoneSizing.HeatDesTemp = zoneSizingInput.HeatDesTemp;
    1256         8018 :         calcZoneSizing.CoolDesTempDiff = zoneSizingInput.CoolDesTempDiff;
    1257         8018 :         calcZoneSizing.HeatDesTempDiff = zoneSizingInput.HeatDesTempDiff;
    1258         8018 :         calcZoneSizing.CoolDesHumRat = zoneSizingInput.CoolDesHumRat;
    1259         8018 :         calcZoneSizing.HeatDesHumRat = zoneSizingInput.HeatDesHumRat;
    1260         8018 :         calcZoneSizing.CoolAirDesMethod = zoneSizingInput.CoolAirDesMethod;
    1261         8018 :         calcZoneSizing.HeatAirDesMethod = zoneSizingInput.HeatAirDesMethod;
    1262         8018 :         calcZoneSizing.InpDesCoolAirFlow = zoneSizingInput.DesCoolAirFlow;
    1263         8018 :         calcZoneSizing.DesCoolMinAirFlowPerArea = zoneSizingInput.DesCoolMinAirFlowPerArea;
    1264         8018 :         calcZoneSizing.DesCoolMinAirFlow = zoneSizingInput.DesCoolMinAirFlow;
    1265         8018 :         calcZoneSizing.DesCoolMinAirFlowFrac = zoneSizingInput.DesCoolMinAirFlowFrac;
    1266         8018 :         calcZoneSizing.InpDesHeatAirFlow = zoneSizingInput.DesHeatAirFlow;
    1267         8018 :         calcZoneSizing.DesHeatMaxAirFlowPerArea = zoneSizingInput.DesHeatMaxAirFlowPerArea;
    1268         8018 :         calcZoneSizing.DesHeatMaxAirFlow = zoneSizingInput.DesHeatMaxAirFlow;
    1269         8018 :         calcZoneSizing.DesHeatMaxAirFlowFrac = zoneSizingInput.DesHeatMaxAirFlowFrac;
    1270         8018 :         calcZoneSizing.HeatSizingFactor = zoneSizingInput.HeatSizingFactor;
    1271         8018 :         calcZoneSizing.CoolSizingFactor = zoneSizingInput.CoolSizingFactor;
    1272         8018 :         calcZoneSizing.AccountForDOAS = zoneSizingInput.AccountForDOAS;
    1273         8018 :         calcZoneSizing.DOASControlStrategy = zoneSizingInput.DOASControlStrategy;
    1274         8018 :         calcZoneSizing.DOASLowSetpoint = zoneSizingInput.DOASLowSetpoint;
    1275         8018 :         calcZoneSizing.DOASHighSetpoint = zoneSizingInput.DOASHighSetpoint;
    1276         8018 :         calcZoneSizing.spaceConcurrence = zoneSizingInput.spaceConcurrence;
    1277         8018 :         calcZoneSizing.zoneSizingMethod = zoneSizingInput.zoneSizingMethod;
    1278         8018 :         calcZoneSizing.zoneLatentSizing = zoneSizingInput.zoneLatentSizing;
    1279         8018 :         calcZoneSizing.zoneRHDehumidifySetPoint = zoneSizingInput.zoneRHDehumidifySetPoint;
    1280         8018 :         calcZoneSizing.zoneRHHumidifySetPoint = zoneSizingInput.zoneRHHumidifySetPoint;
    1281         8018 :         calcZoneSizing.zoneRHDehumidifySched = zoneSizingInput.zoneRHDehumidifySched;
    1282         8018 :         calcZoneSizing.zoneRHHumidifySched = zoneSizingInput.zoneRHHumidifySched;
    1283         8018 :         calcZoneSizing.ZnLatCoolDgnSAMethod = zoneSizingInput.ZnLatCoolDgnSAMethod;
    1284         8018 :         calcZoneSizing.LatentCoolDesHumRat = zoneSizingInput.LatentCoolDesHumRat;
    1285         8018 :         calcZoneSizing.CoolDesHumRatDiff = zoneSizingInput.CoolDesHumRatDiff;
    1286         8018 :         calcZoneSizing.ZnLatHeatDgnSAMethod = zoneSizingInput.ZnLatHeatDgnSAMethod;
    1287         8018 :         calcZoneSizing.LatentHeatDesHumRat = zoneSizingInput.LatentHeatDesHumRat;
    1288         8018 :         calcZoneSizing.HeatDesHumRatDiff = zoneSizingInput.HeatDesHumRatDiff;
    1289              : 
    1290         8018 :         zoneSizing.allocateMemberArrays(state.dataZoneEquipmentManager->NumOfTimeStepInDay);
    1291         8018 :         calcZoneSizing.allocateMemberArrays(state.dataZoneEquipmentManager->NumOfTimeStepInDay);
    1292              :     }
    1293              : 
    1294         3684 :     zsFinalSizing.ZoneName = zoneOrSpaceName;
    1295         3684 :     zsFinalSizing.ZoneNum = zoneOrSpaceNum;
    1296         3684 :     zsCalcFinalSizing.ZoneName = zoneOrSpaceName;
    1297         3684 :     zsCalcFinalSizing.ZoneNum = zoneOrSpaceNum;
    1298              : 
    1299         3684 :     zsFinalSizing.ZnCoolDgnSAMethod = zoneSizingInput.ZnCoolDgnSAMethod;
    1300         3684 :     zsFinalSizing.ZnHeatDgnSAMethod = zoneSizingInput.ZnHeatDgnSAMethod;
    1301         3684 :     zsFinalSizing.CoolDesTemp = zoneSizingInput.CoolDesTemp;
    1302         3684 :     zsFinalSizing.HeatDesTemp = zoneSizingInput.HeatDesTemp;
    1303         3684 :     zsFinalSizing.CoolDesTempDiff = zoneSizingInput.CoolDesTempDiff;
    1304         3684 :     zsFinalSizing.HeatDesTempDiff = zoneSizingInput.HeatDesTempDiff;
    1305         3684 :     zsFinalSizing.CoolDesHumRat = zoneSizingInput.CoolDesHumRat;
    1306         3684 :     zsFinalSizing.HeatDesHumRat = zoneSizingInput.HeatDesHumRat;
    1307         3684 :     zsFinalSizing.ZoneAirDistributionIndex = zoneSizingInput.ZoneAirDistributionIndex;
    1308         3684 :     zsFinalSizing.ZoneDesignSpecOAIndex = zoneSizingInput.ZoneDesignSpecOAIndex;
    1309         3684 :     zsFinalSizing.CoolAirDesMethod = zoneSizingInput.CoolAirDesMethod;
    1310         3684 :     zsFinalSizing.HeatAirDesMethod = zoneSizingInput.HeatAirDesMethod;
    1311         3684 :     zsFinalSizing.InpDesCoolAirFlow = zoneSizingInput.DesCoolAirFlow;
    1312         3684 :     zsFinalSizing.DesCoolMinAirFlowPerArea = zoneSizingInput.DesCoolMinAirFlowPerArea;
    1313         3684 :     zsFinalSizing.DesCoolMinAirFlow = zoneSizingInput.DesCoolMinAirFlow;
    1314         3684 :     zsFinalSizing.DesCoolMinAirFlowFrac = zoneSizingInput.DesCoolMinAirFlowFrac;
    1315         3684 :     zsFinalSizing.InpDesHeatAirFlow = zoneSizingInput.DesHeatAirFlow;
    1316         3684 :     zsFinalSizing.DesHeatMaxAirFlowPerArea = zoneSizingInput.DesHeatMaxAirFlowPerArea;
    1317         3684 :     zsFinalSizing.DesHeatMaxAirFlow = zoneSizingInput.DesHeatMaxAirFlow;
    1318         3684 :     zsFinalSizing.DesHeatMaxAirFlowFrac = zoneSizingInput.DesHeatMaxAirFlowFrac;
    1319         3684 :     zsFinalSizing.HeatSizingFactor = zoneSizingInput.HeatSizingFactor;
    1320         3684 :     zsFinalSizing.CoolSizingFactor = zoneSizingInput.CoolSizingFactor;
    1321         3684 :     zsFinalSizing.AccountForDOAS = zoneSizingInput.AccountForDOAS;
    1322         3684 :     zsFinalSizing.DOASControlStrategy = zoneSizingInput.DOASControlStrategy;
    1323         3684 :     zsFinalSizing.DOASLowSetpoint = zoneSizingInput.DOASLowSetpoint;
    1324         3684 :     zsFinalSizing.DOASHighSetpoint = zoneSizingInput.DOASHighSetpoint;
    1325         3684 :     zsFinalSizing.ZoneADEffCooling = zoneSizingInput.ZoneADEffCooling;
    1326         3684 :     zsFinalSizing.ZoneADEffHeating = zoneSizingInput.ZoneADEffHeating;
    1327         3684 :     zsFinalSizing.ZoneSecondaryRecirculation = zoneSizingInput.ZoneSecondaryRecirculation;
    1328         3684 :     zsFinalSizing.ZoneVentilationEff = zoneSizingInput.ZoneVentilationEff;
    1329         3684 :     zsFinalSizing.spaceConcurrence = zoneSizingInput.spaceConcurrence;
    1330         3684 :     zsFinalSizing.zoneSizingMethod = zoneSizingInput.zoneSizingMethod;
    1331         3684 :     zsFinalSizing.zoneLatentSizing = zoneSizingInput.zoneLatentSizing;
    1332         3684 :     zsFinalSizing.zoneRHDehumidifySetPoint = zoneSizingInput.zoneRHDehumidifySetPoint;
    1333         3684 :     zsFinalSizing.zoneRHHumidifySetPoint = zoneSizingInput.zoneRHHumidifySetPoint;
    1334         3684 :     zsFinalSizing.zoneRHDehumidifySched = zoneSizingInput.zoneRHDehumidifySched;
    1335         3684 :     zsFinalSizing.zoneRHHumidifySched = zoneSizingInput.zoneRHHumidifySched;
    1336         3684 :     zsFinalSizing.ZnLatCoolDgnSAMethod = zoneSizingInput.ZnLatCoolDgnSAMethod;
    1337         3684 :     zsFinalSizing.LatentCoolDesHumRat = zoneSizingInput.LatentCoolDesHumRat;
    1338         3684 :     zsFinalSizing.CoolDesHumRatDiff = zoneSizingInput.CoolDesHumRatDiff;
    1339         3684 :     zsFinalSizing.ZnLatHeatDgnSAMethod = zoneSizingInput.ZnLatHeatDgnSAMethod;
    1340         3684 :     zsFinalSizing.LatentHeatDesHumRat = zoneSizingInput.LatentHeatDesHumRat;
    1341         3684 :     zsFinalSizing.HeatDesHumRatDiff = zoneSizingInput.HeatDesHumRatDiff;
    1342         3684 :     zsCalcFinalSizing.ZnCoolDgnSAMethod = zoneSizingInput.ZnCoolDgnSAMethod;
    1343         3684 :     zsCalcFinalSizing.ZnHeatDgnSAMethod = zoneSizingInput.ZnHeatDgnSAMethod;
    1344         3684 :     zsCalcFinalSizing.CoolDesTemp = zoneSizingInput.CoolDesTemp;
    1345         3684 :     zsCalcFinalSizing.HeatDesTemp = zoneSizingInput.HeatDesTemp;
    1346         3684 :     zsCalcFinalSizing.CoolDesTempDiff = zoneSizingInput.CoolDesTempDiff;
    1347         3684 :     zsCalcFinalSizing.HeatDesTempDiff = zoneSizingInput.HeatDesTempDiff;
    1348         3684 :     zsCalcFinalSizing.CoolDesHumRat = zoneSizingInput.CoolDesHumRat;
    1349         3684 :     zsCalcFinalSizing.HeatDesHumRat = zoneSizingInput.HeatDesHumRat;
    1350         3684 :     zsCalcFinalSizing.ZoneAirDistributionIndex = zoneSizingInput.ZoneAirDistributionIndex;
    1351         3684 :     zsCalcFinalSizing.ZoneDesignSpecOAIndex = zoneSizingInput.ZoneDesignSpecOAIndex;
    1352         3684 :     zsCalcFinalSizing.CoolAirDesMethod = zoneSizingInput.CoolAirDesMethod;
    1353         3684 :     zsCalcFinalSizing.HeatAirDesMethod = zoneSizingInput.HeatAirDesMethod;
    1354         3684 :     zsCalcFinalSizing.InpDesCoolAirFlow = zoneSizingInput.DesCoolAirFlow;
    1355         3684 :     zsCalcFinalSizing.DesCoolMinAirFlowPerArea = zoneSizingInput.DesCoolMinAirFlowPerArea;
    1356         3684 :     zsCalcFinalSizing.DesCoolMinAirFlow = zoneSizingInput.DesCoolMinAirFlow;
    1357         3684 :     zsCalcFinalSizing.DesCoolMinAirFlowFrac = zoneSizingInput.DesCoolMinAirFlowFrac;
    1358         3684 :     zsCalcFinalSizing.InpDesHeatAirFlow = zoneSizingInput.DesHeatAirFlow;
    1359         3684 :     zsCalcFinalSizing.DesHeatMaxAirFlowPerArea = zoneSizingInput.DesHeatMaxAirFlowPerArea;
    1360         3684 :     zsCalcFinalSizing.DesHeatMaxAirFlow = zoneSizingInput.DesHeatMaxAirFlow;
    1361         3684 :     zsCalcFinalSizing.DesHeatMaxAirFlowFrac = zoneSizingInput.DesHeatMaxAirFlowFrac;
    1362         3684 :     zsCalcFinalSizing.HeatSizingFactor = zoneSizingInput.HeatSizingFactor;
    1363         3684 :     zsCalcFinalSizing.CoolSizingFactor = zoneSizingInput.CoolSizingFactor;
    1364         3684 :     zsCalcFinalSizing.AccountForDOAS = zoneSizingInput.AccountForDOAS;
    1365         3684 :     zsCalcFinalSizing.DOASControlStrategy = zoneSizingInput.DOASControlStrategy;
    1366         3684 :     zsCalcFinalSizing.DOASLowSetpoint = zoneSizingInput.DOASLowSetpoint;
    1367         3684 :     zsCalcFinalSizing.DOASHighSetpoint = zoneSizingInput.DOASHighSetpoint;
    1368         3684 :     zsCalcFinalSizing.ZoneADEffCooling = zoneSizingInput.ZoneADEffCooling;
    1369         3684 :     zsCalcFinalSizing.ZoneADEffHeating = zoneSizingInput.ZoneADEffHeating;
    1370         3684 :     zsCalcFinalSizing.spaceConcurrence = zoneSizingInput.spaceConcurrence;
    1371         3684 :     zsCalcFinalSizing.zoneSizingMethod = zoneSizingInput.zoneSizingMethod;
    1372         3684 :     zsCalcFinalSizing.zoneLatentSizing = zoneSizingInput.zoneLatentSizing;
    1373         3684 :     zsCalcFinalSizing.zoneRHDehumidifySetPoint = zoneSizingInput.zoneRHDehumidifySetPoint;
    1374         3684 :     zsCalcFinalSizing.zoneRHHumidifySetPoint = zoneSizingInput.zoneRHHumidifySetPoint;
    1375         3684 :     zsCalcFinalSizing.zoneRHDehumidifySched = zoneSizingInput.zoneRHDehumidifySched;
    1376         3684 :     zsCalcFinalSizing.zoneRHHumidifySched = zoneSizingInput.zoneRHHumidifySched;
    1377         3684 :     zsCalcFinalSizing.ZnLatCoolDgnSAMethod = zoneSizingInput.ZnLatCoolDgnSAMethod;
    1378         3684 :     zsCalcFinalSizing.LatentCoolDesHumRat = zoneSizingInput.LatentCoolDesHumRat;
    1379         3684 :     zsCalcFinalSizing.CoolDesHumRatDiff = zoneSizingInput.CoolDesHumRatDiff;
    1380         3684 :     zsCalcFinalSizing.ZnLatHeatDgnSAMethod = zoneSizingInput.ZnLatHeatDgnSAMethod;
    1381         3684 :     zsCalcFinalSizing.LatentHeatDesHumRat = zoneSizingInput.LatentHeatDesHumRat;
    1382         3684 :     zsCalcFinalSizing.HeatDesHumRatDiff = zoneSizingInput.HeatDesHumRatDiff;
    1383              : 
    1384         3684 :     zsFinalSizing.allocateMemberArrays(state.dataZoneEquipmentManager->NumOfTimeStepInDay);
    1385         3684 :     zsCalcFinalSizing.allocateMemberArrays(state.dataZoneEquipmentManager->NumOfTimeStepInDay);
    1386         3684 : }
    1387           27 : void RezeroZoneSizingArrays(EnergyPlusData &state)
    1388              : {
    1389              :     // Zero zone sizing arrays between the pulse and normal sizing.
    1390           27 :     DisplayString(state, "Re-zeroing zone sizing arrays");
    1391              : 
    1392          242 :     for (int ctrlZoneNum = 1; ctrlZoneNum <= state.dataGlobal->NumOfZones; ++ctrlZoneNum) {
    1393          215 :         if (!state.dataZoneEquip->ZoneEquipConfig(ctrlZoneNum).IsControlled) {
    1394           30 :             continue;
    1395              :         }
    1396          555 :         for (int desDayNum = 1; desDayNum <= state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays; ++desDayNum) {
    1397          370 :             state.dataSize->ZoneSizing(desDayNum, ctrlZoneNum).zeroMemberData();
    1398          370 :             state.dataSize->CalcZoneSizing(desDayNum, ctrlZoneNum).zeroMemberData();
    1399              :         }
    1400          185 :         state.dataSize->CalcFinalZoneSizing(ctrlZoneNum).zeroMemberData();
    1401          185 :         state.dataSize->FinalZoneSizing(ctrlZoneNum).zeroMemberData();
    1402              :     }
    1403           27 :     if (state.dataHeatBal->doSpaceHeatBalanceSizing) {
    1404           18 :         for (int spaceNum = 1; spaceNum <= state.dataGlobal->numSpaces; ++spaceNum) {
    1405           16 :             if (!state.dataZoneEquip->ZoneEquipConfig(state.dataHeatBal->space(spaceNum).zoneNum).IsControlled) {
    1406            2 :                 continue;
    1407              :             }
    1408           42 :             for (int desDayNum = 1; desDayNum <= state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays; ++desDayNum) {
    1409           28 :                 state.dataSize->SpaceSizing(desDayNum, spaceNum).zeroMemberData();
    1410           28 :                 state.dataSize->CalcSpaceSizing(desDayNum, spaceNum).zeroMemberData();
    1411              :             }
    1412           14 :             state.dataSize->CalcFinalSpaceSizing(spaceNum).zeroMemberData();
    1413           14 :             state.dataSize->FinalSpaceSizing(spaceNum).zeroMemberData();
    1414              :         }
    1415              :     }
    1416           27 : }
    1417         8416 : void updateZoneSizingBeginDay(EnergyPlusData const &state, DataSizing::ZoneSizingData &zsCalcSizing)
    1418              : {
    1419         8416 :     zsCalcSizing.CoolDesDay = state.dataEnvrn->EnvironmentName;
    1420         8416 :     zsCalcSizing.HeatDesDay = state.dataEnvrn->EnvironmentName;
    1421         8416 :     zsCalcSizing.DesHeatDens = state.dataEnvrn->StdRhoAir;
    1422         8416 :     zsCalcSizing.DesCoolDens = state.dataEnvrn->StdRhoAir;
    1423         8416 :     zsCalcSizing.HeatDDNum = state.dataSize->CurOverallSimDay;
    1424         8416 :     zsCalcSizing.CoolDDNum = state.dataSize->CurOverallSimDay;
    1425         8416 :     zsCalcSizing.CoolNoDOASDesDay = state.dataEnvrn->EnvironmentName;
    1426         8416 :     zsCalcSizing.HeatNoDOASDesDay = state.dataEnvrn->EnvironmentName;
    1427         8416 :     zsCalcSizing.LatCoolDesDay = state.dataEnvrn->EnvironmentName;
    1428         8416 :     zsCalcSizing.LatHeatDesDay = state.dataEnvrn->EnvironmentName;
    1429         8416 :     zsCalcSizing.LatCoolNoDOASDesDay = state.dataEnvrn->EnvironmentName;
    1430         8416 :     zsCalcSizing.LatHeatNoDOASDesDay = state.dataEnvrn->EnvironmentName;
    1431         8416 :     zsCalcSizing.CoolNoDOASDDNum = state.dataSize->CurOverallSimDay;
    1432         8416 :     zsCalcSizing.HeatNoDOASDDNum = state.dataSize->CurOverallSimDay;
    1433         8416 :     zsCalcSizing.LatentCoolDDNum = state.dataSize->CurOverallSimDay;
    1434         8416 :     zsCalcSizing.LatentHeatDDNum = state.dataSize->CurOverallSimDay;
    1435         8416 :     zsCalcSizing.LatentCoolNoDOASDDNum = state.dataSize->CurOverallSimDay;
    1436         8416 :     zsCalcSizing.LatentHeatNoDOASDDNum = state.dataSize->CurOverallSimDay;
    1437         8416 :     zsCalcSizing.CoolSizingType = "Cooling"; // string reported to eio
    1438         8416 :     zsCalcSizing.HeatSizingType = "Heating"; // string reported to eio
    1439         8416 : }
    1440              : 
    1441      1188120 : void updateZoneSizingDuringDay(DataSizing::ZoneSizingData &zsSizing,
    1442              :                                DataSizing::ZoneSizingData &zsCalcSizing,
    1443              :                                Real64 const tstatHi,
    1444              :                                Real64 const tstatLo,
    1445              :                                Real64 &sizTstatHi,
    1446              :                                Real64 &sizTstatLo,
    1447              :                                int const timeStepInDay,
    1448              :                                Real64 const fracTimeStepZone)
    1449              : {
    1450      1188120 :     if (tstatHi > 0.0 && tstatHi > sizTstatHi) {
    1451         3859 :         sizTstatHi = tstatHi;
    1452              :     }
    1453      1188120 :     if (tstatLo > 0.0 && tstatLo < sizTstatHi) {
    1454       967160 :         sizTstatLo = tstatLo;
    1455              :     }
    1456      1188120 :     zsSizing.DesHeatSetPtSeq(timeStepInDay) = tstatLo;
    1457      1188120 :     zsSizing.HeatTstatTempSeq(timeStepInDay) = zsCalcSizing.HeatTstatTemp;
    1458      1188120 :     zsSizing.DesCoolSetPtSeq(timeStepInDay) = tstatHi;
    1459      1188120 :     zsSizing.CoolTstatTempSeq(timeStepInDay) = zsCalcSizing.CoolTstatTemp;
    1460      1188120 :     zsCalcSizing.HeatFlowSeq(timeStepInDay) += zsCalcSizing.HeatMassFlow * fracTimeStepZone;
    1461      1188120 :     zsCalcSizing.HeatLoadSeq(timeStepInDay) += zsCalcSizing.HeatLoad * fracTimeStepZone;
    1462      1188120 :     zsCalcSizing.HeatZoneTempSeq(timeStepInDay) += zsCalcSizing.HeatZoneTemp * fracTimeStepZone;
    1463      1188120 :     zsCalcSizing.HeatOutTempSeq(timeStepInDay) += zsCalcSizing.HeatOutTemp * fracTimeStepZone;
    1464      1188120 :     zsCalcSizing.HeatZoneRetTempSeq(timeStepInDay) += zsCalcSizing.HeatZoneRetTemp * fracTimeStepZone;
    1465      1188120 :     zsCalcSizing.HeatZoneHumRatSeq(timeStepInDay) += zsCalcSizing.HeatZoneHumRat * fracTimeStepZone;
    1466      1188120 :     zsCalcSizing.HeatOutHumRatSeq(timeStepInDay) += zsCalcSizing.HeatOutHumRat * fracTimeStepZone;
    1467      1188120 :     zsCalcSizing.CoolFlowSeq(timeStepInDay) += zsCalcSizing.CoolMassFlow * fracTimeStepZone;
    1468      1188120 :     zsCalcSizing.CoolLoadSeq(timeStepInDay) += zsCalcSizing.CoolLoad * fracTimeStepZone;
    1469      1188120 :     zsCalcSizing.CoolZoneTempSeq(timeStepInDay) += zsCalcSizing.CoolZoneTemp * fracTimeStepZone;
    1470      1188120 :     zsCalcSizing.CoolOutTempSeq(timeStepInDay) += zsCalcSizing.CoolOutTemp * fracTimeStepZone;
    1471      1188120 :     zsCalcSizing.CoolZoneRetTempSeq(timeStepInDay) += zsCalcSizing.CoolZoneRetTemp * fracTimeStepZone;
    1472      1188120 :     zsCalcSizing.CoolZoneHumRatSeq(timeStepInDay) += zsCalcSizing.CoolZoneHumRat * fracTimeStepZone;
    1473      1188120 :     zsCalcSizing.CoolOutHumRatSeq(timeStepInDay) += zsCalcSizing.CoolOutHumRat * fracTimeStepZone;
    1474      1188120 :     zsCalcSizing.DOASHeatLoadSeq(timeStepInDay) += zsCalcSizing.DOASHeatLoad * fracTimeStepZone;
    1475      1188120 :     zsCalcSizing.DOASCoolLoadSeq(timeStepInDay) += zsCalcSizing.DOASCoolLoad * fracTimeStepZone;
    1476      1188120 :     zsCalcSizing.DOASHeatAddSeq(timeStepInDay) += zsCalcSizing.DOASHeatAdd * fracTimeStepZone;
    1477      1188120 :     zsCalcSizing.DOASLatAddSeq(timeStepInDay) += zsCalcSizing.DOASLatAdd * fracTimeStepZone;
    1478      1188120 :     zsCalcSizing.DOASSupMassFlowSeq(timeStepInDay) += zsCalcSizing.DOASSupMassFlow * fracTimeStepZone;
    1479      1188120 :     zsCalcSizing.DOASSupTempSeq(timeStepInDay) += zsCalcSizing.DOASSupTemp * fracTimeStepZone;
    1480      1188120 :     zsCalcSizing.DOASSupHumRatSeq(timeStepInDay) += zsCalcSizing.DOASSupHumRat * fracTimeStepZone;
    1481      1188120 :     zsCalcSizing.DOASTotCoolLoadSeq(timeStepInDay) += zsCalcSizing.DOASTotCoolLoad * fracTimeStepZone;
    1482      1188120 :     if (zsCalcSizing.zoneLatentSizing) {
    1483         2716 :         zsCalcSizing.LatentHeatLoadSeq(timeStepInDay) += zsCalcSizing.HeatLatentLoad * fracTimeStepZone;
    1484         2716 :         zsCalcSizing.LatentHeatFlowSeq(timeStepInDay) += zsCalcSizing.ZoneHeatLatentMassFlow * fracTimeStepZone;
    1485         2716 :         zsCalcSizing.LatentCoolLoadSeq(timeStepInDay) += zsCalcSizing.CoolLatentLoad * fracTimeStepZone;
    1486         2716 :         zsCalcSizing.LatentCoolFlowSeq(timeStepInDay) += zsCalcSizing.ZoneCoolLatentMassFlow * fracTimeStepZone;
    1487         2716 :         zsCalcSizing.CoolLatentLoadNoDOASSeq(timeStepInDay) += zsCalcSizing.CoolLatentLoadNoDOAS * fracTimeStepZone;
    1488         2716 :         zsCalcSizing.HeatLatentLoadNoDOASSeq(timeStepInDay) += zsCalcSizing.HeatLatentLoadNoDOAS * fracTimeStepZone;
    1489         2716 :         zsCalcSizing.CoolLoadNoDOASSeq(timeStepInDay) += zsCalcSizing.CoolLoadNoDOAS * fracTimeStepZone;
    1490         2716 :         zsCalcSizing.HeatLoadNoDOASSeq(timeStepInDay) += zsCalcSizing.HeatLoadNoDOAS * fracTimeStepZone;
    1491              :     }
    1492      1188120 : }
    1493              : 
    1494        16691 : void updateZoneSizingEndDayMovingAvg(DataSizing::ZoneSizingData &zsCalcSizing, int const numTimeStepsInAvg)
    1495              : {
    1496        16691 :     General::MovingAvg(zsCalcSizing.CoolFlowSeq, numTimeStepsInAvg);
    1497        16691 :     General::MovingAvg(zsCalcSizing.CoolLoadSeq, numTimeStepsInAvg);
    1498        16691 :     General::MovingAvg(zsCalcSizing.HeatFlowSeq, numTimeStepsInAvg);
    1499        16691 :     General::MovingAvg(zsCalcSizing.HeatLoadSeq, numTimeStepsInAvg);
    1500        16691 :     General::MovingAvg(zsCalcSizing.CoolZoneRetTempSeq, numTimeStepsInAvg);
    1501        16691 :     General::MovingAvg(zsCalcSizing.HeatZoneRetTempSeq, numTimeStepsInAvg);
    1502        16691 :     General::MovingAvg(zsCalcSizing.DOASHeatAddSeq, numTimeStepsInAvg);
    1503        16691 :     General::MovingAvg(zsCalcSizing.DOASLatAddSeq, numTimeStepsInAvg);
    1504        16691 :     General::MovingAvg(zsCalcSizing.CoolLatentLoadNoDOASSeq, numTimeStepsInAvg);
    1505        16691 :     General::MovingAvg(zsCalcSizing.HeatLatentLoadNoDOASSeq, numTimeStepsInAvg);
    1506        16691 :     General::MovingAvg(zsCalcSizing.CoolLoadNoDOASSeq, numTimeStepsInAvg);
    1507        16691 :     General::MovingAvg(zsCalcSizing.HeatLoadNoDOASSeq, numTimeStepsInAvg);
    1508              : 
    1509        16691 :     if (zsCalcSizing.zoneLatentSizing) {
    1510           52 :         General::MovingAvg(zsCalcSizing.LatentHeatLoadSeq, numTimeStepsInAvg);
    1511           52 :         General::MovingAvg(zsCalcSizing.LatentHeatFlowSeq, numTimeStepsInAvg);
    1512           52 :         General::MovingAvg(zsCalcSizing.LatentCoolLoadSeq, numTimeStepsInAvg);
    1513           52 :         General::MovingAvg(zsCalcSizing.LatentCoolFlowSeq, numTimeStepsInAvg);
    1514              :     }
    1515        16691 : }
    1516              : 
    1517        16691 : void updateZoneSizingEndDay(DataSizing::ZoneSizingData &zsCalcSizing,
    1518              :                             DataSizing::ZoneSizingData &zsCalcFinalSizing,
    1519              :                             int const numTimeStepInDay,
    1520              :                             DataSizing::DesDayWeathData const &desDayWeath,
    1521              :                             Real64 const stdRhoAir)
    1522              : {
    1523        16691 :     zsCalcFinalSizing.CoolSizingType = zsCalcSizing.CoolSizingType;
    1524        16691 :     zsCalcFinalSizing.HeatSizingType = zsCalcSizing.HeatSizingType;
    1525              : 
    1526              :     // save the sequence values at the heating peak
    1527      2033699 :     for (int TimeStepIndex = 1; TimeStepIndex <= numTimeStepInDay; ++TimeStepIndex) {
    1528      2017008 :         if (zsCalcSizing.HeatLoadSeq(TimeStepIndex) > zsCalcSizing.DesHeatLoad) {
    1529       142469 :             zsCalcSizing.DesHeatLoad = zsCalcSizing.HeatLoadSeq(TimeStepIndex);
    1530       142469 :             zsCalcSizing.DesHeatMassFlow = zsCalcSizing.HeatFlowSeq(TimeStepIndex);
    1531       142469 :             zsCalcSizing.ZoneTempAtHeatPeak = zsCalcSizing.HeatZoneTempSeq(TimeStepIndex);
    1532       142469 :             zsCalcSizing.OutTempAtHeatPeak = zsCalcSizing.HeatOutTempSeq(TimeStepIndex);
    1533       142469 :             zsCalcSizing.ZoneRetTempAtHeatPeak = zsCalcSizing.HeatZoneRetTempSeq(TimeStepIndex);
    1534       142469 :             zsCalcSizing.ZoneHumRatAtHeatPeak = zsCalcSizing.HeatZoneHumRatSeq(TimeStepIndex);
    1535       142469 :             zsCalcSizing.OutHumRatAtHeatPeak = zsCalcSizing.HeatOutHumRatSeq(TimeStepIndex);
    1536       142469 :             zsCalcSizing.TimeStepNumAtHeatMax = TimeStepIndex;
    1537              :         }
    1538              :     }
    1539              :     // save the sequence values at the latent heating peak
    1540        16691 :     if (zsCalcSizing.zoneLatentSizing) {
    1541         5044 :         for (int TimeStepIndex = 1; TimeStepIndex <= numTimeStepInDay; ++TimeStepIndex) {
    1542         4992 :             if (zsCalcSizing.LatentHeatLoadSeq(TimeStepIndex) > zsCalcSizing.DesLatentHeatLoad) {
    1543           63 :                 zsCalcSizing.DesLatentHeatLoad = zsCalcSizing.LatentHeatLoadSeq(TimeStepIndex);
    1544           63 :                 zsCalcSizing.DesLatentHeatMassFlow = zsCalcSizing.LatentHeatFlowSeq(TimeStepIndex);
    1545           63 :                 zsCalcSizing.ZoneHeatLatentMassFlow = zsCalcSizing.LatentHeatFlowSeq(TimeStepIndex);
    1546           63 :                 zsCalcSizing.ZoneTempAtLatentHeatPeak = zsCalcSizing.HeatZoneTempSeq(TimeStepIndex);
    1547           63 :                 zsCalcSizing.OutTempAtLatentHeatPeak = zsCalcSizing.HeatOutTempSeq(TimeStepIndex);
    1548           63 :                 zsCalcSizing.ZoneHumRatAtLatentHeatPeak = zsCalcSizing.HeatZoneHumRatSeq(TimeStepIndex);
    1549           63 :                 zsCalcSizing.OutHumRatAtLatentHeatPeak = zsCalcSizing.HeatOutHumRatSeq(TimeStepIndex);
    1550           63 :                 zsCalcSizing.ZoneRetTempAtLatentHeatPeak = zsCalcSizing.HeatZoneRetTempSeq(TimeStepIndex);
    1551           63 :                 zsCalcSizing.TimeStepNumAtLatentHeatMax = TimeStepIndex;
    1552              :             }
    1553              :         }
    1554              :     }
    1555      2033699 :     for (int TimeStepIndex = 1; TimeStepIndex <= numTimeStepInDay; ++TimeStepIndex) {
    1556              :         // select largest load from NoDOAS arrays
    1557      2017008 :         if (zsCalcSizing.HeatLoadNoDOASSeq(TimeStepIndex) > zsCalcSizing.DesHeatLoadNoDOAS) {
    1558          557 :             zsCalcSizing.DesHeatLoadNoDOAS = zsCalcSizing.HeatLoadNoDOASSeq(TimeStepIndex);
    1559          557 :             zsCalcSizing.TimeStepNumAtHeatNoDOASMax = TimeStepIndex;
    1560              :         }
    1561      2017008 :         if (zsCalcSizing.HeatLatentLoadNoDOASSeq(TimeStepIndex) > zsCalcSizing.DesLatentHeatLoadNoDOAS) {
    1562           63 :             zsCalcSizing.DesLatentHeatLoadNoDOAS = zsCalcSizing.HeatLatentLoadNoDOASSeq(TimeStepIndex);
    1563           63 :             zsCalcSizing.TimeStepNumAtLatentHeatNoDOASMax = TimeStepIndex;
    1564              :         }
    1565      2017008 :         if (zsCalcSizing.CoolLoadNoDOASSeq(TimeStepIndex) > zsCalcSizing.DesCoolLoadNoDOAS) {
    1566          323 :             zsCalcSizing.DesCoolLoadNoDOAS = zsCalcSizing.CoolLoadNoDOASSeq(TimeStepIndex);
    1567          323 :             zsCalcSizing.TimeStepNumAtCoolNoDOASMax = TimeStepIndex;
    1568              :         }
    1569      2017008 :         if (zsCalcSizing.CoolLatentLoadNoDOASSeq(TimeStepIndex) > zsCalcSizing.DesLatentCoolLoadNoDOAS) {
    1570          282 :             zsCalcSizing.DesLatentCoolLoadNoDOAS = zsCalcSizing.CoolLatentLoadNoDOASSeq(TimeStepIndex);
    1571          282 :             zsCalcSizing.TimeStepNumAtLatentCoolNoDOASMax = TimeStepIndex;
    1572              :         }
    1573              :     }
    1574        16691 :     if (zsCalcSizing.DesHeatMassFlow > 0.0) {
    1575         3889 :         zsCalcSizing.DesHeatVolFlow = zsCalcSizing.DesHeatMassFlow / zsCalcSizing.DesHeatDens;
    1576         3889 :         Real64 OAFrac = zsCalcSizing.MinOA / max(zsCalcSizing.DesHeatVolFlow, HVAC::SmallMassFlow);
    1577         3889 :         OAFrac = min(1.0, max(0.0, OAFrac));
    1578         3889 :         int TimeStepAtPeak = zsCalcSizing.TimeStepNumAtHeatMax;
    1579         3889 :         zsCalcSizing.DesHeatCoilInTemp = OAFrac * desDayWeath.Temp(TimeStepAtPeak) + (1.0 - OAFrac) * zsCalcSizing.ZoneTempAtHeatPeak;
    1580         3889 :         zsCalcSizing.DesHeatCoilInHumRat = OAFrac * desDayWeath.HumRat(TimeStepAtPeak) + (1.0 - OAFrac) * zsCalcSizing.ZoneHumRatAtHeatPeak;
    1581              :     }
    1582        16691 :     if (zsCalcSizing.zoneLatentSizing && zsCalcSizing.DesLatentHeatMassFlow > 0.0) {
    1583           14 :         zsCalcSizing.DesLatentHeatVolFlow = zsCalcSizing.DesLatentHeatMassFlow / stdRhoAir;
    1584           14 :         Real64 OAFrac = zsCalcSizing.MinOA / max(zsCalcSizing.DesHeatVolFlow, HVAC::SmallMassFlow);
    1585           14 :         OAFrac = min(1.0, max(0.0, OAFrac));
    1586           14 :         int TimeStepAtPeak = zsCalcSizing.TimeStepNumAtLatentHeatMax;
    1587           14 :         zsCalcSizing.DesLatentHeatCoilInTemp = OAFrac * desDayWeath.Temp(TimeStepAtPeak) + (1.0 - OAFrac) * zsCalcSizing.ZoneTempAtHeatPeak;
    1588           14 :         zsCalcSizing.DesLatentHeatCoilInHumRat = OAFrac * desDayWeath.HumRat(TimeStepAtPeak) + (1.0 - OAFrac) * zsCalcSizing.ZoneHumRatAtHeatPeak;
    1589              :     }
    1590              :     // save the sequence values at the cooling peak
    1591      2033699 :     for (int TimeStepIndex = 1; TimeStepIndex <= numTimeStepInDay; ++TimeStepIndex) {
    1592      2017008 :         if (zsCalcSizing.CoolLoadSeq(TimeStepIndex) > zsCalcSizing.DesCoolLoad) {
    1593       157713 :             zsCalcSizing.DesCoolLoad = zsCalcSizing.CoolLoadSeq(TimeStepIndex);
    1594       157713 :             zsCalcSizing.DesCoolMassFlow = zsCalcSizing.CoolFlowSeq(TimeStepIndex);
    1595       157713 :             zsCalcSizing.ZoneTempAtCoolPeak = zsCalcSizing.CoolZoneTempSeq(TimeStepIndex);
    1596       157713 :             zsCalcSizing.OutTempAtCoolPeak = zsCalcSizing.CoolOutTempSeq(TimeStepIndex);
    1597       157713 :             zsCalcSizing.ZoneRetTempAtCoolPeak = zsCalcSizing.CoolZoneRetTempSeq(TimeStepIndex);
    1598       157713 :             zsCalcSizing.ZoneHumRatAtCoolPeak = zsCalcSizing.CoolZoneHumRatSeq(TimeStepIndex);
    1599       157713 :             zsCalcSizing.OutHumRatAtCoolPeak = zsCalcSizing.CoolOutHumRatSeq(TimeStepIndex);
    1600       157713 :             zsCalcSizing.TimeStepNumAtCoolMax = TimeStepIndex;
    1601              :         }
    1602              :     }
    1603        16691 :     if (zsCalcSizing.zoneLatentSizing) {
    1604         5044 :         for (int TimeStepIndex = 1; TimeStepIndex <= numTimeStepInDay; ++TimeStepIndex) {
    1605         4992 :             if (zsCalcSizing.LatentCoolLoadSeq(TimeStepIndex) > zsCalcSizing.DesLatentCoolLoad) {
    1606          282 :                 zsCalcSizing.DesLatentCoolLoad = zsCalcSizing.LatentCoolLoadSeq(TimeStepIndex);
    1607          282 :                 zsCalcSizing.DesLatentCoolMassFlow = zsCalcSizing.LatentCoolFlowSeq(TimeStepIndex);
    1608          282 :                 zsCalcSizing.ZoneTempAtLatentCoolPeak = zsCalcSizing.CoolZoneTempSeq(TimeStepIndex);
    1609          282 :                 zsCalcSizing.OutTempAtLatentCoolPeak = zsCalcSizing.CoolOutTempSeq(TimeStepIndex);
    1610          282 :                 zsCalcSizing.ZoneHumRatAtLatentCoolPeak = zsCalcSizing.CoolZoneHumRatSeq(TimeStepIndex);
    1611          282 :                 zsCalcSizing.OutHumRatAtLatentCoolPeak = zsCalcSizing.CoolOutHumRatSeq(TimeStepIndex);
    1612          282 :                 zsCalcSizing.ZoneRetTempAtLatentCoolPeak = zsCalcSizing.CoolZoneRetTempSeq(TimeStepIndex);
    1613          282 :                 zsCalcSizing.TimeStepNumAtLatentCoolMax = TimeStepIndex;
    1614              :             }
    1615              :         }
    1616              :     }
    1617        16691 :     if (zsCalcSizing.DesCoolMassFlow > 0.0) {
    1618         4580 :         zsCalcSizing.DesCoolVolFlow = zsCalcSizing.DesCoolMassFlow / zsCalcSizing.DesCoolDens;
    1619         4580 :         Real64 OAFrac = zsCalcSizing.MinOA / max(zsCalcSizing.DesCoolVolFlow, HVAC::SmallMassFlow);
    1620         4580 :         OAFrac = min(1.0, max(0.0, OAFrac));
    1621         4580 :         int TimeStepAtPeak = zsCalcSizing.TimeStepNumAtCoolMax;
    1622         4580 :         zsCalcSizing.DesCoolCoilInTemp = OAFrac * desDayWeath.Temp(TimeStepAtPeak) + (1.0 - OAFrac) * zsCalcSizing.ZoneTempAtCoolPeak;
    1623         4580 :         zsCalcSizing.DesCoolCoilInHumRat = OAFrac * desDayWeath.HumRat(TimeStepAtPeak) + (1.0 - OAFrac) * zsCalcSizing.ZoneHumRatAtCoolPeak;
    1624              :     }
    1625        16691 :     if (zsCalcSizing.zoneLatentSizing && zsCalcSizing.DesLatentCoolMassFlow > 0.0) {
    1626           19 :         zsCalcSizing.DesLatentCoolVolFlow = zsCalcSizing.DesLatentCoolMassFlow / stdRhoAir;
    1627           19 :         Real64 OAFrac = zsCalcSizing.MinOA / max(zsCalcSizing.DesCoolVolFlow, HVAC::SmallMassFlow);
    1628           19 :         OAFrac = min(1.0, max(0.0, OAFrac));
    1629           19 :         int TimeStepAtPeak = zsCalcSizing.TimeStepNumAtLatentCoolMax;
    1630           19 :         zsCalcSizing.DesLatentCoolCoilInTemp = OAFrac * desDayWeath.Temp(TimeStepAtPeak) + (1.0 - OAFrac) * zsCalcSizing.ZoneTempAtCoolPeak;
    1631           19 :         zsCalcSizing.DesLatentCoolCoilInHumRat = OAFrac * desDayWeath.HumRat(TimeStepAtPeak) + (1.0 - OAFrac) * zsCalcSizing.ZoneHumRatAtCoolPeak;
    1632              :     }
    1633              :     // from all the design periods, choose the one needing the most heating and save all its design variables in zsCalcFinalSizing
    1634        16691 :     if (zsCalcSizing.DesHeatVolFlow > zsCalcFinalSizing.DesHeatVolFlow) {
    1635         3686 :         zsCalcFinalSizing.DesHeatVolFlow = zsCalcSizing.DesHeatVolFlow;
    1636         3686 :         zsCalcFinalSizing.DesHeatLoad = zsCalcSizing.DesHeatLoad;
    1637         3686 :         zsCalcFinalSizing.DesHeatMassFlow = zsCalcSizing.DesHeatMassFlow;
    1638         3686 :         zsCalcFinalSizing.HeatDesDay = zsCalcSizing.HeatDesDay;
    1639         3686 :         zsCalcFinalSizing.DesHeatDens = zsCalcSizing.DesHeatDens;
    1640         3686 :         zsCalcFinalSizing.HeatFlowSeq = zsCalcSizing.HeatFlowSeq;
    1641         3686 :         zsCalcFinalSizing.HeatLoadSeq = zsCalcSizing.HeatLoadSeq;
    1642         3686 :         zsCalcFinalSizing.HeatZoneTempSeq = zsCalcSizing.HeatZoneTempSeq;
    1643         3686 :         zsCalcFinalSizing.HeatOutTempSeq = zsCalcSizing.HeatOutTempSeq;
    1644         3686 :         zsCalcFinalSizing.HeatZoneRetTempSeq = zsCalcSizing.HeatZoneRetTempSeq;
    1645         3686 :         zsCalcFinalSizing.HeatZoneHumRatSeq = zsCalcSizing.HeatZoneHumRatSeq;
    1646         3686 :         zsCalcFinalSizing.HeatOutHumRatSeq = zsCalcSizing.HeatOutHumRatSeq;
    1647         3686 :         zsCalcFinalSizing.ZoneTempAtHeatPeak = zsCalcSizing.ZoneTempAtHeatPeak;
    1648         3686 :         zsCalcFinalSizing.OutTempAtHeatPeak = zsCalcSizing.OutTempAtHeatPeak;
    1649         3686 :         zsCalcFinalSizing.ZoneRetTempAtHeatPeak = zsCalcSizing.ZoneRetTempAtHeatPeak;
    1650         3686 :         zsCalcFinalSizing.ZoneHumRatAtHeatPeak = zsCalcSizing.ZoneHumRatAtHeatPeak;
    1651         3686 :         zsCalcFinalSizing.OutHumRatAtHeatPeak = zsCalcSizing.OutHumRatAtHeatPeak;
    1652         3686 :         zsCalcFinalSizing.HeatDDNum = zsCalcSizing.HeatDDNum;
    1653         3686 :         zsCalcFinalSizing.cHeatDDDate = desDayWeath.DateString;
    1654         3686 :         zsCalcFinalSizing.TimeStepNumAtHeatMax = zsCalcSizing.TimeStepNumAtHeatMax;
    1655         3686 :         zsCalcFinalSizing.DesHeatCoilInTemp = zsCalcSizing.DesHeatCoilInTemp;
    1656         3686 :         zsCalcFinalSizing.DesHeatCoilInHumRat = zsCalcSizing.DesHeatCoilInHumRat;
    1657              :     } else {
    1658        13005 :         zsCalcFinalSizing.DesHeatDens = stdRhoAir;
    1659              :         // save design heating load when the there is design heating load and the design heating volume flow rate is zero, i.e., when
    1660              :         // design heating volume flow rate is set to zero due to heating supply air temp less than zone thermostat temperature
    1661        13005 :         if (zsCalcSizing.DesHeatLoad > zsCalcFinalSizing.DesHeatLoad) {
    1662            0 :             zsCalcFinalSizing.DesHeatLoad = zsCalcSizing.DesHeatLoad;
    1663            0 :             zsCalcFinalSizing.HeatDesDay = zsCalcSizing.HeatDesDay;
    1664            0 :             zsCalcFinalSizing.HeatLoadSeq = zsCalcSizing.HeatLoadSeq;
    1665            0 :             zsCalcFinalSizing.HeatZoneTempSeq = zsCalcSizing.HeatZoneTempSeq;
    1666            0 :             zsCalcFinalSizing.HeatOutTempSeq = zsCalcSizing.HeatOutTempSeq;
    1667            0 :             zsCalcFinalSizing.HeatZoneRetTempSeq = zsCalcSizing.HeatZoneRetTempSeq;
    1668            0 :             zsCalcFinalSizing.HeatZoneHumRatSeq = zsCalcSizing.HeatZoneHumRatSeq;
    1669            0 :             zsCalcFinalSizing.HeatOutHumRatSeq = zsCalcSizing.HeatOutHumRatSeq;
    1670            0 :             zsCalcFinalSizing.ZoneTempAtHeatPeak = zsCalcSizing.ZoneTempAtHeatPeak;
    1671            0 :             zsCalcFinalSizing.OutTempAtHeatPeak = zsCalcSizing.OutTempAtHeatPeak;
    1672            0 :             zsCalcFinalSizing.ZoneRetTempAtHeatPeak = zsCalcSizing.ZoneRetTempAtHeatPeak;
    1673            0 :             zsCalcFinalSizing.ZoneHumRatAtHeatPeak = zsCalcSizing.ZoneHumRatAtHeatPeak;
    1674            0 :             zsCalcFinalSizing.OutHumRatAtHeatPeak = zsCalcSizing.OutHumRatAtHeatPeak;
    1675            0 :             zsCalcFinalSizing.HeatDDNum = zsCalcSizing.HeatDDNum;
    1676            0 :             zsCalcFinalSizing.cHeatDDDate = desDayWeath.DateString;
    1677            0 :             zsCalcFinalSizing.TimeStepNumAtHeatMax = zsCalcSizing.TimeStepNumAtHeatMax;
    1678            0 :             zsCalcFinalSizing.DesHeatCoilInTemp = zsCalcSizing.DesHeatCoilInTemp;
    1679            0 :             zsCalcFinalSizing.DesHeatCoilInHumRat = zsCalcSizing.DesHeatCoilInHumRat;
    1680            0 :             zsCalcFinalSizing.HeatTstatTemp = zsCalcSizing.HeatTstatTemp;
    1681              :         }
    1682              :     }
    1683        16691 :     if (zsCalcSizing.zoneLatentSizing) {
    1684              :         // from all the design periods, choose the one needing the most latent heating and save all its design variables in
    1685              :         // zsCalcFinalSizing
    1686           52 :         if (zsCalcSizing.DesLatentHeatVolFlow > zsCalcFinalSizing.DesLatentHeatVolFlow) {
    1687           12 :             zsCalcFinalSizing.DesLatentHeatVolFlow = zsCalcSizing.DesLatentHeatVolFlow;
    1688           12 :             zsCalcFinalSizing.DesLatentHeatMassFlow = zsCalcSizing.ZoneHeatLatentMassFlow;
    1689           12 :             zsCalcFinalSizing.DesLatentHeatLoad = zsCalcSizing.DesLatentHeatLoad;
    1690           12 :             zsCalcFinalSizing.ZoneTempAtLatentHeatPeak = zsCalcSizing.ZoneTempAtLatentHeatPeak;
    1691           12 :             zsCalcFinalSizing.ZoneHumRatAtLatentHeatPeak = zsCalcSizing.ZoneHumRatAtLatentHeatPeak;
    1692           12 :             zsCalcFinalSizing.ZoneRetTempAtLatentHeatPeak = zsCalcSizing.ZoneRetTempAtLatentHeatPeak;
    1693           12 :             zsCalcFinalSizing.DesLatentHeatCoilInTemp = zsCalcSizing.DesLatentHeatCoilInTemp;
    1694           12 :             zsCalcFinalSizing.DesLatentHeatCoilInHumRat = zsCalcSizing.DesLatentHeatCoilInHumRat;
    1695           12 :             zsCalcFinalSizing.LatHeatDesDay = zsCalcSizing.LatHeatDesDay;
    1696           12 :             zsCalcFinalSizing.cLatentHeatDDDate = desDayWeath.DateString;
    1697           12 :             zsCalcFinalSizing.LatentHeatDDNum = zsCalcSizing.LatentHeatDDNum;
    1698           12 :             zsCalcFinalSizing.TimeStepNumAtLatentHeatMax = zsCalcSizing.TimeStepNumAtLatentHeatMax;
    1699           12 :             zsCalcFinalSizing.LatentHeatLoadSeq = zsCalcSizing.LatentHeatLoadSeq;
    1700           12 :             zsCalcFinalSizing.LatentHeatFlowSeq = zsCalcSizing.LatentHeatFlowSeq;
    1701              :         } else {
    1702              :             // save design latent heating load when the there is design load and the design volume flow rate is zero, i.e., when
    1703              :             // design latent heating volume flow rate is set to zero due to heating supply air humrat is less than zone humidistat humrat
    1704           40 :             if (zsCalcSizing.DesLatentHeatLoad > zsCalcFinalSizing.DesLatentHeatLoad) {
    1705            0 :                 zsCalcFinalSizing.DesLatentHeatLoad = zsCalcSizing.DesLatentHeatLoad;
    1706            0 :                 zsCalcFinalSizing.cLatentHeatDDDate = desDayWeath.DateString;
    1707            0 :                 zsCalcFinalSizing.LatentHeatDDNum = zsCalcSizing.LatentHeatDDNum;
    1708            0 :                 zsCalcFinalSizing.TimeStepNumAtLatentHeatMax = zsCalcSizing.TimeStepNumAtLatentHeatMax;
    1709            0 :                 zsCalcFinalSizing.LatentHeatLoadSeq = zsCalcSizing.LatentHeatLoadSeq;
    1710            0 :                 zsCalcFinalSizing.LatentHeatFlowSeq = zsCalcSizing.LatentHeatFlowSeq;
    1711              :             }
    1712              :         }
    1713              :     }
    1714              :     // select largest load from NoDOAS arrays
    1715        16691 :     if (zsCalcSizing.DesHeatLoadNoDOAS > zsCalcFinalSizing.DesHeatLoadNoDOAS) {
    1716           13 :         zsCalcFinalSizing.DesHeatLoadNoDOAS = zsCalcSizing.DesHeatLoadNoDOAS;
    1717           13 :         zsCalcFinalSizing.HeatLoadNoDOASSeq = zsCalcSizing.HeatLoadNoDOASSeq;
    1718           13 :         zsCalcFinalSizing.HeatNoDOASDDNum = zsCalcSizing.HeatNoDOASDDNum;
    1719           13 :         zsCalcFinalSizing.HeatNoDOASDesDay = zsCalcSizing.HeatNoDOASDesDay;
    1720           13 :         zsCalcFinalSizing.TimeStepNumAtHeatNoDOASMax = zsCalcSizing.TimeStepNumAtHeatNoDOASMax;
    1721              :     }
    1722        16691 :     if (zsCalcSizing.DesLatentHeatLoadNoDOAS > zsCalcFinalSizing.DesLatentHeatLoadNoDOAS) {
    1723           12 :         zsCalcFinalSizing.DesLatentHeatLoadNoDOAS = zsCalcSizing.DesLatentHeatLoadNoDOAS;
    1724           12 :         zsCalcFinalSizing.HeatLatentLoadNoDOASSeq = zsCalcSizing.HeatLatentLoadNoDOASSeq;
    1725           12 :         zsCalcFinalSizing.LatentHeatNoDOASDDNum = zsCalcSizing.LatentHeatNoDOASDDNum;
    1726           12 :         zsCalcFinalSizing.LatHeatNoDOASDesDay = zsCalcSizing.LatHeatNoDOASDesDay;
    1727           12 :         zsCalcFinalSizing.TimeStepNumAtLatentHeatNoDOASMax = zsCalcSizing.TimeStepNumAtLatentHeatNoDOASMax;
    1728              :     }
    1729              :     // from all the design periods, choose the one needing the most Cooling and save all its design variables in zsCalcFinalSizing
    1730        16691 :     if (zsCalcSizing.DesCoolVolFlow > zsCalcFinalSizing.DesCoolVolFlow) {
    1731         4031 :         zsCalcFinalSizing.DesCoolVolFlow = zsCalcSizing.DesCoolVolFlow;
    1732         4031 :         zsCalcFinalSizing.DesCoolLoad = zsCalcSizing.DesCoolLoad;
    1733         4031 :         zsCalcFinalSizing.DesCoolMassFlow = zsCalcSizing.DesCoolMassFlow;
    1734         4031 :         zsCalcFinalSizing.CoolDesDay = zsCalcSizing.CoolDesDay;
    1735         4031 :         zsCalcFinalSizing.DesCoolDens = zsCalcSizing.DesCoolDens;
    1736         4031 :         zsCalcFinalSizing.CoolFlowSeq = zsCalcSizing.CoolFlowSeq;
    1737         4031 :         zsCalcFinalSizing.CoolLoadSeq = zsCalcSizing.CoolLoadSeq;
    1738         4031 :         zsCalcFinalSizing.CoolZoneTempSeq = zsCalcSizing.CoolZoneTempSeq;
    1739         4031 :         zsCalcFinalSizing.CoolOutTempSeq = zsCalcSizing.CoolOutTempSeq;
    1740         4031 :         zsCalcFinalSizing.CoolZoneRetTempSeq = zsCalcSizing.CoolZoneRetTempSeq;
    1741         4031 :         zsCalcFinalSizing.CoolZoneHumRatSeq = zsCalcSizing.CoolZoneHumRatSeq;
    1742         4031 :         zsCalcFinalSizing.CoolOutHumRatSeq = zsCalcSizing.CoolOutHumRatSeq;
    1743         4031 :         zsCalcFinalSizing.ZoneTempAtCoolPeak = zsCalcSizing.ZoneTempAtCoolPeak;
    1744         4031 :         zsCalcFinalSizing.OutTempAtCoolPeak = zsCalcSizing.OutTempAtCoolPeak;
    1745         4031 :         zsCalcFinalSizing.ZoneRetTempAtCoolPeak = zsCalcSizing.ZoneRetTempAtCoolPeak;
    1746         4031 :         zsCalcFinalSizing.ZoneHumRatAtCoolPeak = zsCalcSizing.ZoneHumRatAtCoolPeak;
    1747         4031 :         zsCalcFinalSizing.OutHumRatAtCoolPeak = zsCalcSizing.OutHumRatAtCoolPeak;
    1748         4031 :         zsCalcFinalSizing.CoolDDNum = zsCalcSizing.CoolDDNum;
    1749         4031 :         zsCalcFinalSizing.cCoolDDDate = desDayWeath.DateString;
    1750         4031 :         zsCalcFinalSizing.TimeStepNumAtCoolMax = zsCalcSizing.TimeStepNumAtCoolMax;
    1751         4031 :         zsCalcFinalSizing.DesCoolCoilInTemp = zsCalcSizing.DesCoolCoilInTemp;
    1752         4031 :         zsCalcFinalSizing.DesCoolCoilInHumRat = zsCalcSizing.DesCoolCoilInHumRat;
    1753              :     } else {
    1754        12660 :         zsCalcFinalSizing.DesCoolDens = stdRhoAir;
    1755              :         // save design cooling load when the there is design cooling load and the design cooling volume flow rate is zero, i.e., when
    1756              :         // design cooling volume flow rate is set to zero due to cooling supply air temp greater than zone thermostat temperature
    1757        12660 :         if (zsCalcSizing.DesCoolLoad > zsCalcFinalSizing.DesCoolLoad) {
    1758            0 :             zsCalcFinalSizing.DesCoolLoad = zsCalcSizing.DesCoolLoad;
    1759            0 :             zsCalcFinalSizing.CoolDesDay = zsCalcSizing.CoolDesDay;
    1760            0 :             zsCalcFinalSizing.CoolLoadSeq = zsCalcSizing.CoolLoadSeq;
    1761            0 :             zsCalcFinalSizing.CoolZoneTempSeq = zsCalcSizing.CoolZoneTempSeq;
    1762            0 :             zsCalcFinalSizing.CoolOutTempSeq = zsCalcSizing.CoolOutTempSeq;
    1763            0 :             zsCalcFinalSizing.CoolZoneRetTempSeq = zsCalcSizing.CoolZoneRetTempSeq;
    1764            0 :             zsCalcFinalSizing.CoolZoneHumRatSeq = zsCalcSizing.CoolZoneHumRatSeq;
    1765            0 :             zsCalcFinalSizing.CoolOutHumRatSeq = zsCalcSizing.CoolOutHumRatSeq;
    1766            0 :             zsCalcFinalSizing.ZoneTempAtCoolPeak = zsCalcSizing.ZoneTempAtCoolPeak;
    1767            0 :             zsCalcFinalSizing.OutTempAtCoolPeak = zsCalcSizing.OutTempAtCoolPeak;
    1768            0 :             zsCalcFinalSizing.ZoneRetTempAtCoolPeak = zsCalcSizing.ZoneRetTempAtCoolPeak;
    1769            0 :             zsCalcFinalSizing.ZoneHumRatAtCoolPeak = zsCalcSizing.ZoneHumRatAtCoolPeak;
    1770            0 :             zsCalcFinalSizing.OutHumRatAtCoolPeak = zsCalcSizing.OutHumRatAtCoolPeak;
    1771            0 :             zsCalcFinalSizing.CoolDDNum = zsCalcSizing.CoolDDNum;
    1772            0 :             zsCalcFinalSizing.cCoolDDDate = desDayWeath.DateString;
    1773            0 :             zsCalcFinalSizing.TimeStepNumAtCoolMax = zsCalcSizing.TimeStepNumAtCoolMax;
    1774            0 :             zsCalcFinalSizing.DesCoolCoilInTemp = zsCalcSizing.DesCoolCoilInTemp;
    1775            0 :             zsCalcFinalSizing.DesCoolCoilInHumRat = zsCalcSizing.DesCoolCoilInHumRat;
    1776            0 :             zsCalcFinalSizing.CoolTstatTemp = zsCalcSizing.CoolTstatTemp;
    1777              :         }
    1778              :     }
    1779        16691 :     if (zsCalcSizing.zoneLatentSizing) {
    1780              :         // from all the design periods, choose the one needing the most Latent Cooling and save all its design variables in
    1781              :         // zsCalcFinalSizing
    1782           52 :         if (zsCalcSizing.DesLatentCoolVolFlow > zsCalcFinalSizing.DesLatentCoolVolFlow) {
    1783           19 :             zsCalcFinalSizing.DesLatentCoolVolFlow = zsCalcSizing.DesLatentCoolVolFlow;
    1784           19 :             zsCalcFinalSizing.DesLatentCoolMassFlow = zsCalcSizing.DesLatentCoolMassFlow;
    1785           19 :             zsCalcFinalSizing.DesLatentCoolLoad = zsCalcSizing.DesLatentCoolLoad;
    1786           19 :             zsCalcFinalSizing.ZoneTempAtLatentCoolPeak = zsCalcSizing.ZoneTempAtLatentCoolPeak;
    1787           19 :             zsCalcFinalSizing.ZoneHumRatAtLatentCoolPeak = zsCalcSizing.ZoneHumRatAtLatentCoolPeak;
    1788           19 :             zsCalcFinalSizing.ZoneRetTempAtLatentCoolPeak = zsCalcSizing.ZoneRetTempAtLatentCoolPeak;
    1789           19 :             zsCalcFinalSizing.DesLatentCoolCoilInTemp = zsCalcSizing.DesLatentCoolCoilInTemp;
    1790           19 :             zsCalcFinalSizing.DesLatentCoolCoilInHumRat = zsCalcSizing.DesLatentCoolCoilInHumRat;
    1791           19 :             zsCalcFinalSizing.LatCoolDesDay = zsCalcSizing.LatCoolDesDay;
    1792           19 :             zsCalcFinalSizing.cLatentCoolDDDate = desDayWeath.DateString;
    1793           19 :             zsCalcFinalSizing.LatentCoolDDNum = zsCalcSizing.LatentCoolDDNum;
    1794           19 :             zsCalcFinalSizing.TimeStepNumAtLatentCoolMax = zsCalcSizing.TimeStepNumAtLatentCoolMax;
    1795           19 :             zsCalcFinalSizing.LatentCoolLoadSeq = zsCalcSizing.LatentCoolLoadSeq;
    1796           19 :             zsCalcFinalSizing.LatentCoolFlowSeq = zsCalcSizing.LatentCoolFlowSeq;
    1797              :         } else {
    1798              :             // save design latent cooling load when the there is design load and the design volume flow rate is zero, i.e., when
    1799              :             // design latent cooling volume flow rate is set to zero due to cooling supply air humrat is greater than zone humidistat humrat
    1800           33 :             if (zsCalcSizing.DesLatentCoolLoad > zsCalcFinalSizing.DesLatentCoolLoad) {
    1801            0 :                 zsCalcFinalSizing.DesLatentCoolLoad = zsCalcSizing.DesLatentCoolLoad;
    1802            0 :                 zsCalcFinalSizing.cLatentCoolDDDate = desDayWeath.DateString;
    1803            0 :                 zsCalcFinalSizing.LatentCoolDDNum = zsCalcSizing.LatentCoolDDNum;
    1804            0 :                 zsCalcFinalSizing.LatCoolDesDay = zsCalcSizing.LatCoolDesDay;
    1805            0 :                 zsCalcFinalSizing.TimeStepNumAtLatentCoolMax = zsCalcSizing.TimeStepNumAtLatentCoolMax;
    1806            0 :                 zsCalcFinalSizing.LatentCoolLoadSeq = zsCalcSizing.LatentCoolLoadSeq;
    1807              :             }
    1808              :         }
    1809              :     }
    1810        16691 :     if (zsCalcSizing.DesCoolLoadNoDOAS > zsCalcFinalSizing.DesCoolLoadNoDOAS) {
    1811           13 :         zsCalcFinalSizing.DesCoolLoadNoDOAS = zsCalcSizing.DesCoolLoadNoDOAS;
    1812           13 :         zsCalcFinalSizing.CoolLoadNoDOASSeq = zsCalcSizing.CoolLoadNoDOASSeq;
    1813           13 :         zsCalcFinalSizing.CoolNoDOASDDNum = zsCalcSizing.CoolNoDOASDDNum;
    1814           13 :         zsCalcFinalSizing.CoolNoDOASDesDay = zsCalcSizing.CoolNoDOASDesDay;
    1815           13 :         zsCalcFinalSizing.TimeStepNumAtCoolNoDOASMax = zsCalcSizing.TimeStepNumAtCoolNoDOASMax;
    1816              :     }
    1817        16691 :     if (zsCalcSizing.DesLatentCoolLoadNoDOAS > zsCalcFinalSizing.DesLatentCoolLoadNoDOAS) {
    1818           19 :         zsCalcFinalSizing.DesLatentCoolLoadNoDOAS = zsCalcSizing.DesLatentCoolLoadNoDOAS;
    1819           19 :         zsCalcFinalSizing.CoolLatentLoadNoDOASSeq = zsCalcSizing.CoolLatentLoadNoDOASSeq;
    1820           19 :         zsCalcFinalSizing.LatentCoolNoDOASDDNum = zsCalcSizing.LatentCoolNoDOASDDNum;
    1821           19 :         zsCalcFinalSizing.LatCoolNoDOASDesDay = zsCalcSizing.LatCoolNoDOASDesDay;
    1822           19 :         zsCalcFinalSizing.TimeStepNumAtLatentCoolNoDOASMax = zsCalcSizing.TimeStepNumAtLatentCoolNoDOASMax;
    1823              :     }
    1824              :     // save heat peak conditions when there is no design heating load or design heating volume flow rate, i.e., when
    1825              :     // zone temperature is always greater than the zone heating thermostat temperature
    1826        16691 :     if (zsCalcFinalSizing.DesHeatLoad == 0) {
    1827         4795 :         bool FirstIteration = true; // declare as static to save for next iteration? but needs to be space/zone specific?
    1828       573211 :         for (int TimeStepIndex = 1; TimeStepIndex <= numTimeStepInDay; ++TimeStepIndex) {
    1829       568416 :             if ((zsCalcSizing.HeatZoneTempSeq(TimeStepIndex) < zsCalcSizing.ZoneTempAtHeatPeak) || FirstIteration) {
    1830        20841 :                 zsCalcSizing.ZoneTempAtHeatPeak = zsCalcSizing.HeatZoneTempSeq(TimeStepIndex);
    1831        20841 :                 zsCalcSizing.OutTempAtHeatPeak = zsCalcSizing.HeatOutTempSeq(TimeStepIndex);
    1832        20841 :                 zsCalcSizing.ZoneRetTempAtHeatPeak = zsCalcSizing.HeatZoneRetTempSeq(TimeStepIndex);
    1833        20841 :                 zsCalcSizing.ZoneHumRatAtHeatPeak = zsCalcSizing.HeatZoneHumRatSeq(TimeStepIndex);
    1834        20841 :                 zsCalcSizing.OutHumRatAtHeatPeak = zsCalcSizing.HeatOutHumRatSeq(TimeStepIndex);
    1835        20841 :                 zsCalcSizing.TimeStepNumAtHeatMax = TimeStepIndex;
    1836        20841 :                 FirstIteration = false;
    1837              :             }
    1838              :         }
    1839         4795 :         if (zsCalcSizing.OutTempAtHeatPeak <= zsCalcFinalSizing.OutTempAtHeatPeak) {
    1840         4196 :             zsCalcFinalSizing.HeatDesDay = zsCalcSizing.HeatDesDay;
    1841         4196 :             zsCalcFinalSizing.HeatZoneTempSeq = zsCalcSizing.HeatZoneTempSeq;
    1842         4196 :             zsCalcFinalSizing.HeatOutTempSeq = zsCalcSizing.HeatOutTempSeq;
    1843         4196 :             zsCalcFinalSizing.HeatZoneRetTempSeq = zsCalcSizing.HeatZoneRetTempSeq;
    1844         4196 :             zsCalcFinalSizing.HeatZoneHumRatSeq = zsCalcSizing.HeatZoneHumRatSeq;
    1845         4196 :             zsCalcFinalSizing.HeatOutHumRatSeq = zsCalcSizing.HeatOutHumRatSeq;
    1846         4196 :             zsCalcFinalSizing.ZoneTempAtHeatPeak = zsCalcSizing.ZoneTempAtHeatPeak;
    1847         4196 :             zsCalcFinalSizing.OutTempAtHeatPeak = zsCalcSizing.OutTempAtHeatPeak;
    1848         4196 :             zsCalcFinalSizing.ZoneRetTempAtHeatPeak = zsCalcSizing.ZoneRetTempAtHeatPeak;
    1849         4196 :             zsCalcFinalSizing.ZoneHumRatAtHeatPeak = zsCalcSizing.ZoneHumRatAtHeatPeak;
    1850         4196 :             zsCalcFinalSizing.OutHumRatAtHeatPeak = zsCalcSizing.OutHumRatAtHeatPeak;
    1851         4196 :             zsCalcFinalSizing.HeatDDNum = zsCalcSizing.HeatDDNum;
    1852         4196 :             zsCalcFinalSizing.cHeatDDDate = desDayWeath.DateString;
    1853         4196 :             zsCalcFinalSizing.TimeStepNumAtHeatMax = zsCalcSizing.TimeStepNumAtHeatMax;
    1854         4196 :             zsCalcFinalSizing.DesHeatCoilInTemp = zsCalcSizing.DesHeatCoilInTemp;
    1855         4196 :             zsCalcFinalSizing.DesHeatCoilInHumRat = zsCalcSizing.DesHeatCoilInHumRat;
    1856         4196 :             zsCalcFinalSizing.HeatTstatTemp = zsCalcSizing.HeatTstatTemp;
    1857         4196 :             FirstIteration = false;
    1858              :         }
    1859              :     }
    1860        16691 :     if (zsCalcFinalSizing.zoneLatentSizing && zsCalcFinalSizing.DesLatentHeatLoad == 0) {
    1861           32 :         bool FirstIteration = true;
    1862         3104 :         for (int TimeStepIndex = 1; TimeStepIndex <= numTimeStepInDay; ++TimeStepIndex) {
    1863         3072 :             if (zsCalcSizing.HeatZoneTempSeq(TimeStepIndex) < zsCalcSizing.ZoneTempAtLatentHeatPeak || FirstIteration) {
    1864          124 :                 zsCalcSizing.ZoneTempAtLatentHeatPeak = zsCalcSizing.HeatZoneTempSeq(TimeStepIndex);
    1865          124 :                 zsCalcSizing.OutTempAtLatentHeatPeak = zsCalcSizing.HeatOutTempSeq(TimeStepIndex);
    1866          124 :                 zsCalcSizing.OutHumRatAtLatentHeatPeak = zsCalcSizing.HeatOutHumRatSeq(TimeStepIndex);
    1867              :             }
    1868         3072 :             if (zsCalcSizing.HeatOutTempSeq(TimeStepIndex) <= zsCalcFinalSizing.OutTempAtLatentHeatPeak) {
    1869         1920 :                 zsCalcFinalSizing.OutTempAtLatentHeatPeak = zsCalcSizing.HeatOutTempSeq(TimeStepIndex);
    1870         1920 :                 zsCalcFinalSizing.OutHumRatAtLatentHeatPeak = zsCalcSizing.HeatOutHumRatSeq(TimeStepIndex);
    1871         1920 :                 zsCalcFinalSizing.LatHeatDesDay = zsCalcSizing.LatHeatDesDay;
    1872         1920 :                 zsCalcFinalSizing.LatentHeatDDNum = zsCalcSizing.LatentHeatDDNum;
    1873         1920 :                 zsCalcFinalSizing.cLatentHeatDDDate = desDayWeath.DateString;
    1874         1920 :                 zsCalcFinalSizing.TimeStepNumAtLatentHeatMax = zsCalcSizing.TimeStepNumAtLatentHeatMax;
    1875              :             }
    1876         3072 :             FirstIteration = false;
    1877              :         }
    1878              :     }
    1879              :     // save cool peak conditions when there is no design cooling load or design cooling volume flow rate, i.e., when
    1880              :     // zone temperature is always less than the zone cooling thermostat temperature
    1881        16691 :     if (zsCalcFinalSizing.DesCoolLoad == 0) {
    1882        11161 :         bool FirstIteration = true;
    1883      1353049 :         for (int TimeStepIndex = 1; TimeStepIndex <= numTimeStepInDay; ++TimeStepIndex) {
    1884      1341888 :             if ((zsCalcSizing.CoolZoneTempSeq(TimeStepIndex) > zsCalcSizing.ZoneTempAtCoolPeak) || FirstIteration) {
    1885       101948 :                 zsCalcSizing.ZoneTempAtCoolPeak = zsCalcSizing.CoolZoneTempSeq(TimeStepIndex);
    1886       101948 :                 zsCalcSizing.OutTempAtCoolPeak = zsCalcSizing.CoolOutTempSeq(TimeStepIndex);
    1887       101948 :                 zsCalcSizing.ZoneRetTempAtCoolPeak = zsCalcSizing.CoolZoneRetTempSeq(TimeStepIndex);
    1888       101948 :                 zsCalcSizing.ZoneHumRatAtCoolPeak = zsCalcSizing.CoolZoneHumRatSeq(TimeStepIndex);
    1889       101948 :                 zsCalcSizing.OutHumRatAtCoolPeak = zsCalcSizing.CoolOutHumRatSeq(TimeStepIndex);
    1890       101948 :                 zsCalcSizing.TimeStepNumAtCoolMax = TimeStepIndex;
    1891       101948 :                 FirstIteration = false;
    1892              :             }
    1893              :         }
    1894        11161 :         if (zsCalcSizing.OutTempAtCoolPeak > zsCalcFinalSizing.OutTempAtCoolPeak) {
    1895          292 :             zsCalcFinalSizing.CoolDesDay = zsCalcSizing.CoolDesDay;
    1896          292 :             zsCalcFinalSizing.CoolZoneTempSeq = zsCalcSizing.CoolZoneTempSeq;
    1897          292 :             zsCalcFinalSizing.CoolOutTempSeq = zsCalcSizing.CoolOutTempSeq;
    1898          292 :             zsCalcFinalSizing.CoolZoneRetTempSeq = zsCalcSizing.CoolZoneRetTempSeq;
    1899          292 :             zsCalcFinalSizing.CoolZoneHumRatSeq = zsCalcSizing.CoolZoneHumRatSeq;
    1900          292 :             zsCalcFinalSizing.CoolOutHumRatSeq = zsCalcSizing.CoolOutHumRatSeq;
    1901          292 :             zsCalcFinalSizing.ZoneTempAtCoolPeak = zsCalcSizing.ZoneTempAtCoolPeak;
    1902          292 :             zsCalcFinalSizing.OutTempAtCoolPeak = zsCalcSizing.OutTempAtCoolPeak;
    1903          292 :             zsCalcFinalSizing.ZoneRetTempAtCoolPeak = zsCalcSizing.ZoneRetTempAtCoolPeak;
    1904          292 :             zsCalcFinalSizing.ZoneHumRatAtCoolPeak = zsCalcSizing.ZoneHumRatAtCoolPeak;
    1905          292 :             zsCalcFinalSizing.OutHumRatAtCoolPeak = zsCalcSizing.OutHumRatAtCoolPeak;
    1906          292 :             zsCalcFinalSizing.CoolDDNum = zsCalcSizing.CoolDDNum;
    1907          292 :             zsCalcFinalSizing.cCoolDDDate = desDayWeath.DateString;
    1908          292 :             zsCalcFinalSizing.TimeStepNumAtCoolMax = zsCalcSizing.TimeStepNumAtCoolMax;
    1909          292 :             zsCalcFinalSizing.DesCoolCoilInTemp = zsCalcSizing.DesCoolCoilInTemp;
    1910          292 :             zsCalcFinalSizing.DesCoolCoilInHumRat = zsCalcSizing.DesCoolCoilInHumRat;
    1911          292 :             zsCalcFinalSizing.CoolTstatTemp = zsCalcSizing.CoolTstatTemp;
    1912              :         }
    1913              :     }
    1914        16691 :     if (zsCalcFinalSizing.zoneLatentSizing && zsCalcFinalSizing.DesLatentCoolLoad == 0) {
    1915           27 :         bool FirstIteration = true;
    1916         2619 :         for (int TimeStepIndex = 1; TimeStepIndex <= numTimeStepInDay; ++TimeStepIndex) {
    1917         2592 :             if (zsCalcSizing.CoolZoneTempSeq(TimeStepIndex) > zsCalcSizing.ZoneTempAtLatentCoolPeak || FirstIteration) {
    1918           38 :                 zsCalcSizing.ZoneTempAtLatentCoolPeak = zsCalcSizing.CoolZoneTempSeq(TimeStepIndex);
    1919           38 :                 zsCalcSizing.OutTempAtLatentCoolPeak = zsCalcSizing.CoolOutTempSeq(TimeStepIndex);
    1920           38 :                 zsCalcSizing.OutHumRatAtLatentCoolPeak = zsCalcSizing.CoolOutHumRatSeq(TimeStepIndex);
    1921           38 :                 FirstIteration = false;
    1922              :             }
    1923         2592 :             if (zsCalcSizing.OutTempAtLatentCoolPeak >= zsCalcFinalSizing.OutTempAtLatentCoolPeak) {
    1924         2016 :                 zsCalcFinalSizing.LatCoolDesDay = zsCalcSizing.LatCoolDesDay;
    1925         2016 :                 zsCalcFinalSizing.LatentCoolDDNum = zsCalcSizing.LatentCoolDDNum;
    1926         2016 :                 zsCalcFinalSizing.cLatentCoolDDDate = desDayWeath.DateString;
    1927         2016 :                 zsCalcFinalSizing.TimeStepNumAtLatentCoolMax = zsCalcSizing.TimeStepNumAtLatentCoolMax;
    1928              :             }
    1929              :         }
    1930              :     }
    1931        16691 : }
    1932              : 
    1933            2 : void updateZoneSizingEndZoneSizingCalc1(EnergyPlusData &state, int const zoneNum)
    1934              : {
    1935              :     // Set or override finalzonesizing data for non-coincident sizing
    1936            2 :     auto &zoneCFS = state.dataSize->CalcFinalZoneSizing(zoneNum);
    1937            2 :     if (zoneCFS.spaceConcurrence == DataSizing::SizingConcurrence::Coincident) {
    1938            2 :         return;
    1939              :     }
    1940              :     // Zero out simple sums
    1941            0 :     zoneCFS.DesHeatVolFlow = 0.0;
    1942            0 :     zoneCFS.DesHeatLoad = 0.0;
    1943            0 :     zoneCFS.DesHeatMassFlow = 0.0;
    1944            0 :     zoneCFS.DesHeatLoadNoDOAS = 0.0;
    1945            0 :     zoneCFS.DesCoolVolFlow = 0.0;
    1946            0 :     zoneCFS.DesCoolLoad = 0.0;
    1947            0 :     zoneCFS.DesCoolMassFlow = 0.0;
    1948            0 :     zoneCFS.DesCoolLoadNoDOAS = 0.0;
    1949              : 
    1950              :     // Zero out weighted averages
    1951            0 :     zoneCFS.DesHeatDens = 0.0;
    1952            0 :     zoneCFS.ZoneTempAtHeatPeak = 0.0;
    1953            0 :     zoneCFS.OutTempAtHeatPeak = 0.0;
    1954            0 :     zoneCFS.ZoneRetTempAtHeatPeak = 0.0;
    1955            0 :     zoneCFS.ZoneHumRatAtHeatPeak = 0.0;
    1956            0 :     zoneCFS.OutHumRatAtHeatPeak = 0.0;
    1957            0 :     zoneCFS.DesHeatCoilInTemp = 0.0;
    1958            0 :     zoneCFS.DesHeatCoilInHumRat = 0.0;
    1959            0 :     zoneCFS.DesCoolDens = 0.0;
    1960            0 :     zoneCFS.ZoneTempAtCoolPeak = 0.0;
    1961            0 :     zoneCFS.OutTempAtCoolPeak = 0.0;
    1962            0 :     zoneCFS.ZoneRetTempAtCoolPeak = 0.0;
    1963            0 :     zoneCFS.ZoneHumRatAtCoolPeak = 0.0;
    1964            0 :     zoneCFS.OutHumRatAtCoolPeak = 0.0;
    1965            0 :     zoneCFS.DesCoolCoilInTemp = 0.0;
    1966            0 :     zoneCFS.DesCoolCoilInHumRat = 0.0;
    1967              : 
    1968              :     // Zero out time-series sums and averages
    1969            0 :     for (int ts = 1; ts <= state.dataZoneEquipmentManager->NumOfTimeStepInDay; ++ts) {
    1970            0 :         zoneCFS.HeatFlowSeq(ts) = 0.0;
    1971            0 :         zoneCFS.HeatLoadSeq(ts) = 0.0;
    1972            0 :         zoneCFS.HeatZoneTempSeq(ts) = 0.0;
    1973            0 :         zoneCFS.HeatOutTempSeq(ts) = 0.0;
    1974            0 :         zoneCFS.HeatZoneRetTempSeq(ts) = 0.0;
    1975            0 :         zoneCFS.HeatZoneHumRatSeq(ts) = 0.0;
    1976            0 :         zoneCFS.HeatOutHumRatSeq(ts) = 0.0;
    1977            0 :         zoneCFS.HeatLoadNoDOASSeq(ts) = 0.0;
    1978            0 :         zoneCFS.CoolFlowSeq(ts) = 0.0;
    1979            0 :         zoneCFS.CoolLoadSeq(ts) = 0.0;
    1980            0 :         zoneCFS.CoolZoneTempSeq(ts) = 0.0;
    1981            0 :         zoneCFS.CoolOutTempSeq(ts) = 0.0;
    1982            0 :         zoneCFS.CoolZoneRetTempSeq(ts) = 0.0;
    1983            0 :         zoneCFS.CoolZoneHumRatSeq(ts) = 0.0;
    1984            0 :         zoneCFS.CoolOutHumRatSeq(ts) = 0.0;
    1985            0 :         zoneCFS.CoolLoadNoDOASSeq(ts) = 0.0;
    1986              :     }
    1987              : 
    1988            0 :     if (zoneCFS.zoneLatentSizing) {
    1989              :         // Zero out latent simple sums
    1990            0 :         zoneCFS.DesLatentHeatVolFlow = 0.0;
    1991            0 :         zoneCFS.DesLatentHeatMassFlow = 0.0;
    1992            0 :         zoneCFS.DesLatentHeatLoad = 0.0;
    1993            0 :         zoneCFS.DesLatentHeatLoadNoDOAS = 0.0;
    1994            0 :         zoneCFS.DesLatentCoolVolFlow = 0.0;
    1995            0 :         zoneCFS.DesLatentCoolMassFlow = 0.0;
    1996            0 :         zoneCFS.DesLatentCoolLoad = 0.0;
    1997            0 :         zoneCFS.DesLatentCoolLoadNoDOAS = 0.0;
    1998              : 
    1999              :         // Zero out latent weighted averages
    2000            0 :         zoneCFS.ZoneTempAtLatentHeatPeak = 0.0;
    2001            0 :         zoneCFS.ZoneHumRatAtLatentHeatPeak = 0.0;
    2002            0 :         zoneCFS.ZoneRetTempAtLatentHeatPeak = 0.0;
    2003            0 :         zoneCFS.DesLatentHeatCoilInTemp = 0.0;
    2004            0 :         zoneCFS.DesLatentHeatCoilInHumRat = 0.0;
    2005            0 :         zoneCFS.ZoneTempAtLatentCoolPeak = 0.0;
    2006            0 :         zoneCFS.ZoneHumRatAtLatentCoolPeak = 0.0;
    2007            0 :         zoneCFS.ZoneRetTempAtLatentCoolPeak = 0.0;
    2008            0 :         zoneCFS.DesLatentCoolCoilInTemp = 0.0;
    2009            0 :         zoneCFS.DesLatentCoolCoilInHumRat = 0.0;
    2010              : 
    2011              :         // Zero out latent time-series sums
    2012            0 :         for (int ts = 1; ts <= state.dataZoneEquipmentManager->NumOfTimeStepInDay; ++ts) {
    2013            0 :             zoneCFS.LatentHeatLoadSeq(ts) = 0.0;
    2014            0 :             zoneCFS.LatentHeatFlowSeq(ts) = 0.0;
    2015            0 :             zoneCFS.HeatLatentLoadNoDOASSeq(ts) = 0.0;
    2016            0 :             zoneCFS.LatentCoolLoadSeq(ts) = 0.0;
    2017            0 :             zoneCFS.LatentCoolFlowSeq(ts) = 0.0;
    2018            0 :             zoneCFS.CoolLatentLoadNoDOASSeq(ts) = 0.0;
    2019              :         }
    2020              :     }
    2021              : 
    2022              :     // Other - Initialize to first space values (clear later if not all the same)
    2023            0 :     int firstSpace = state.dataHeatBal->Zone(zoneNum).spaceIndexes[0];
    2024            0 :     auto const &firstSpaceCFS = state.dataSize->CalcFinalSpaceSizing(firstSpace);
    2025            0 :     zoneCFS.HeatDesDay = firstSpaceCFS.HeatDesDay;
    2026            0 :     zoneCFS.HeatDDNum = firstSpaceCFS.HeatDDNum;
    2027            0 :     zoneCFS.cHeatDDDate = firstSpaceCFS.cHeatDDDate;
    2028            0 :     zoneCFS.TimeStepNumAtHeatMax = firstSpaceCFS.TimeStepNumAtHeatMax;
    2029            0 :     zoneCFS.HeatNoDOASDDNum = firstSpaceCFS.HeatNoDOASDDNum;
    2030            0 :     zoneCFS.HeatNoDOASDesDay = firstSpaceCFS.HeatNoDOASDesDay;
    2031            0 :     zoneCFS.TimeStepNumAtHeatNoDOASMax = firstSpaceCFS.TimeStepNumAtHeatNoDOASMax;
    2032            0 :     zoneCFS.CoolDesDay = firstSpaceCFS.CoolDesDay;
    2033            0 :     zoneCFS.CoolDDNum = firstSpaceCFS.CoolDDNum;
    2034            0 :     zoneCFS.cCoolDDDate = firstSpaceCFS.cCoolDDDate;
    2035            0 :     zoneCFS.TimeStepNumAtCoolMax = firstSpaceCFS.TimeStepNumAtCoolMax;
    2036            0 :     if (zoneCFS.zoneLatentSizing) {
    2037            0 :         zoneCFS.LatHeatDesDay = firstSpaceCFS.LatHeatDesDay;
    2038            0 :         zoneCFS.cLatentHeatDDDate = firstSpaceCFS.cLatentHeatDDDate;
    2039            0 :         zoneCFS.LatentHeatDDNum = firstSpaceCFS.LatentHeatDDNum;
    2040            0 :         zoneCFS.TimeStepNumAtLatentHeatMax = firstSpaceCFS.TimeStepNumAtLatentHeatMax;
    2041            0 :         zoneCFS.LatentHeatNoDOASDDNum = firstSpaceCFS.LatentHeatNoDOASDDNum;
    2042            0 :         zoneCFS.LatHeatNoDOASDesDay = firstSpaceCFS.LatHeatNoDOASDesDay;
    2043            0 :         zoneCFS.TimeStepNumAtLatentHeatNoDOASMax = firstSpaceCFS.TimeStepNumAtLatentHeatNoDOASMax;
    2044            0 :         zoneCFS.LatCoolDesDay = firstSpaceCFS.LatCoolDesDay;
    2045            0 :         zoneCFS.cLatentCoolDDDate = firstSpaceCFS.cLatentCoolDDDate;
    2046            0 :         zoneCFS.LatentCoolDDNum = firstSpaceCFS.LatentCoolDDNum;
    2047            0 :         zoneCFS.TimeStepNumAtLatentCoolMax = firstSpaceCFS.TimeStepNumAtLatentCoolMax;
    2048            0 :         zoneCFS.CoolNoDOASDDNum = firstSpaceCFS.CoolNoDOASDDNum;
    2049            0 :         zoneCFS.CoolNoDOASDesDay = firstSpaceCFS.CoolNoDOASDesDay;
    2050            0 :         zoneCFS.TimeStepNumAtCoolNoDOASMax = firstSpaceCFS.TimeStepNumAtCoolNoDOASMax;
    2051            0 :         zoneCFS.LatentCoolNoDOASDDNum = firstSpaceCFS.LatentCoolNoDOASDDNum;
    2052            0 :         zoneCFS.LatCoolNoDOASDesDay = firstSpaceCFS.LatCoolNoDOASDesDay;
    2053            0 :         zoneCFS.TimeStepNumAtLatentCoolNoDOASMax = firstSpaceCFS.TimeStepNumAtLatentCoolNoDOASMax;
    2054              :     }
    2055              : 
    2056            0 :     int numSpaces = 0; // Track this for averages later
    2057            0 :     for (int spaceNum : state.dataHeatBal->Zone(zoneNum).spaceIndexes) {
    2058            0 :         auto &spaceCFS = state.dataSize->CalcFinalSpaceSizing(spaceNum);
    2059            0 :         ++numSpaces;
    2060              : 
    2061              :         // Simple sums
    2062            0 :         zoneCFS.DesHeatVolFlow += spaceCFS.DesHeatVolFlow;
    2063            0 :         zoneCFS.DesHeatLoad += spaceCFS.DesHeatLoad;
    2064            0 :         zoneCFS.DesHeatMassFlow += spaceCFS.DesHeatMassFlow;
    2065            0 :         zoneCFS.DesHeatLoadNoDOAS += spaceCFS.DesHeatLoadNoDOAS;
    2066            0 :         zoneCFS.DesCoolVolFlow += spaceCFS.DesCoolVolFlow;
    2067            0 :         zoneCFS.DesCoolLoad += spaceCFS.DesCoolLoad;
    2068            0 :         zoneCFS.DesCoolMassFlow += spaceCFS.DesCoolMassFlow;
    2069            0 :         zoneCFS.DesCoolLoadNoDOAS += spaceCFS.DesCoolLoadNoDOAS;
    2070              : 
    2071              :         // Weighted averages
    2072            0 :         zoneCFS.DesHeatDens += spaceCFS.DesHeatDens * spaceCFS.DesHeatMassFlow;
    2073            0 :         zoneCFS.ZoneTempAtHeatPeak += spaceCFS.ZoneTempAtHeatPeak * spaceCFS.DesHeatMassFlow;
    2074            0 :         zoneCFS.OutTempAtHeatPeak += spaceCFS.OutTempAtHeatPeak * spaceCFS.DesHeatMassFlow;
    2075            0 :         zoneCFS.ZoneRetTempAtHeatPeak += spaceCFS.ZoneRetTempAtHeatPeak * spaceCFS.DesHeatMassFlow;
    2076            0 :         zoneCFS.ZoneHumRatAtHeatPeak += spaceCFS.ZoneHumRatAtHeatPeak * spaceCFS.DesHeatMassFlow;
    2077            0 :         zoneCFS.OutHumRatAtHeatPeak += spaceCFS.OutHumRatAtHeatPeak * spaceCFS.DesHeatMassFlow;
    2078            0 :         zoneCFS.DesHeatCoilInTemp += spaceCFS.DesHeatCoilInTemp * spaceCFS.DesHeatMassFlow;
    2079            0 :         zoneCFS.DesHeatCoilInHumRat += spaceCFS.DesHeatCoilInHumRat * spaceCFS.DesHeatMassFlow;
    2080            0 :         zoneCFS.DesCoolDens += spaceCFS.DesCoolDens * spaceCFS.DesCoolMassFlow;
    2081            0 :         zoneCFS.ZoneTempAtCoolPeak += spaceCFS.ZoneTempAtCoolPeak * spaceCFS.DesCoolMassFlow;
    2082            0 :         zoneCFS.OutTempAtCoolPeak += spaceCFS.OutTempAtCoolPeak * spaceCFS.DesCoolMassFlow;
    2083            0 :         zoneCFS.ZoneRetTempAtCoolPeak += spaceCFS.ZoneRetTempAtCoolPeak * spaceCFS.DesCoolMassFlow;
    2084            0 :         zoneCFS.ZoneHumRatAtCoolPeak += spaceCFS.ZoneHumRatAtCoolPeak * spaceCFS.DesCoolMassFlow;
    2085            0 :         zoneCFS.OutHumRatAtCoolPeak += spaceCFS.OutHumRatAtCoolPeak * spaceCFS.DesCoolMassFlow;
    2086            0 :         zoneCFS.DesCoolCoilInTemp += spaceCFS.DesCoolCoilInTemp * spaceCFS.DesCoolMassFlow;
    2087            0 :         zoneCFS.DesCoolCoilInHumRat += spaceCFS.DesCoolCoilInHumRat * spaceCFS.DesCoolMassFlow;
    2088              : 
    2089            0 :         for (int ts = 1; ts <= state.dataZoneEquipmentManager->NumOfTimeStepInDay; ++ts) {
    2090              :             // Time-series sums
    2091            0 :             zoneCFS.HeatFlowSeq(ts) += spaceCFS.HeatFlowSeq(ts);
    2092            0 :             zoneCFS.HeatLoadSeq(ts) += spaceCFS.HeatLoadSeq(ts);
    2093            0 :             zoneCFS.HeatLoadNoDOASSeq(ts) += spaceCFS.HeatLoadNoDOASSeq(ts);
    2094            0 :             zoneCFS.CoolFlowSeq(ts) += spaceCFS.CoolFlowSeq(ts);
    2095            0 :             zoneCFS.CoolLoadSeq(ts) += spaceCFS.CoolLoadSeq(ts);
    2096            0 :             zoneCFS.CoolLoadNoDOASSeq(ts) += spaceCFS.CoolLoadNoDOASSeq(ts);
    2097              : 
    2098              :             // Time-series weighted averages
    2099            0 :             zoneCFS.HeatZoneTempSeq(ts) += spaceCFS.HeatZoneTempSeq(ts) * spaceCFS.HeatFlowSeq(ts);
    2100            0 :             zoneCFS.HeatOutTempSeq(ts) += spaceCFS.HeatOutTempSeq(ts) * spaceCFS.HeatFlowSeq(ts);
    2101            0 :             zoneCFS.HeatZoneRetTempSeq(ts) += spaceCFS.HeatZoneRetTempSeq(ts) * spaceCFS.HeatFlowSeq(ts);
    2102            0 :             zoneCFS.HeatZoneHumRatSeq(ts) += spaceCFS.HeatZoneHumRatSeq(ts) * spaceCFS.HeatFlowSeq(ts);
    2103            0 :             zoneCFS.HeatOutHumRatSeq(ts) += spaceCFS.HeatOutHumRatSeq(ts) * spaceCFS.HeatFlowSeq(ts);
    2104            0 :             zoneCFS.CoolZoneTempSeq(ts) += spaceCFS.CoolZoneTempSeq(ts) * spaceCFS.CoolFlowSeq(ts);
    2105            0 :             zoneCFS.CoolOutTempSeq(ts) += spaceCFS.CoolOutTempSeq(ts) * spaceCFS.CoolFlowSeq(ts);
    2106            0 :             zoneCFS.CoolZoneRetTempSeq(ts) += spaceCFS.CoolZoneRetTempSeq(ts) * spaceCFS.CoolFlowSeq(ts);
    2107            0 :             zoneCFS.CoolZoneHumRatSeq(ts) += spaceCFS.CoolZoneHumRatSeq(ts) * spaceCFS.CoolFlowSeq(ts);
    2108            0 :             zoneCFS.CoolOutHumRatSeq(ts) += spaceCFS.CoolOutHumRatSeq(ts) * spaceCFS.CoolFlowSeq(ts);
    2109              :         }
    2110              : 
    2111              :         // Other
    2112            0 :         if ((zoneCFS.HeatDDNum != 0) && (zoneCFS.HeatDDNum != spaceCFS.HeatDDNum)) {
    2113            0 :             zoneCFS.HeatDesDay = "N/A";
    2114            0 :             zoneCFS.HeatDDNum = 0;
    2115            0 :             zoneCFS.cHeatDDDate = "";
    2116              :         }
    2117            0 :         if ((zoneCFS.HeatNoDOASDDNum != 0) && (zoneCFS.HeatNoDOASDDNum != spaceCFS.HeatNoDOASDDNum)) {
    2118            0 :             zoneCFS.HeatNoDOASDDNum = 0;
    2119            0 :             zoneCFS.HeatNoDOASDesDay = "N/A";
    2120              :         }
    2121            0 :         if ((zoneCFS.CoolDDNum != 0) && (zoneCFS.CoolDDNum != spaceCFS.CoolDDNum)) {
    2122            0 :             zoneCFS.CoolDesDay = "N/A";
    2123            0 :             zoneCFS.CoolDDNum = 0;
    2124            0 :             zoneCFS.cCoolDDDate = "";
    2125              :         }
    2126            0 :         if ((zoneCFS.CoolNoDOASDDNum != 0) && (zoneCFS.CoolNoDOASDDNum != spaceCFS.CoolNoDOASDDNum)) {
    2127            0 :             zoneCFS.CoolNoDOASDDNum = 0;
    2128            0 :             zoneCFS.CoolNoDOASDesDay = "N/A";
    2129              :         }
    2130              : 
    2131            0 :         if (zoneCFS.zoneLatentSizing) {
    2132              :             // Simple sums
    2133            0 :             zoneCFS.DesLatentHeatVolFlow += spaceCFS.DesLatentHeatVolFlow;
    2134            0 :             zoneCFS.DesLatentHeatMassFlow += spaceCFS.ZoneHeatLatentMassFlow;
    2135            0 :             zoneCFS.DesLatentHeatLoad += spaceCFS.DesLatentHeatLoad;
    2136            0 :             zoneCFS.DesLatentHeatLoadNoDOAS += spaceCFS.DesLatentHeatLoadNoDOAS;
    2137            0 :             zoneCFS.DesLatentCoolVolFlow += spaceCFS.DesLatentCoolVolFlow;
    2138            0 :             zoneCFS.DesLatentCoolMassFlow += spaceCFS.DesLatentCoolMassFlow;
    2139            0 :             zoneCFS.DesLatentCoolLoad += spaceCFS.DesLatentCoolLoad;
    2140            0 :             zoneCFS.DesLatentCoolLoadNoDOAS += spaceCFS.DesLatentCoolLoadNoDOAS;
    2141              : 
    2142              :             // Weighted averages
    2143            0 :             zoneCFS.ZoneTempAtLatentHeatPeak += spaceCFS.ZoneTempAtLatentHeatPeak * spaceCFS.ZoneHeatLatentMassFlow;
    2144            0 :             zoneCFS.ZoneHumRatAtLatentHeatPeak += spaceCFS.ZoneHumRatAtLatentHeatPeak * spaceCFS.ZoneHeatLatentMassFlow;
    2145            0 :             zoneCFS.ZoneRetTempAtLatentHeatPeak += spaceCFS.ZoneRetTempAtLatentHeatPeak * spaceCFS.ZoneHeatLatentMassFlow;
    2146            0 :             zoneCFS.DesLatentHeatCoilInTemp += spaceCFS.DesLatentHeatCoilInTemp * spaceCFS.ZoneHeatLatentMassFlow;
    2147            0 :             zoneCFS.DesLatentHeatCoilInHumRat += spaceCFS.DesLatentHeatCoilInHumRat * spaceCFS.ZoneHeatLatentMassFlow;
    2148            0 :             zoneCFS.ZoneTempAtLatentCoolPeak += spaceCFS.ZoneTempAtLatentCoolPeak * spaceCFS.DesLatentCoolVolFlow;
    2149            0 :             zoneCFS.ZoneHumRatAtLatentCoolPeak += spaceCFS.ZoneHumRatAtLatentCoolPeak * spaceCFS.DesLatentCoolVolFlow;
    2150            0 :             zoneCFS.ZoneRetTempAtLatentCoolPeak += spaceCFS.ZoneRetTempAtLatentCoolPeak * spaceCFS.DesLatentCoolVolFlow;
    2151            0 :             zoneCFS.DesLatentCoolCoilInTemp += spaceCFS.DesLatentCoolCoilInTemp * spaceCFS.DesLatentCoolVolFlow;
    2152            0 :             zoneCFS.DesLatentCoolCoilInHumRat += spaceCFS.DesLatentCoolCoilInHumRat * spaceCFS.DesLatentCoolVolFlow;
    2153              : 
    2154              :             // Other
    2155            0 :             if ((zoneCFS.LatentHeatDDNum != 0) && (zoneCFS.LatentHeatDDNum != spaceCFS.LatentHeatDDNum)) {
    2156            0 :                 zoneCFS.LatHeatDesDay = "N/A";
    2157            0 :                 zoneCFS.cLatentHeatDDDate = "";
    2158            0 :                 zoneCFS.LatentHeatDDNum = 0;
    2159              :             }
    2160            0 :             if ((zoneCFS.LatentHeatNoDOASDDNum != 0) && (zoneCFS.LatentHeatNoDOASDDNum != spaceCFS.LatentHeatNoDOASDDNum)) {
    2161            0 :                 zoneCFS.LatentHeatNoDOASDDNum = 0;
    2162            0 :                 zoneCFS.LatHeatNoDOASDesDay = "N/A";
    2163              :             }
    2164            0 :             if ((zoneCFS.LatentCoolDDNum != 0) && (zoneCFS.LatentCoolDDNum != spaceCFS.LatentCoolDDNum)) {
    2165            0 :                 zoneCFS.LatCoolDesDay = "N/A";
    2166            0 :                 zoneCFS.cLatentCoolDDDate = "";
    2167            0 :                 zoneCFS.LatentCoolDDNum = 0;
    2168              :             }
    2169            0 :             if ((zoneCFS.LatentCoolNoDOASDDNum != 0) && (zoneCFS.LatentCoolNoDOASDDNum != spaceCFS.LatentCoolNoDOASDDNum)) {
    2170            0 :                 zoneCFS.LatentCoolNoDOASDDNum = 0;
    2171            0 :                 zoneCFS.LatCoolNoDOASDesDay = "N/A";
    2172              :             }
    2173              : 
    2174              :             // Time-series sums
    2175            0 :             for (int ts = 1; ts <= state.dataZoneEquipmentManager->NumOfTimeStepInDay; ++ts) {
    2176            0 :                 zoneCFS.LatentHeatLoadSeq(ts) += spaceCFS.LatentHeatLoadSeq(ts);
    2177            0 :                 zoneCFS.LatentHeatFlowSeq(ts) += spaceCFS.LatentHeatFlowSeq(ts);
    2178            0 :                 zoneCFS.HeatLatentLoadNoDOASSeq(ts) += spaceCFS.HeatLatentLoadNoDOASSeq(ts);
    2179            0 :                 zoneCFS.LatentCoolLoadSeq(ts) += spaceCFS.LatentCoolLoadSeq(ts);
    2180            0 :                 zoneCFS.LatentCoolFlowSeq(ts) += spaceCFS.LatentCoolFlowSeq(ts);
    2181            0 :                 zoneCFS.CoolLatentLoadNoDOASSeq(ts) += spaceCFS.CoolLatentLoadNoDOASSeq(ts);
    2182              :             }
    2183              :         }
    2184            0 :     }
    2185              : 
    2186              :     // Compute weighted averages
    2187            0 :     if (zoneCFS.DesHeatMassFlow > 0) {
    2188            0 :         zoneCFS.DesHeatDens /= zoneCFS.DesHeatMassFlow;
    2189            0 :         zoneCFS.ZoneTempAtHeatPeak /= zoneCFS.DesHeatMassFlow;
    2190            0 :         zoneCFS.OutTempAtHeatPeak /= zoneCFS.DesHeatMassFlow;
    2191            0 :         zoneCFS.ZoneRetTempAtHeatPeak /= zoneCFS.DesHeatMassFlow;
    2192            0 :         zoneCFS.ZoneHumRatAtHeatPeak /= zoneCFS.DesHeatMassFlow;
    2193            0 :         zoneCFS.OutHumRatAtHeatPeak /= zoneCFS.DesHeatMassFlow;
    2194            0 :         zoneCFS.DesHeatCoilInTemp /= zoneCFS.DesHeatMassFlow;
    2195            0 :         zoneCFS.DesHeatCoilInHumRat /= zoneCFS.DesHeatMassFlow;
    2196              :     }
    2197            0 :     if (zoneCFS.DesCoolMassFlow > 0) {
    2198            0 :         zoneCFS.DesCoolDens /= zoneCFS.DesCoolMassFlow;
    2199            0 :         zoneCFS.ZoneTempAtCoolPeak /= zoneCFS.DesCoolMassFlow;
    2200            0 :         zoneCFS.OutTempAtCoolPeak /= zoneCFS.DesCoolMassFlow;
    2201            0 :         zoneCFS.ZoneRetTempAtCoolPeak /= zoneCFS.DesCoolMassFlow;
    2202            0 :         zoneCFS.ZoneHumRatAtCoolPeak /= zoneCFS.DesCoolMassFlow;
    2203            0 :         zoneCFS.OutHumRatAtCoolPeak /= zoneCFS.DesCoolMassFlow;
    2204            0 :         zoneCFS.DesCoolCoilInTemp /= zoneCFS.DesCoolMassFlow;
    2205            0 :         zoneCFS.DesCoolCoilInHumRat /= zoneCFS.DesCoolMassFlow;
    2206              :     }
    2207            0 :     for (int ts = 1; ts <= state.dataZoneEquipmentManager->NumOfTimeStepInDay; ++ts) {
    2208            0 :         Real64 tsHeatFlow = zoneCFS.HeatFlowSeq(ts);
    2209            0 :         if (tsHeatFlow > 0) {
    2210            0 :             zoneCFS.HeatZoneTempSeq(ts) /= tsHeatFlow;
    2211            0 :             zoneCFS.HeatOutTempSeq(ts) /= tsHeatFlow;
    2212            0 :             zoneCFS.HeatZoneRetTempSeq(ts) /= tsHeatFlow;
    2213            0 :             zoneCFS.HeatZoneHumRatSeq(ts) /= tsHeatFlow;
    2214            0 :             zoneCFS.HeatOutHumRatSeq(ts) /= tsHeatFlow;
    2215              :         }
    2216              : 
    2217            0 :         Real64 tsCoolFlow = zoneCFS.CoolFlowSeq(ts);
    2218            0 :         if (tsCoolFlow > 0) {
    2219            0 :             zoneCFS.CoolZoneTempSeq(ts) /= tsCoolFlow;
    2220            0 :             zoneCFS.CoolOutTempSeq(ts) /= tsCoolFlow;
    2221            0 :             zoneCFS.CoolZoneRetTempSeq(ts) /= tsCoolFlow;
    2222            0 :             zoneCFS.CoolZoneHumRatSeq(ts) /= tsCoolFlow;
    2223            0 :             zoneCFS.CoolOutHumRatSeq(ts) /= tsCoolFlow;
    2224              :         }
    2225              :     }
    2226              :     // Timestep at max
    2227            0 :     zoneCFS.TimeStepNumAtHeatMax =
    2228            0 :         1 + std::distance(zoneCFS.HeatLoadSeq.begin(), std::max_element(zoneCFS.HeatLoadSeq.begin(), zoneCFS.HeatLoadSeq.end()));
    2229            0 :     zoneCFS.TimeStepNumAtHeatNoDOASMax =
    2230            0 :         1 + std::distance(zoneCFS.HeatLoadNoDOASSeq.begin(), std::max_element(zoneCFS.HeatLoadNoDOASSeq.begin(), zoneCFS.HeatLoadNoDOASSeq.end()));
    2231            0 :     zoneCFS.TimeStepNumAtCoolMax =
    2232            0 :         1 + std::distance(zoneCFS.CoolLoadSeq.begin(), std::max_element(zoneCFS.CoolLoadSeq.begin(), zoneCFS.CoolLoadSeq.end()));
    2233            0 :     zoneCFS.TimeStepNumAtCoolNoDOASMax =
    2234            0 :         1 + std::distance(zoneCFS.CoolLoadNoDOASSeq.begin(), std::max_element(zoneCFS.CoolLoadNoDOASSeq.begin(), zoneCFS.CoolLoadNoDOASSeq.end()));
    2235              : 
    2236            0 :     if (zoneCFS.zoneLatentSizing) {
    2237            0 :         if (zoneCFS.DesLatentHeatMassFlow > 0) {
    2238            0 :             zoneCFS.ZoneTempAtLatentHeatPeak /= zoneCFS.DesLatentHeatMassFlow;
    2239            0 :             zoneCFS.ZoneHumRatAtLatentHeatPeak /= zoneCFS.DesLatentHeatMassFlow;
    2240            0 :             zoneCFS.ZoneRetTempAtLatentHeatPeak /= zoneCFS.DesLatentHeatMassFlow;
    2241            0 :             zoneCFS.DesLatentHeatCoilInTemp /= zoneCFS.DesLatentHeatMassFlow;
    2242            0 :             zoneCFS.DesLatentHeatCoilInHumRat /= zoneCFS.DesLatentHeatMassFlow;
    2243              :         }
    2244            0 :         if (zoneCFS.DesLatentCoolMassFlow > 0) {
    2245            0 :             zoneCFS.ZoneTempAtLatentCoolPeak /= zoneCFS.DesLatentCoolMassFlow;
    2246            0 :             zoneCFS.ZoneHumRatAtLatentCoolPeak /= zoneCFS.DesLatentCoolMassFlow;
    2247            0 :             zoneCFS.ZoneRetTempAtLatentCoolPeak /= zoneCFS.DesLatentCoolMassFlow;
    2248            0 :             zoneCFS.DesLatentCoolCoilInTemp /= zoneCFS.DesLatentCoolMassFlow;
    2249            0 :             zoneCFS.DesLatentCoolCoilInHumRat /= zoneCFS.DesLatentCoolMassFlow;
    2250              :         }
    2251              :         // Timestep at max
    2252            0 :         zoneCFS.TimeStepNumAtLatentHeatMax = 1 + std::distance(zoneCFS.LatentHeatFlowSeq.begin(),
    2253              :                                                                std::max_element(zoneCFS.LatentHeatFlowSeq.begin(), zoneCFS.LatentHeatFlowSeq.end()));
    2254            0 :         zoneCFS.TimeStepNumAtLatentHeatNoDOASMax =
    2255            0 :             1 + std::distance(zoneCFS.HeatLatentLoadNoDOASSeq.begin(),
    2256              :                               std::max_element(zoneCFS.HeatLatentLoadNoDOASSeq.begin(), zoneCFS.HeatLatentLoadNoDOASSeq.end()));
    2257            0 :         zoneCFS.TimeStepNumAtLatentCoolMax = 1 + std::distance(zoneCFS.LatentCoolLoadSeq.begin(),
    2258              :                                                                std::max_element(zoneCFS.LatentCoolLoadSeq.begin(), zoneCFS.LatentCoolLoadSeq.end()));
    2259            0 :         zoneCFS.TimeStepNumAtLatentCoolNoDOASMax =
    2260            0 :             1 + std::distance(zoneCFS.CoolLatentLoadNoDOASSeq.begin(),
    2261              :                               std::max_element(zoneCFS.CoolLatentLoadNoDOASSeq.begin(), zoneCFS.CoolLatentLoadNoDOASSeq.end()));
    2262              :     }
    2263              : 
    2264            0 :     return;
    2265              : }
    2266              : 
    2267         3684 : void updateZoneSizingEndZoneSizingCalc2(EnergyPlusData &state, DataSizing::ZoneSizingData &zsCalcSizing)
    2268              : {
    2269         3684 :     if (std::abs(zsCalcSizing.DesCoolLoad) <= 1.e-8) {
    2270           82 :         ShowWarningError(state, format("Calculated design cooling load for zone={} is zero.", zsCalcSizing.ZoneName));
    2271          246 :         ShowContinueError(state, "Check Sizing:Zone and ZoneControl:Thermostat inputs.");
    2272              :     }
    2273         3684 :     if (std::abs(zsCalcSizing.DesHeatLoad) <= 1.e-8) {
    2274          202 :         ShowWarningError(state, format("Calculated design heating load for zone={} is zero.", zsCalcSizing.ZoneName));
    2275          606 :         ShowContinueError(state, "Check Sizing:Zone and ZoneControl:Thermostat inputs.");
    2276              :     }
    2277              : 
    2278         3684 :     Real64 SupplyTemp = 0.0;
    2279         3684 :     Real64 DeltaTemp = 0.0;
    2280              :     // Should this be done only if there is a cooling load? Or would this message help determine why there was no load?
    2281         3684 :     if (std::abs(zsCalcSizing.DesCoolLoad) > 1.e-8) {
    2282              :         // check for low cooling delta T from supply to zone to see if air volume flow rate might be excessively high
    2283         3602 :         if (zsCalcSizing.ZnCoolDgnSAMethod == SupplyAirTemperature) {
    2284         3547 :             SupplyTemp = zsCalcSizing.CoolDesTemp;
    2285         3547 :             DeltaTemp = SupplyTemp - zsCalcSizing.ZoneTempAtCoolPeak;
    2286              :         } else {
    2287           55 :             DeltaTemp = -std::abs(zsCalcSizing.CoolDesTempDiff);
    2288           55 :             SupplyTemp = DeltaTemp + zsCalcSizing.ZoneTempAtCoolPeak;
    2289              :         }
    2290              : 
    2291              :         // check for low delta T to avoid very high flow rates
    2292         3602 :         if (std::abs(DeltaTemp) < 5.0 && std::abs(DeltaTemp) > HVAC::SmallTempDiff) { // Vdot exceeds 1200 cfm/ton @ DT=5
    2293            2 :             if (std::abs(DeltaTemp) >= 2.0) {                                         // Vdot exceeds 3000 cfm/ton @ DT=2
    2294            6 :                 ShowWarningError(state, "UpdateZoneSizing: Cooling supply air temperature (calculated) within 5C of zone temperature");
    2295              :             } else {
    2296            0 :                 ShowSevereError(state, "UpdateZoneSizing: Cooling supply air temperature (calculated) within 2C of zone temperature");
    2297              :             }
    2298            4 :             ShowContinueError(state, "...check zone thermostat set point and design supply air temperatures");
    2299            2 :             ShowContinueError(state, format("...zone name = {}", zsCalcSizing.ZoneName));
    2300            2 :             ShowContinueError(state, format("...design sensible cooling load = {:.2R} W", zsCalcSizing.DesCoolLoad));
    2301            2 :             ShowContinueError(state, format("...thermostat set point temp    = {:.3R} C", zsCalcSizing.CoolTstatTemp));
    2302            2 :             ShowContinueError(state, format("...zone temperature             = {:.3R} C", zsCalcSizing.ZoneTempAtCoolPeak));
    2303            2 :             ShowContinueError(state, format("...supply air temperature       = {:.3R} C", SupplyTemp));
    2304            2 :             ShowContinueError(state, format("...temperature difference       = {:.5R} C", DeltaTemp));
    2305            2 :             ShowContinueError(state, format("...calculated volume flow rate  = {:.5R} m3/s", (zsCalcSizing.DesCoolVolFlow)));
    2306            2 :             ShowContinueError(state, format("...calculated mass flow rate    = {:.5R} kg/s", (zsCalcSizing.DesCoolMassFlow)));
    2307            2 :             if (SupplyTemp > zsCalcSizing.ZoneTempAtCoolPeak) {
    2308            0 :                 ShowContinueError(state, "...Note: supply air temperature should be less than zone temperature during cooling air flow calculations");
    2309              :             }
    2310         3600 :         } else if (std::abs(DeltaTemp) > HVAC::SmallTempDiff && SupplyTemp > zsCalcSizing.ZoneTempAtCoolPeak) {
    2311            0 :             ShowSevereError(state, "UpdateZoneSizing: Supply air temperature is greater than zone temperature during cooling air flow calculations");
    2312            0 :             ShowContinueError(state, format("...calculated volume flow rate  = {:.5R} m3/s", (zsCalcSizing.DesCoolVolFlow)));
    2313            0 :             ShowContinueError(state, format("...calculated mass flow rate    = {:.5R} kg/s", (zsCalcSizing.DesCoolMassFlow)));
    2314            0 :             ShowContinueError(state, format("...thermostat set point temp    = {:.3R} C", zsCalcSizing.CoolTstatTemp));
    2315            0 :             ShowContinueError(state, format("...zone temperature            = {:.3R} C", zsCalcSizing.ZoneTempAtCoolPeak));
    2316            0 :             ShowContinueError(state, format("...supply air temperature      = {:.3R} C", SupplyTemp));
    2317            0 :             ShowContinueError(state, format("...occurs in zone              = {}", zsCalcSizing.ZoneName));
    2318            0 :             ShowContinueError(state, "...Note: supply air temperature should be less than zone temperature during cooling air flow calculations");
    2319              :         }
    2320              :     }
    2321              :     // Should this be done only if there is a heating load? Or would this message help determine why there was no load?
    2322         3684 :     if (std::abs(zsCalcSizing.DesHeatLoad) > 1.e-8) { // ABS() ?
    2323              :         // check for low cooling delta T from supply to zone to see if air volume flow rate might be excessively high
    2324         3482 :         if (zsCalcSizing.ZnHeatDgnSAMethod == SupplyAirTemperature) {
    2325         3427 :             SupplyTemp = zsCalcSizing.HeatDesTemp;
    2326         3427 :             DeltaTemp = SupplyTemp - zsCalcSizing.ZoneTempAtHeatPeak;
    2327              :         } else {
    2328           55 :             DeltaTemp = zsCalcSizing.HeatDesTempDiff;
    2329           55 :             SupplyTemp = DeltaTemp + zsCalcSizing.ZoneTempAtHeatPeak;
    2330              :         }
    2331              : 
    2332         3482 :         if (std::abs(DeltaTemp) < 5.0 && std::abs(DeltaTemp) > HVAC::SmallTempDiff) { // Vdot exceeds 1200 cfm/ton @ DT=5
    2333            0 :             if (std::abs(DeltaTemp) >= 2.0) {                                         // Vdot exceeds 3000 cfm/ton @ DT=2
    2334            0 :                 ShowWarningError(state, "UpdateZoneSizing: Heating supply air temperature (calculated) within 5C of zone temperature");
    2335              :             } else {
    2336            0 :                 ShowSevereError(state, "UpdateZoneSizing: Heating supply air temperature (calculated) within 2C of zone temperature");
    2337              :             }
    2338            0 :             ShowContinueError(state, "...check zone thermostat set point and design supply air temperatures");
    2339            0 :             ShowContinueError(state, format("...zone name = {}", zsCalcSizing.ZoneName));
    2340            0 :             ShowContinueError(state, format("...design heating load         = {:.2R} W", zsCalcSizing.DesHeatLoad));
    2341            0 :             ShowContinueError(state, format("...thermostat set point temp   = {:.3R} C", zsCalcSizing.HeatTstatTemp));
    2342            0 :             ShowContinueError(state, format("...zone temperature            = {:.3R} C", zsCalcSizing.ZoneTempAtHeatPeak));
    2343            0 :             ShowContinueError(state, format("...supply air temperature      = {:.3R} C", SupplyTemp));
    2344            0 :             ShowContinueError(state, format("...temperature difference      = {:.5R} C", DeltaTemp));
    2345            0 :             ShowContinueError(state, format("...calculated volume flow rate = {:.5R} m3/s", (zsCalcSizing.DesHeatVolFlow)));
    2346            0 :             ShowContinueError(state, format("...calculated mass flow rate   = {:.5R} kg/s", (zsCalcSizing.DesHeatMassFlow)));
    2347            0 :             if (SupplyTemp < zsCalcSizing.ZoneTempAtHeatPeak) {
    2348            0 :                 ShowContinueError(state,
    2349              :                                   "...Note: supply air temperature should be greater than zone temperature during heating air "
    2350              :                                   "flow calculations");
    2351              :             }
    2352         3482 :         } else if (std::abs(DeltaTemp) > HVAC::SmallTempDiff && SupplyTemp < zsCalcSizing.ZoneTempAtHeatPeak) {
    2353            0 :             ShowSevereError(state, "UpdateZoneSizing: Supply air temperature is less than zone temperature during heating air flow calculations");
    2354            0 :             ShowContinueError(state, format("...calculated design heating volume flow rate = {:.5R} m3/s", (zsCalcSizing.DesHeatVolFlow)));
    2355            0 :             ShowContinueError(state, format("...calculated design heating mass flow rate   = {:.5R} kg/s", (zsCalcSizing.DesHeatMassFlow)));
    2356            0 :             ShowContinueError(state, format("...thermostat set point temp   = {:.3R} C", zsCalcSizing.HeatTstatTemp));
    2357            0 :             ShowContinueError(state, format("...zone temperature            = {:.3R} C", zsCalcSizing.ZoneTempAtHeatPeak));
    2358            0 :             ShowContinueError(state, format("...supply air temperature      = {:.3R} C", SupplyTemp));
    2359            0 :             ShowContinueError(state, format("...occurs in zone              = {}", zsCalcSizing.ZoneName));
    2360            0 :             ShowContinueError(state,
    2361              :                               "...Note: supply air temperature should be greater than zone temperature during heating air "
    2362              :                               "flow calculations");
    2363              :         }
    2364              :     }
    2365         3684 :     zsCalcSizing.HeatPeakDateHrMin = zsCalcSizing.cHeatDDDate + ' ' + sizingPeakTimeStamp(state, zsCalcSizing.TimeStepNumAtHeatMax);
    2366              : 
    2367         3684 :     zsCalcSizing.CoolPeakDateHrMin = zsCalcSizing.cCoolDDDate + ' ' + sizingPeakTimeStamp(state, zsCalcSizing.TimeStepNumAtCoolMax);
    2368              : 
    2369         3684 :     zsCalcSizing.LatHeatPeakDateHrMin = zsCalcSizing.cLatentHeatDDDate + ' ' + sizingPeakTimeStamp(state, zsCalcSizing.TimeStepNumAtLatentHeatMax);
    2370              : 
    2371         3684 :     zsCalcSizing.LatCoolPeakDateHrMin = zsCalcSizing.cLatentCoolDDDate + ' ' + sizingPeakTimeStamp(state, zsCalcSizing.TimeStepNumAtLatentCoolMax);
    2372         3684 : }
    2373              : 
    2374        14736 : std::string sizingPeakTimeStamp(EnergyPlusData const &state, int timeStepIndex)
    2375              : {
    2376        14736 :     int constexpr minToSec = 60;
    2377        14736 :     int hour = 0;
    2378        14736 :     int minute = 0;
    2379        14736 :     Real64 second = 0;
    2380              : 
    2381        14736 :     Real64 timeInSeconds = timeStepIndex * state.dataGlobal->MinutesInTimeStep * minToSec;
    2382        14736 :     General::ParseTime(timeInSeconds, hour, minute, second);
    2383        29472 :     return format(PeakHrMinFmt, hour, minute);
    2384              : }
    2385              : 
    2386          430 : void writeZszSpsz(EnergyPlusData &state,
    2387              :                   EnergyPlus::InputOutputFile &outputFile,
    2388              :                   int const numSpacesOrZones,
    2389              :                   EPVector<DataSizing::ZoneSizingData> const &zsCalcFinalSizing,
    2390              :                   Array2D<DataSizing::ZoneSizingData> const &zsCalcSizing,
    2391              :                   bool const forSpaces)
    2392              : {
    2393          430 :     char const colSep = state.dataSize->SizingFileColSep;
    2394          430 :     print(outputFile, "Time");
    2395         4607 :     for (int i = 1; i <= numSpacesOrZones; ++i) {
    2396         4177 :         int zoneNum = (forSpaces) ? state.dataHeatBal->space(i).zoneNum : i;
    2397         4177 :         if (!state.dataHeatBal->Zone(zoneNum).IsControlled) {
    2398          493 :             continue;
    2399              :         }
    2400         3684 :         auto &thisCalcFS = zsCalcFinalSizing(i);
    2401              : 
    2402              :         static constexpr std::string_view ZSizeFmt11("{}{}:{}{}{}{}:{}{}{}{}:{}{}{}{}:{}{}{}{}:{}{}{}{}:{}{}{}{}:{}{}{}{}:{}{}{}{}:{}{}{}{}:{"
    2403              :                                                      "}{}{}{}:{}{}{}{}:{}{}{}{}:{}{}{}{}:{}{}{}{}:{}{}{}{}:{}{}");
    2404         3684 :         print(outputFile,
    2405              :               ZSizeFmt11,
    2406              :               colSep,
    2407         3684 :               thisCalcFS.ZoneName,
    2408         3684 :               thisCalcFS.HeatDesDay,
    2409              :               ":Des Heat Load [W]",
    2410              :               colSep,
    2411         3684 :               thisCalcFS.ZoneName,
    2412         3684 :               thisCalcFS.CoolDesDay,
    2413              :               ":Des Sens Cool Load [W]",
    2414              :               colSep,
    2415         3684 :               thisCalcFS.ZoneName,
    2416         3684 :               thisCalcFS.HeatDesDay,
    2417              :               ":Des Heat Mass Flow [kg/s]",
    2418              :               colSep,
    2419         3684 :               thisCalcFS.ZoneName,
    2420         3684 :               thisCalcFS.CoolDesDay,
    2421              :               ":Des Cool Mass Flow [kg/s]",
    2422              :               colSep,
    2423         3684 :               thisCalcFS.ZoneName,
    2424         3684 :               thisCalcFS.LatHeatDesDay,
    2425              :               ":Des Latent Heat Load [W]",
    2426              :               colSep,
    2427         3684 :               thisCalcFS.ZoneName,
    2428         3684 :               thisCalcFS.LatCoolDesDay,
    2429              :               ":Des Latent Cool Load [W]",
    2430              :               colSep,
    2431         3684 :               thisCalcFS.ZoneName,
    2432         3684 :               thisCalcFS.LatHeatDesDay,
    2433              :               ":Des Latent Heat Mass Flow [kg/s]",
    2434              :               colSep,
    2435         3684 :               thisCalcFS.ZoneName,
    2436         3684 :               thisCalcFS.LatCoolDesDay,
    2437              :               ":Des Latent Cool Mass Flow [kg/s]",
    2438              :               colSep,
    2439         3684 :               thisCalcFS.ZoneName,
    2440         3684 :               thisCalcFS.HeatNoDOASDesDay,
    2441              :               ":Des Heat Load No DOAS [W]",
    2442              :               colSep,
    2443         3684 :               thisCalcFS.ZoneName,
    2444         3684 :               thisCalcFS.CoolNoDOASDesDay,
    2445              :               ":Des Sens Cool Load No DOAS [W]",
    2446              :               colSep,
    2447         3684 :               thisCalcFS.ZoneName,
    2448         3684 :               thisCalcFS.LatHeatNoDOASDesDay,
    2449              :               ":Des Latent Heat Load No DOAS [W]",
    2450              :               colSep,
    2451         3684 :               thisCalcFS.ZoneName,
    2452         3684 :               thisCalcFS.LatCoolNoDOASDesDay,
    2453              :               ":Des Latent Cool Load No DOAS [W]",
    2454              :               colSep,
    2455         3684 :               thisCalcFS.ZoneName,
    2456         3684 :               thisCalcFS.HeatDesDay,
    2457              :               ":Heating Zone Temperature [C]",
    2458              :               colSep,
    2459         3684 :               thisCalcFS.ZoneName,
    2460         3684 :               thisCalcFS.HeatDesDay,
    2461              :               ":Heating Zone Relative Humidity [%]",
    2462              :               colSep,
    2463         3684 :               thisCalcFS.ZoneName,
    2464         3684 :               thisCalcFS.CoolDesDay,
    2465              :               ":Cooling Zone Temperature [C]",
    2466              :               colSep,
    2467         3684 :               thisCalcFS.ZoneName,
    2468         3684 :               thisCalcFS.CoolDesDay,
    2469              :               ":Cooling Zone Relative Humidity [%]");
    2470              :     }
    2471          430 :     print(outputFile, "\n");
    2472              :     //      HourFrac = 0.0
    2473          430 :     int Minutes = 0;
    2474          430 :     int TimeStepIndex = 0;
    2475        10750 :     for (int HourCounter = 1; HourCounter <= 24; ++HourCounter) {
    2476        63960 :         for (int TimeStepCounter = 1; TimeStepCounter <= state.dataGlobal->TimeStepsInHour; ++TimeStepCounter) {
    2477        53640 :             ++TimeStepIndex;
    2478        53640 :             Minutes += state.dataGlobal->MinutesInTimeStep;
    2479        53640 :             int HourPrint = HourCounter - 1;
    2480        53640 :             if (Minutes == 60) {
    2481        10320 :                 Minutes = 0;
    2482        10320 :                 HourPrint = HourCounter;
    2483              :             }
    2484              :             static constexpr std::string_view ZSizeFmt20("{:02}:{:02}:00");
    2485        53640 :             print(outputFile, ZSizeFmt20, HourPrint, Minutes);
    2486       556920 :             for (int i = 1; i <= numSpacesOrZones; ++i) {
    2487       503280 :                 int zoneNum = (forSpaces) ? state.dataHeatBal->space(i).zoneNum : i;
    2488       503280 :                 if (!state.dataHeatBal->Zone(zoneNum).IsControlled) {
    2489        56256 :                     continue;
    2490              :                 }
    2491       447024 :                 auto &thisCalcFS = zsCalcFinalSizing(i);
    2492              :                 static constexpr std::string_view ZSizeFmt21("{}{:12.6E}{}{:12.6E}{}{:12.6E}{}{:12.6E}{}{:12.6E}{}{:12.6E}{}{:12.6E}{}{:12."
    2493              :                                                              "6E}{}{:12.6E}{}{:12.6E}{}{:12.6E}{}{:12.6E}{}{:12.6E}{}{:12.6E}{}{:12.6E}{}{:12.6E}");
    2494       447024 :                 Real64 ZoneRHHeat = 0.0;
    2495       447024 :                 Real64 ZoneRHCool = 0.0;
    2496       447024 :                 Real64 ZoneTHeat = 0.0;
    2497       447024 :                 Real64 ZoneTCool = 0.0;
    2498       447024 :                 if (thisCalcFS.HeatDDNum > 0) {
    2499       446496 :                     ZoneTHeat = zsCalcSizing(thisCalcFS.HeatDDNum, i).HeatZoneTempSeq(TimeStepIndex);
    2500       446496 :                     ZoneRHHeat = Psychrometrics::PsyRhFnTdbWPb(state,
    2501       446496 :                                                                zsCalcSizing(thisCalcFS.HeatDDNum, i).HeatZoneTempSeq(TimeStepIndex),
    2502       446496 :                                                                zsCalcSizing(thisCalcFS.HeatDDNum, i).HeatZoneHumRatSeq(TimeStepIndex),
    2503       892992 :                                                                state.dataEnvrn->OutBaroPress) *
    2504              :                                  100.0;
    2505              :                 }
    2506       447024 :                 if (thisCalcFS.CoolDDNum > 0) {
    2507       447024 :                     ZoneTCool = zsCalcSizing(thisCalcFS.CoolDDNum, i).CoolZoneTempSeq(TimeStepIndex);
    2508       447024 :                     ZoneRHCool = Psychrometrics::PsyRhFnTdbWPb(state,
    2509       447024 :                                                                zsCalcSizing(thisCalcFS.CoolDDNum, i).CoolZoneTempSeq(TimeStepIndex),
    2510       447024 :                                                                zsCalcSizing(thisCalcFS.CoolDDNum, i).CoolZoneHumRatSeq(TimeStepIndex),
    2511       894048 :                                                                state.dataEnvrn->OutBaroPress) *
    2512              :                                  100.0;
    2513              :                 }
    2514       447024 :                 print(outputFile,
    2515              :                       ZSizeFmt21,
    2516              :                       colSep,
    2517              :                       thisCalcFS.HeatLoadSeq(TimeStepIndex),
    2518              :                       colSep,
    2519              :                       thisCalcFS.CoolLoadSeq(TimeStepIndex),
    2520              :                       colSep,
    2521              :                       thisCalcFS.HeatFlowSeq(TimeStepIndex),
    2522              :                       colSep,
    2523              :                       thisCalcFS.CoolFlowSeq(TimeStepIndex),
    2524              :                       colSep,
    2525              :                       thisCalcFS.LatentHeatLoadSeq(TimeStepIndex),
    2526              :                       colSep,
    2527              :                       thisCalcFS.LatentCoolLoadSeq(TimeStepIndex),
    2528              :                       colSep,
    2529              :                       thisCalcFS.LatentHeatFlowSeq(TimeStepIndex),
    2530              :                       colSep,
    2531              :                       thisCalcFS.LatentCoolFlowSeq(TimeStepIndex),
    2532              :                       colSep,
    2533              :                       thisCalcFS.HeatLoadNoDOASSeq(TimeStepIndex),
    2534              :                       colSep,
    2535              :                       thisCalcFS.CoolLoadNoDOASSeq(TimeStepIndex),
    2536              :                       colSep,
    2537              :                       thisCalcFS.HeatLatentLoadNoDOASSeq(TimeStepIndex),
    2538              :                       colSep,
    2539              :                       thisCalcFS.CoolLatentLoadNoDOASSeq(TimeStepIndex),
    2540              :                       colSep,
    2541              :                       ZoneTHeat,
    2542              :                       colSep,
    2543              :                       ZoneRHHeat,
    2544              :                       colSep,
    2545              :                       ZoneTCool,
    2546              :                       colSep,
    2547              :                       ZoneRHCool);
    2548              :             }
    2549        53640 :             print(outputFile, "\n");
    2550              :         }
    2551              :     }
    2552          430 :     print(outputFile, "Peak");
    2553              : 
    2554         4607 :     for (int i = 1; i <= numSpacesOrZones; ++i) {
    2555         4177 :         int zoneNum = (forSpaces) ? state.dataHeatBal->space(i).zoneNum : i;
    2556         4177 :         if (!state.dataHeatBal->Zone(zoneNum).IsControlled) {
    2557          493 :             continue;
    2558              :         }
    2559         3684 :         auto &thisCalcFS = zsCalcFinalSizing(i);
    2560              : 
    2561              :         static constexpr std::string_view ZSizeFmt31("{}{:12.6E}{}{:12.6E}{}{:12.6E}{}{:12.6E}{}{:12.6E}{}{:12.6E}{}{:12.6E}{}{:12.6E}{}{:12."
    2562              :                                                      "6E}{}{:12.6E}{}{:12.6E}{}{:12.6E}{}{}{}{}");
    2563         3684 :         print(outputFile,
    2564              :               ZSizeFmt31,
    2565              :               colSep,
    2566         3684 :               thisCalcFS.DesHeatLoad,
    2567              :               colSep,
    2568         3684 :               thisCalcFS.DesCoolLoad,
    2569              :               colSep,
    2570         3684 :               thisCalcFS.DesHeatMassFlow,
    2571              :               colSep,
    2572         3684 :               thisCalcFS.DesCoolMassFlow,
    2573              :               colSep,
    2574         3684 :               thisCalcFS.DesLatentHeatLoad,
    2575              :               colSep,
    2576         3684 :               thisCalcFS.DesLatentCoolLoad,
    2577              :               colSep,
    2578         3684 :               thisCalcFS.DesLatentHeatMassFlow,
    2579              :               colSep,
    2580         3684 :               thisCalcFS.DesLatentCoolMassFlow,
    2581              :               colSep,
    2582         3684 :               thisCalcFS.DesHeatLoadNoDOAS,
    2583              :               colSep,
    2584         3684 :               thisCalcFS.DesCoolLoadNoDOAS,
    2585              :               colSep,
    2586         3684 :               thisCalcFS.DesLatentHeatLoadNoDOAS,
    2587              :               colSep,
    2588         3684 :               thisCalcFS.DesLatentCoolLoadNoDOAS,
    2589              :               colSep,
    2590              :               colSep,
    2591              :               colSep,
    2592              :               colSep);
    2593              :     }
    2594          430 :     print(outputFile, "\n");
    2595              : 
    2596          430 :     print(outputFile, "\nPeak Vol Flow (m3/s)");
    2597         4607 :     for (int i = 1; i <= numSpacesOrZones; ++i) {
    2598         4177 :         int zoneNum = (forSpaces) ? state.dataHeatBal->space(i).zoneNum : i;
    2599         4177 :         if (!state.dataHeatBal->Zone(zoneNum).IsControlled) {
    2600          493 :             continue;
    2601              :         }
    2602         3684 :         auto &thisCalcFS = zsCalcFinalSizing(i);
    2603              :         static constexpr std::string_view ZSizeFmt41("{}{}{}{:12.6E}{}{:12.6E}{}{}{}{:12.6E}{}{:12.6E}{}{}{}{}{}{}{}{}");
    2604         3684 :         print(outputFile,
    2605              :               ZSizeFmt41,
    2606              :               colSep,
    2607              :               colSep,
    2608              :               colSep,
    2609         3684 :               thisCalcFS.DesHeatVolFlow,
    2610              :               colSep,
    2611         3684 :               thisCalcFS.DesCoolVolFlow,
    2612              :               colSep,
    2613              :               colSep,
    2614              :               colSep,
    2615         3684 :               thisCalcFS.DesLatentHeatVolFlow,
    2616              :               colSep,
    2617         3684 :               thisCalcFS.DesLatentCoolVolFlow,
    2618              :               colSep,
    2619              :               colSep,
    2620              :               colSep,
    2621              :               colSep,
    2622              :               colSep,
    2623              :               colSep,
    2624              :               colSep,
    2625              :               colSep);
    2626              :     }
    2627          430 :     print(outputFile, "\n");
    2628          430 :     outputFile.close();
    2629          430 : }
    2630              : 
    2631            8 : void updateZoneSizingEndZoneSizingCalc3(DataSizing::ZoneSizingData &zsCalcFinalSizing,
    2632              :                                         Array2D<DataSizing::ZoneSizingData> &zsCalcSizing,
    2633              :                                         bool &anyLatentLoad,
    2634              :                                         int const zoneOrSpaceNum)
    2635              : {
    2636              :     // latent sizing data has the same variables as sensible sizing data
    2637              :     // if the user has specified latent sizing, move the latent sizing data into the final calc arrays
    2638              :     // this method allows all upstream sizing functions to use the same data as before (e.g., DesCoolVolFlow)
    2639              :     // if sensible sizing, use sensible data. if latent sizing, use latent data (if there is latent data).
    2640              :     // if sensible or latent sizing, use larger of sensible and latent based on volume flow rate
    2641              : 
    2642            8 :     if ((zsCalcFinalSizing.zoneSizingMethod == ZoneSizing::Latent && zsCalcFinalSizing.DesLatentCoolVolFlow > 0.0) ||
    2643            8 :         (zsCalcFinalSizing.zoneSizingMethod == ZoneSizing::SensibleAndLatent &&
    2644            8 :          zsCalcFinalSizing.DesLatentCoolLoad > zsCalcFinalSizing.DesCoolLoad)) {
    2645            5 :         anyLatentLoad = true;
    2646            5 :         zsCalcFinalSizing.CoolSizingType = "Latent Cooling"; // string reported to eio
    2647            5 :         zsCalcFinalSizing.DesCoolVolFlow = zsCalcFinalSizing.DesLatentCoolVolFlow;
    2648            5 :         zsCalcFinalSizing.DesCoolMassFlow = zsCalcFinalSizing.DesLatentCoolMassFlow;
    2649            5 :         zsCalcFinalSizing.DesCoolLoad = zsCalcFinalSizing.DesLatentCoolLoad;
    2650            5 :         zsCalcFinalSizing.CoolDesDay = zsCalcFinalSizing.LatCoolDesDay;
    2651            5 :         zsCalcFinalSizing.cCoolDDDate = zsCalcFinalSizing.cLatentCoolDDDate;
    2652            5 :         zsCalcFinalSizing.CoolDDNum = zsCalcFinalSizing.LatentCoolDDNum;
    2653            5 :         zsCalcFinalSizing.TimeStepNumAtCoolMax = zsCalcFinalSizing.TimeStepNumAtLatentCoolMax;
    2654            5 :         zsCalcFinalSizing.CoolFlowSeq = zsCalcFinalSizing.LatentCoolFlowSeq;
    2655            5 :         zsCalcFinalSizing.DesCoolCoilInTemp = zsCalcFinalSizing.DesLatentCoolCoilInTemp;
    2656            5 :         zsCalcFinalSizing.DesCoolCoilInHumRat = zsCalcFinalSizing.DesLatentCoolCoilInHumRat;
    2657            5 :         zsCalcFinalSizing.ZoneRetTempAtCoolPeak = zsCalcFinalSizing.ZoneRetTempAtLatentCoolPeak;
    2658            5 :         zsCalcFinalSizing.ZoneTempAtCoolPeak = zsCalcFinalSizing.ZoneTempAtLatentCoolPeak;
    2659            5 :         zsCalcFinalSizing.ZoneHumRatAtCoolPeak = zsCalcFinalSizing.ZoneHumRatAtLatentCoolPeak;
    2660            5 :         zsCalcFinalSizing.CoolPeakDateHrMin = zsCalcFinalSizing.LatCoolPeakDateHrMin;
    2661              : 
    2662              :         // the zone supply air humrat used for latent sizing is required to adequately size coil capacity
    2663            5 :         if (zsCalcFinalSizing.ZnLatCoolDgnSAMethod == SupplyAirHumidityRatio) {
    2664            0 :             zsCalcFinalSizing.CoolDesHumRat = zsCalcFinalSizing.LatentCoolDesHumRat;
    2665              :         } else {
    2666            5 :             zsCalcFinalSizing.CoolDesHumRat = zsCalcFinalSizing.ZoneHumRatAtLatentCoolPeak - zsCalcFinalSizing.CoolDesHumRatDiff;
    2667              :         }
    2668              : 
    2669            5 :         if (zsCalcFinalSizing.LatentCoolDDNum > 0) {
    2670            5 :             auto &calcZoneSizing = zsCalcSizing(zsCalcFinalSizing.LatentCoolDDNum, zoneOrSpaceNum);
    2671            5 :             calcZoneSizing.DesCoolVolFlow = calcZoneSizing.DesLatentCoolVolFlow;
    2672            5 :             calcZoneSizing.DesCoolMassFlow = calcZoneSizing.DesLatentCoolMassFlow;
    2673            5 :             calcZoneSizing.DesCoolLoad = calcZoneSizing.DesLatentCoolLoad;
    2674            5 :             calcZoneSizing.CoolDesDay = calcZoneSizing.LatCoolDesDay;
    2675            5 :             calcZoneSizing.cCoolDDDate = zsCalcFinalSizing.cLatentCoolDDDate; // this has correct CoolDDDate
    2676            5 :             calcZoneSizing.CoolDDNum = calcZoneSizing.LatentCoolDDNum;
    2677            5 :             calcZoneSizing.TimeStepNumAtCoolMax = calcZoneSizing.TimeStepNumAtLatentCoolMax;
    2678            5 :             calcZoneSizing.CoolFlowSeq = calcZoneSizing.LatentCoolFlowSeq;
    2679            5 :             calcZoneSizing.DesCoolCoilInTemp = calcZoneSizing.DesLatentCoolCoilInTemp;
    2680            5 :             calcZoneSizing.DesCoolCoilInHumRat = calcZoneSizing.DesLatentCoolCoilInHumRat;
    2681            5 :             calcZoneSizing.ZoneRetTempAtCoolPeak = calcZoneSizing.ZoneRetTempAtLatentCoolPeak;
    2682            5 :             calcZoneSizing.ZoneTempAtCoolPeak = calcZoneSizing.ZoneTempAtLatentCoolPeak;
    2683            5 :             calcZoneSizing.ZoneHumRatAtCoolPeak = calcZoneSizing.ZoneHumRatAtLatentCoolPeak;
    2684            5 :             calcZoneSizing.CoolPeakDateHrMin = zsCalcFinalSizing.LatCoolPeakDateHrMin;
    2685              : 
    2686              :             // the zone supply air humrat used for latent sizing is required to adequately size coil capacity
    2687            5 :             if (calcZoneSizing.ZnLatCoolDgnSAMethod == SupplyAirHumidityRatio) {
    2688            0 :                 calcZoneSizing.CoolDesHumRat = calcZoneSizing.LatentCoolDesHumRat;
    2689              :             } else {
    2690            5 :                 calcZoneSizing.CoolDesHumRat = calcZoneSizing.ZoneHumRatAtLatentCoolPeak - calcZoneSizing.CoolDesHumRatDiff;
    2691              :             }
    2692              :         }
    2693              :     }
    2694            8 :     if ((zsCalcFinalSizing.zoneSizingMethod == ZoneSizing::Latent && zsCalcFinalSizing.DesLatentHeatVolFlow > 0.0) ||
    2695            8 :         (zsCalcFinalSizing.zoneSizingMethod == ZoneSizing::SensibleAndLatent &&
    2696            8 :          zsCalcFinalSizing.DesLatentHeatLoad > zsCalcFinalSizing.DesHeatLoad)) {
    2697              : 
    2698            0 :         zsCalcFinalSizing.HeatSizingType = "Latent Heating"; // string reported to eio
    2699            0 :         zsCalcFinalSizing.DesHeatVolFlow = zsCalcFinalSizing.DesLatentHeatVolFlow;
    2700            0 :         zsCalcFinalSizing.DesHeatMassFlow = zsCalcFinalSizing.DesLatentHeatMassFlow;
    2701            0 :         zsCalcFinalSizing.DesHeatLoad = zsCalcFinalSizing.DesLatentHeatLoad;
    2702            0 :         zsCalcFinalSizing.HeatDesDay = zsCalcFinalSizing.LatHeatDesDay;
    2703            0 :         zsCalcFinalSizing.cHeatDDDate = zsCalcFinalSizing.cLatentHeatDDDate;
    2704            0 :         zsCalcFinalSizing.HeatDDNum = zsCalcFinalSizing.LatentHeatDDNum;
    2705            0 :         zsCalcFinalSizing.TimeStepNumAtHeatMax = zsCalcFinalSizing.TimeStepNumAtLatentHeatMax;
    2706            0 :         zsCalcFinalSizing.HeatFlowSeq = zsCalcFinalSizing.LatentHeatFlowSeq;
    2707            0 :         zsCalcFinalSizing.DesHeatCoilInTemp = zsCalcFinalSizing.DesLatentHeatCoilInTemp;
    2708            0 :         zsCalcFinalSizing.DesHeatCoilInHumRat = zsCalcFinalSizing.DesLatentHeatCoilInHumRat;
    2709            0 :         zsCalcFinalSizing.ZoneRetTempAtHeatPeak = zsCalcFinalSizing.ZoneRetTempAtLatentHeatPeak;
    2710            0 :         zsCalcFinalSizing.ZoneTempAtHeatPeak = zsCalcFinalSizing.ZoneTempAtLatentHeatPeak;
    2711            0 :         zsCalcFinalSizing.ZoneHumRatAtHeatPeak = zsCalcFinalSizing.ZoneHumRatAtLatentHeatPeak;
    2712            0 :         zsCalcFinalSizing.HeatPeakDateHrMin = zsCalcFinalSizing.LatHeatPeakDateHrMin;
    2713              : 
    2714              :         // will this cause sizing issues with heating coils since SA humrat is higher than zone humrat?
    2715              :         // use zone humrat instead? this value would size humidifiers well, but what about heating coils?
    2716              :         // not sure at this point if heating should reset HeatDesHumRat
    2717            0 :         if (zsCalcFinalSizing.ZnLatHeatDgnSAMethod == SupplyAirHumidityRatio) {
    2718            0 :             zsCalcFinalSizing.HeatDesHumRat = zsCalcFinalSizing.LatentHeatDesHumRat;
    2719              :         } else {
    2720            0 :             zsCalcFinalSizing.HeatDesHumRat = zsCalcFinalSizing.ZoneHumRatAtLatentHeatPeak + zsCalcFinalSizing.HeatDesHumRatDiff;
    2721              :         }
    2722              : 
    2723            0 :         if (zsCalcFinalSizing.LatentHeatDDNum > 0) {
    2724            0 :             auto &calcZoneSizing = zsCalcSizing(zsCalcFinalSizing.LatentHeatDDNum, zoneOrSpaceNum);
    2725            0 :             calcZoneSizing.DesHeatVolFlow = calcZoneSizing.DesLatentHeatVolFlow;
    2726            0 :             calcZoneSizing.DesHeatMassFlow = calcZoneSizing.DesLatentHeatMassFlow;
    2727            0 :             calcZoneSizing.DesHeatLoad = calcZoneSizing.DesLatentHeatLoad;
    2728            0 :             calcZoneSizing.HeatDesDay = calcZoneSizing.LatHeatDesDay;
    2729            0 :             calcZoneSizing.cHeatDDDate = zsCalcFinalSizing.cLatentHeatDDDate; // this has correct HeatDDDate
    2730            0 :             calcZoneSizing.HeatDDNum = calcZoneSizing.LatentHeatDDNum;
    2731            0 :             calcZoneSizing.TimeStepNumAtHeatMax = calcZoneSizing.TimeStepNumAtLatentHeatMax;
    2732            0 :             calcZoneSizing.HeatFlowSeq = calcZoneSizing.LatentHeatFlowSeq;
    2733            0 :             calcZoneSizing.DesHeatCoilInTemp = calcZoneSizing.DesLatentHeatCoilInTemp;
    2734            0 :             calcZoneSizing.DesHeatCoilInHumRat = calcZoneSizing.DesLatentHeatCoilInHumRat;
    2735            0 :             calcZoneSizing.ZoneRetTempAtHeatPeak = calcZoneSizing.ZoneRetTempAtLatentHeatPeak;
    2736            0 :             calcZoneSizing.ZoneTempAtHeatPeak = calcZoneSizing.ZoneTempAtLatentHeatPeak;
    2737            0 :             calcZoneSizing.ZoneHumRatAtHeatPeak = calcZoneSizing.ZoneHumRatAtLatentHeatPeak;
    2738            0 :             calcZoneSizing.HeatPeakDateHrMin = zsCalcFinalSizing.LatHeatPeakDateHrMin;
    2739              : 
    2740              :             // the zone supply air humrat used for latent sizing is required to adequately size coil capacity
    2741              :             // not sure at this point if heating should reset HeatDesHumRat
    2742            0 :             if (calcZoneSizing.ZnLatHeatDgnSAMethod == SupplyAirHumidityRatio) {
    2743            0 :                 calcZoneSizing.HeatDesHumRat = calcZoneSizing.LatentHeatDesHumRat;
    2744              :             } else {
    2745            0 :                 calcZoneSizing.HeatDesHumRat = calcZoneSizing.ZoneHumRatAtLatentHeatPeak + calcZoneSizing.HeatDesHumRatDiff;
    2746              :             }
    2747              :         }
    2748              :     }
    2749            8 : }
    2750        10174 : void updateZoneSizingEndZoneSizingCalc4(DataSizing::ZoneSizingData &zsSizing, DataSizing::ZoneSizingData const &zsCalcSizing)
    2751              : {
    2752              :     // Move data from Calc arrays to user modified arrays
    2753        10174 :     zsSizing.CoolDesDay = zsCalcSizing.CoolDesDay;
    2754        10174 :     zsSizing.HeatDesDay = zsCalcSizing.HeatDesDay;
    2755        10174 :     zsSizing.DesHeatDens = zsCalcSizing.DesHeatDens;
    2756        10174 :     zsSizing.DesCoolDens = zsCalcSizing.DesCoolDens;
    2757        10174 :     zsSizing.HeatDDNum = zsCalcSizing.HeatDDNum;
    2758        10174 :     zsSizing.CoolDDNum = zsCalcSizing.CoolDDNum;
    2759              : 
    2760        10174 :     zsSizing.DesHeatLoad = zsCalcSizing.DesHeatLoad;
    2761        10174 :     zsSizing.DesHeatMassFlow = zsCalcSizing.DesHeatMassFlow;
    2762        10174 :     zsSizing.ZoneTempAtHeatPeak = zsCalcSizing.ZoneTempAtHeatPeak;
    2763        10174 :     zsSizing.OutTempAtHeatPeak = zsCalcSizing.OutTempAtHeatPeak;
    2764        10174 :     zsSizing.ZoneRetTempAtHeatPeak = zsCalcSizing.ZoneRetTempAtHeatPeak;
    2765        10174 :     zsSizing.ZoneHumRatAtHeatPeak = zsCalcSizing.ZoneHumRatAtHeatPeak;
    2766        10174 :     zsSizing.OutHumRatAtHeatPeak = zsCalcSizing.OutHumRatAtHeatPeak;
    2767        10174 :     zsSizing.TimeStepNumAtHeatMax = zsCalcSizing.TimeStepNumAtHeatMax;
    2768        10174 :     zsSizing.DesHeatVolFlow = zsCalcSizing.DesHeatVolFlow;
    2769        10174 :     zsSizing.DesHeatCoilInTemp = zsCalcSizing.DesHeatCoilInTemp;
    2770        10174 :     zsSizing.DesHeatCoilInHumRat = zsCalcSizing.DesHeatCoilInHumRat;
    2771        10174 :     zsSizing.CoolDesHumRat = zsCalcSizing.CoolDesHumRat;
    2772              : 
    2773        10174 :     zsSizing.DesCoolLoad = zsCalcSizing.DesCoolLoad;
    2774        10174 :     zsSizing.DesCoolMassFlow = zsCalcSizing.DesCoolMassFlow;
    2775        10174 :     zsSizing.ZoneTempAtCoolPeak = zsCalcSizing.ZoneTempAtCoolPeak;
    2776        10174 :     zsSizing.OutTempAtCoolPeak = zsCalcSizing.OutTempAtCoolPeak;
    2777        10174 :     zsSizing.ZoneRetTempAtCoolPeak = zsCalcSizing.ZoneRetTempAtCoolPeak;
    2778        10174 :     zsSizing.ZoneHumRatAtCoolPeak = zsCalcSizing.ZoneHumRatAtCoolPeak;
    2779        10174 :     zsSizing.OutHumRatAtCoolPeak = zsCalcSizing.OutHumRatAtCoolPeak;
    2780        10174 :     zsSizing.TimeStepNumAtCoolMax = zsCalcSizing.TimeStepNumAtCoolMax;
    2781        10174 :     zsSizing.DesCoolVolFlow = zsCalcSizing.DesCoolVolFlow;
    2782        10174 :     zsSizing.DesCoolCoilInTemp = zsCalcSizing.DesCoolCoilInTemp;
    2783        10174 :     zsSizing.DesCoolCoilInHumRat = zsCalcSizing.DesCoolCoilInHumRat;
    2784        10174 : }
    2785              : 
    2786         4568 : void updateZoneSizingEndZoneSizingCalc5(DataSizing::ZoneSizingData &zsFinalSizing, DataSizing::ZoneSizingData const &zsCalcFinalSizing)
    2787              : {
    2788              :     // Move data from CalcFinal arrays to user modified final arrays
    2789              :     // SpaceSizing TODO: This is essentially the same as updateZoneSizingEndZoneSizingCalc4, except there are two extra fields copied here
    2790         4568 :     zsFinalSizing.CoolDesDay = zsCalcFinalSizing.CoolDesDay;
    2791         4568 :     zsFinalSizing.HeatDesDay = zsCalcFinalSizing.HeatDesDay;
    2792         4568 :     zsFinalSizing.DesHeatDens = zsCalcFinalSizing.DesHeatDens;
    2793         4568 :     zsFinalSizing.DesCoolDens = zsCalcFinalSizing.DesCoolDens;
    2794         4568 :     zsFinalSizing.HeatDDNum = zsCalcFinalSizing.HeatDDNum;
    2795         4568 :     zsFinalSizing.CoolDDNum = zsCalcFinalSizing.CoolDDNum;
    2796              : 
    2797         4568 :     zsFinalSizing.DesHeatLoad = zsCalcFinalSizing.DesHeatLoad;
    2798         4568 :     zsFinalSizing.NonAirSysDesHeatLoad = zsCalcFinalSizing.DesHeatLoad;
    2799         4568 :     zsFinalSizing.DesHeatMassFlow = zsCalcFinalSizing.DesHeatMassFlow;
    2800         4568 :     zsFinalSizing.ZoneTempAtHeatPeak = zsCalcFinalSizing.ZoneTempAtHeatPeak;
    2801         4568 :     zsFinalSizing.OutTempAtHeatPeak = zsCalcFinalSizing.OutTempAtHeatPeak;
    2802         4568 :     zsFinalSizing.ZoneRetTempAtHeatPeak = zsCalcFinalSizing.ZoneRetTempAtHeatPeak;
    2803         4568 :     zsFinalSizing.ZoneHumRatAtHeatPeak = zsCalcFinalSizing.ZoneHumRatAtHeatPeak;
    2804         4568 :     zsFinalSizing.OutHumRatAtHeatPeak = zsCalcFinalSizing.OutHumRatAtHeatPeak;
    2805         4568 :     zsFinalSizing.TimeStepNumAtHeatMax = zsCalcFinalSizing.TimeStepNumAtHeatMax;
    2806         4568 :     zsFinalSizing.DesHeatVolFlow = zsCalcFinalSizing.DesHeatVolFlow;
    2807         4568 :     zsFinalSizing.NonAirSysDesHeatVolFlow = zsCalcFinalSizing.DesHeatVolFlow; // SpaceSizing TODO: Suspicious
    2808         4568 :     zsFinalSizing.DesHeatCoilInTemp = zsCalcFinalSizing.DesHeatCoilInTemp;
    2809         4568 :     zsFinalSizing.DesHeatCoilInHumRat = zsCalcFinalSizing.DesHeatCoilInHumRat;
    2810         4568 :     zsFinalSizing.CoolDesHumRat = zsCalcFinalSizing.CoolDesHumRat;
    2811              : 
    2812         4568 :     zsFinalSizing.DesCoolLoad = zsCalcFinalSizing.DesCoolLoad;
    2813         4568 :     zsFinalSizing.NonAirSysDesCoolLoad = zsCalcFinalSizing.DesCoolLoad;
    2814         4568 :     zsFinalSizing.DesCoolMassFlow = zsCalcFinalSizing.DesCoolMassFlow;
    2815         4568 :     zsFinalSizing.ZoneTempAtCoolPeak = zsCalcFinalSizing.ZoneTempAtCoolPeak;
    2816         4568 :     zsFinalSizing.OutTempAtCoolPeak = zsCalcFinalSizing.OutTempAtCoolPeak;
    2817         4568 :     zsFinalSizing.ZoneRetTempAtCoolPeak = zsCalcFinalSizing.ZoneRetTempAtCoolPeak;
    2818         4568 :     zsFinalSizing.ZoneHumRatAtCoolPeak = zsCalcFinalSizing.ZoneHumRatAtCoolPeak;
    2819         4568 :     zsFinalSizing.OutHumRatAtCoolPeak = zsCalcFinalSizing.OutHumRatAtCoolPeak;
    2820         4568 :     zsFinalSizing.TimeStepNumAtCoolMax = zsCalcFinalSizing.TimeStepNumAtCoolMax;
    2821         4568 :     zsFinalSizing.DesCoolVolFlow = zsCalcFinalSizing.DesCoolVolFlow;
    2822         4568 :     zsFinalSizing.NonAirSysDesCoolVolFlow = zsCalcFinalSizing.DesCoolVolFlow; // SpaceSizing TODO: Suspicious
    2823         4568 :     zsFinalSizing.DesCoolCoilInTemp = zsCalcFinalSizing.DesCoolCoilInTemp;
    2824         4568 :     zsFinalSizing.DesCoolCoilInHumRat = zsCalcFinalSizing.DesCoolCoilInHumRat;
    2825         4568 : }
    2826              : 
    2827        12299 : void updateZoneSizingEndZoneSizingCalc6(DataSizing::ZoneSizingData &zsSizing,
    2828              :                                         DataSizing::ZoneSizingData const &zsCalcSizing,
    2829              :                                         int const numTimeStepsInDay)
    2830              : {
    2831              :     // This is called for all zsSizing/zsCalcSizing (2D arrays) and FinalZoneSizing/CalcFinalZoneSizing (1D arrays) for both zones and spaces
    2832      1497083 :     for (int TimeStepIndex = 1; TimeStepIndex <= numTimeStepsInDay; ++TimeStepIndex) {
    2833      1484784 :         zsSizing.HeatFlowSeq(TimeStepIndex) = zsCalcSizing.HeatFlowSeq(TimeStepIndex);
    2834      1484784 :         zsSizing.HeatLoadSeq(TimeStepIndex) = zsCalcSizing.HeatLoadSeq(TimeStepIndex);
    2835      1484784 :         zsSizing.CoolFlowSeq(TimeStepIndex) = zsCalcSizing.CoolFlowSeq(TimeStepIndex);
    2836      1484784 :         zsSizing.CoolLoadSeq(TimeStepIndex) = zsCalcSizing.CoolLoadSeq(TimeStepIndex);
    2837      1484784 :         zsSizing.HeatZoneTempSeq(TimeStepIndex) = zsCalcSizing.HeatZoneTempSeq(TimeStepIndex);
    2838      1484784 :         zsSizing.HeatOutTempSeq(TimeStepIndex) = zsCalcSizing.HeatOutTempSeq(TimeStepIndex);
    2839      1484784 :         zsSizing.HeatZoneRetTempSeq(TimeStepIndex) = zsCalcSizing.HeatZoneRetTempSeq(TimeStepIndex);
    2840      1484784 :         zsSizing.HeatZoneHumRatSeq(TimeStepIndex) = zsCalcSizing.HeatZoneHumRatSeq(TimeStepIndex);
    2841      1484784 :         zsSizing.HeatOutHumRatSeq(TimeStepIndex) = zsCalcSizing.HeatOutHumRatSeq(TimeStepIndex);
    2842      1484784 :         zsSizing.CoolZoneTempSeq(TimeStepIndex) = zsCalcSizing.CoolZoneTempSeq(TimeStepIndex);
    2843      1484784 :         zsSizing.CoolOutTempSeq(TimeStepIndex) = zsCalcSizing.CoolOutTempSeq(TimeStepIndex);
    2844      1484784 :         zsSizing.CoolZoneRetTempSeq(TimeStepIndex) = zsCalcSizing.CoolZoneRetTempSeq(TimeStepIndex);
    2845      1484784 :         zsSizing.CoolZoneHumRatSeq(TimeStepIndex) = zsCalcSizing.CoolZoneHumRatSeq(TimeStepIndex);
    2846      1484784 :         zsSizing.CoolOutHumRatSeq(TimeStepIndex) = zsCalcSizing.CoolOutHumRatSeq(TimeStepIndex);
    2847              :     }
    2848        12299 : }
    2849              : 
    2850         3883 : void updateZoneSizingEndZoneSizingCalc7(EnergyPlusData &state,
    2851              :                                         DataSizing::ZoneSizingData &zsFinalSizing,
    2852              :                                         DataSizing::ZoneSizingData &zsCalcFinalSizing,
    2853              :                                         Array2D<DataSizing::ZoneSizingData> &zsSizing,
    2854              :                                         Array2D<DataSizing::ZoneSizingData> &zsCalcSizing,
    2855              :                                         int const zoneOrSpaceNum)
    2856              : {
    2857              :     static constexpr std::string_view RoutineName("updateZoneSizingEndZoneSizingCalc7");
    2858              :     // update non air system design load and air flow to include the sizing factor
    2859         3883 :     zsFinalSizing.NonAirSysDesCoolLoad *= zsFinalSizing.CoolSizingFactor;
    2860         3883 :     zsFinalSizing.NonAirSysDesCoolVolFlow *= zsFinalSizing.CoolSizingFactor; // NonAirSysDesCoolVolFlow not currently used
    2861              :     // Now take into account the user specified sizing factor and user specified cooling design air flow rate
    2862         3883 :     Real64 TotCoolSizMult = 0.0;
    2863              :     // Calculate a sizing factor from the user specified cooling design air flow rate
    2864         3883 :     if (zsFinalSizing.InpDesCoolAirFlow > 0.0 && zsFinalSizing.CoolAirDesMethod == AirflowSizingMethod::InpDesAirFlow &&
    2865            4 :         zsFinalSizing.DesCoolVolFlow > 0.0) {
    2866            4 :         TotCoolSizMult = (zsFinalSizing.InpDesCoolAirFlow / zsFinalSizing.DesCoolVolFlow) * zsFinalSizing.CoolSizingFactor;
    2867              :         // If no user specified cooling design air flow rate input, use the user specified szing factor
    2868              :     } else {
    2869         3879 :         TotCoolSizMult = zsFinalSizing.CoolSizingFactor;
    2870              :     }
    2871              :     // If the cooling sizing multiplier is not 1, adjust the cooling design data
    2872         3883 :     if (std::abs(TotCoolSizMult - 1.0) > 0.00001) {
    2873         2514 :         if (zsFinalSizing.DesCoolVolFlow > 0.0) {
    2874         2435 :             int TimeStepAtPeak = zsFinalSizing.TimeStepNumAtCoolMax;
    2875         2435 :             int DDNum = zsFinalSizing.CoolDDNum;
    2876         2435 :             zsFinalSizing.DesCoolVolFlow = zsCalcFinalSizing.DesCoolVolFlow * TotCoolSizMult;
    2877         2435 :             zsFinalSizing.DesCoolMassFlow = zsCalcFinalSizing.DesCoolMassFlow * TotCoolSizMult;
    2878         2435 :             zsFinalSizing.DesCoolLoad = zsCalcFinalSizing.DesCoolLoad * TotCoolSizMult;
    2879       304883 :             for (int i = 0; i < (int)zsFinalSizing.CoolFlowSeq.size(); ++i) {
    2880       302448 :                 zsFinalSizing.CoolFlowSeq[i] = zsCalcFinalSizing.CoolFlowSeq[i] * TotCoolSizMult;
    2881       302448 :                 zsFinalSizing.CoolLoadSeq[i] = zsCalcFinalSizing.CoolLoadSeq[i] * TotCoolSizMult;
    2882              :             }
    2883         2435 :             Real64 OAFrac = zsFinalSizing.MinOA / zsFinalSizing.DesCoolVolFlow;
    2884         2435 :             OAFrac = min(1.0, max(0.0, OAFrac));
    2885         2435 :             zsFinalSizing.DesCoolCoilInTemp =
    2886         2435 :                 OAFrac * state.dataSize->DesDayWeath(DDNum).Temp(TimeStepAtPeak) + (1.0 - OAFrac) * zsFinalSizing.ZoneTempAtCoolPeak;
    2887         2435 :             zsFinalSizing.DesCoolCoilInHumRat =
    2888         2435 :                 OAFrac * state.dataSize->DesDayWeath(DDNum).HumRat(TimeStepAtPeak) + (1.0 - OAFrac) * zsFinalSizing.ZoneHumRatAtCoolPeak;
    2889              :         } else {
    2890           79 :             zsFinalSizing.DesCoolVolFlow = zsFinalSizing.InpDesCoolAirFlow;
    2891           79 :             zsFinalSizing.DesCoolMassFlow = zsFinalSizing.DesCoolVolFlow * zsFinalSizing.DesCoolDens;
    2892              :         }
    2893         7718 :         for (int DDNum = 1; DDNum <= state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays; ++DDNum) {
    2894         5204 :             auto &zoneSizing = zsSizing(DDNum, zoneOrSpaceNum);
    2895         5204 :             if (zoneSizing.DesCoolVolFlow > 0.0) {
    2896         2689 :                 int TimeStepAtPeak = zoneSizing.TimeStepNumAtCoolMax;
    2897         2689 :                 auto &calcZoneSizing = zsCalcSizing(DDNum, zoneOrSpaceNum);
    2898         2689 :                 auto &desDayWeath = state.dataSize->DesDayWeath(DDNum);
    2899         2689 :                 zoneSizing.DesCoolVolFlow = calcZoneSizing.DesCoolVolFlow * TotCoolSizMult;
    2900         2689 :                 zoneSizing.DesCoolMassFlow = calcZoneSizing.DesCoolMassFlow * TotCoolSizMult;
    2901         2689 :                 zoneSizing.DesCoolLoad = calcZoneSizing.DesCoolLoad * TotCoolSizMult;
    2902       338833 :                 for (int i = 0; i < (int)zoneSizing.CoolFlowSeq.size(); ++i) {
    2903       336144 :                     zoneSizing.CoolFlowSeq[i] = calcZoneSizing.CoolFlowSeq[i] * TotCoolSizMult;
    2904       336144 :                     zoneSizing.CoolLoadSeq[i] = calcZoneSizing.CoolLoadSeq[i] * TotCoolSizMult;
    2905              :                 }
    2906         2689 :                 Real64 OAFrac = zoneSizing.MinOA / zoneSizing.DesCoolVolFlow;
    2907         2689 :                 OAFrac = min(1.0, max(0.0, OAFrac));
    2908         2689 :                 zoneSizing.DesCoolCoilInTemp = OAFrac * desDayWeath.Temp(TimeStepAtPeak) + (1.0 - OAFrac) * zoneSizing.ZoneTempAtCoolPeak;
    2909         2689 :                 zoneSizing.DesCoolCoilInHumRat = OAFrac * desDayWeath.HumRat(TimeStepAtPeak) + (1.0 - OAFrac) * zoneSizing.ZoneHumRatAtCoolPeak;
    2910              :             } else {
    2911         2515 :                 zoneSizing.DesCoolVolFlow = zoneSizing.InpDesCoolAirFlow;
    2912         2515 :                 zoneSizing.DesCoolMassFlow = zoneSizing.DesCoolVolFlow * zoneSizing.DesCoolDens;
    2913              :             }
    2914              :             // Save cooling flows without MinOA for use later
    2915         5204 :             zoneSizing.CoolFlowSeqNoOA = zoneSizing.CoolFlowSeq;
    2916         5204 :             zoneSizing.DesCoolVolFlowNoOA = zoneSizing.DesCoolVolFlow;
    2917         5204 :             zoneSizing.DesCoolMassFlowNoOA = zoneSizing.DesCoolMassFlow;
    2918              :         }
    2919              :     } else {
    2920         4581 :         for (int DDNum = 1; DDNum <= state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays; ++DDNum) {
    2921              :             // initialize HeatFlowSeqNoOA before any adjustments to HeatFlowSeq
    2922         3212 :             auto &zoneSizing = zsSizing(DDNum, zoneOrSpaceNum);
    2923         3212 :             zoneSizing.CoolFlowSeqNoOA = zoneSizing.CoolFlowSeq;
    2924         3212 :             zoneSizing.DesCoolVolFlowNoOA = zoneSizing.DesCoolVolFlow;
    2925         3212 :             zoneSizing.DesCoolMassFlowNoOA = zoneSizing.DesCoolMassFlow;
    2926              :         }
    2927              :     }
    2928              :     // Save a set of design cooling air flow rates greater than or equal to the specified minimums without MinOA
    2929              :     {
    2930         3883 :         Real64 MaxOfMinCoolVolFlowNoOA = 0.0; // max of the user specified design cooling minimum flows without min OA flow [m3/s]
    2931         3883 :         if (zsFinalSizing.CoolAirDesMethod == AirflowSizingMethod::DesAirFlowWithLim) {
    2932         1197 :             MaxOfMinCoolVolFlowNoOA = max(zsFinalSizing.DesCoolMinAirFlow, zsFinalSizing.DesCoolMinAirFlow2);
    2933              :         }
    2934         3883 :         Real64 MaxOfMinCoolMassFlowNoOA =
    2935         3883 :             MaxOfMinCoolVolFlowNoOA * zsFinalSizing.DesCoolDens; // max of the user specified design cooling minimum flows without min OA flow [m3/s]
    2936         3883 :         zsFinalSizing.DesCoolVolFlowNoOA = zsFinalSizing.DesCoolVolFlow;
    2937         3883 :         zsFinalSizing.DesCoolMassFlowNoOA = zsFinalSizing.DesCoolMassFlow;
    2938         3883 :         if (MaxOfMinCoolVolFlowNoOA > zsFinalSizing.DesCoolVolFlowNoOA) {
    2939          264 :             zsFinalSizing.DesCoolVolFlowNoOA = MaxOfMinCoolVolFlowNoOA;
    2940          264 :             zsFinalSizing.DesCoolMassFlowNoOA = MaxOfMinCoolMassFlowNoOA;
    2941              :         }
    2942       470011 :         for (int TimeStepIndex = 1; TimeStepIndex <= state.dataZoneEquipmentManager->NumOfTimeStepInDay; ++TimeStepIndex) {
    2943       466128 :             zsFinalSizing.CoolFlowSeqNoOA(TimeStepIndex) = zsFinalSizing.CoolFlowSeq(TimeStepIndex);
    2944       466128 :             if (MaxOfMinCoolMassFlowNoOA > zsFinalSizing.CoolFlowSeqNoOA(TimeStepIndex)) {
    2945        73386 :                 zsFinalSizing.CoolFlowSeqNoOA(TimeStepIndex) = MaxOfMinCoolMassFlowNoOA;
    2946              :             }
    2947              :         }
    2948        12299 :         for (int DDNum = 1; DDNum <= state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays; ++DDNum) {
    2949         8416 :             auto &zoneSizing = zsSizing(DDNum, zoneOrSpaceNum);
    2950         8416 :             zoneSizing.DesCoolVolFlowNoOA = zoneSizing.DesCoolVolFlow;
    2951         8416 :             zoneSizing.DesCoolMassFlowNoOA = zoneSizing.DesCoolMassFlow;
    2952         8416 :             MaxOfMinCoolVolFlowNoOA = max(zoneSizing.DesCoolMinAirFlow, zoneSizing.DesCoolMinAirFlow);
    2953         8416 :             MaxOfMinCoolMassFlowNoOA = MaxOfMinCoolVolFlowNoOA * zoneSizing.DesCoolDens;
    2954         8416 :             if (MaxOfMinCoolVolFlowNoOA > zoneSizing.DesCoolVolFlow) {
    2955          833 :                 zoneSizing.DesCoolVolFlowNoOA = MaxOfMinCoolVolFlowNoOA;
    2956          833 :                 zoneSizing.DesCoolMassFlowNoOA = MaxOfMinCoolMassFlowNoOA;
    2957              :             }
    2958      1027072 :             for (int TimeStepIndex = 1; TimeStepIndex <= state.dataZoneEquipmentManager->NumOfTimeStepInDay; ++TimeStepIndex) {
    2959      1018656 :                 if (MaxOfMinCoolMassFlowNoOA > zoneSizing.CoolFlowSeq(TimeStepIndex)) {
    2960       126240 :                     zoneSizing.CoolFlowSeqNoOA(TimeStepIndex) = MaxOfMinCoolMassFlowNoOA;
    2961              :                 }
    2962              :             }
    2963              :         }
    2964              :     }
    2965              : 
    2966              :     // Now make sure that the design cooling air flow rates are greater than or equal to the specified minimums including MinOA
    2967              :     {
    2968         3883 :         Real64 MaxOfMinCoolVolFlow = 0.0; // max of the user specified design cooling minimum flows and min OA flow [m3/s]
    2969         3883 :         if (zsFinalSizing.CoolAirDesMethod == AirflowSizingMethod::DesAirFlowWithLim) {
    2970         1197 :             MaxOfMinCoolVolFlow = max(zsFinalSizing.DesCoolMinAirFlow, zsFinalSizing.DesCoolMinAirFlow2, zsFinalSizing.MinOA);
    2971              :         } else {
    2972         2686 :             MaxOfMinCoolVolFlow = zsFinalSizing.MinOA;
    2973              :         }
    2974         3883 :         Real64 MaxOfMinCoolMassFlow =
    2975         3883 :             MaxOfMinCoolVolFlow * zsFinalSizing.DesCoolDens; // max of the user specified design cooling minimum flows and min OA flow [kg/s]
    2976         3883 :         if (MaxOfMinCoolVolFlow > zsFinalSizing.DesCoolVolFlow) {
    2977          370 :             zsFinalSizing.DesCoolVolFlow = MaxOfMinCoolVolFlow;
    2978          370 :             zsFinalSizing.DesCoolMassFlow = MaxOfMinCoolMassFlow;
    2979              :         }
    2980       470011 :         for (int TimeStepIndex = 1; TimeStepIndex <= state.dataZoneEquipmentManager->NumOfTimeStepInDay; ++TimeStepIndex) {
    2981       466128 :             if (MaxOfMinCoolMassFlow > zsFinalSizing.CoolFlowSeq(TimeStepIndex)) {
    2982       172739 :                 zsFinalSizing.CoolFlowSeq(TimeStepIndex) = MaxOfMinCoolMassFlow;
    2983              :             }
    2984              :         }
    2985        12299 :         for (int DDNum = 1; DDNum <= state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays; ++DDNum) {
    2986         8416 :             auto &zoneSizing = zsSizing(DDNum, zoneOrSpaceNum);
    2987         8416 :             MaxOfMinCoolVolFlow = max(zoneSizing.DesCoolMinAirFlow, zoneSizing.DesCoolMinAirFlow, zoneSizing.MinOA);
    2988         8416 :             MaxOfMinCoolMassFlow = MaxOfMinCoolVolFlow * zoneSizing.DesCoolDens;
    2989         8416 :             if (MaxOfMinCoolVolFlow > zoneSizing.DesCoolVolFlow) {
    2990         4234 :                 zoneSizing.DesCoolVolFlow = MaxOfMinCoolVolFlow;
    2991         4234 :                 zoneSizing.DesCoolMassFlow = MaxOfMinCoolMassFlow;
    2992              :             }
    2993      1027072 :             for (int TimeStepIndex = 1; TimeStepIndex <= state.dataZoneEquipmentManager->NumOfTimeStepInDay; ++TimeStepIndex) {
    2994      1018656 :                 if (MaxOfMinCoolMassFlow > zoneSizing.CoolFlowSeq(TimeStepIndex)) {
    2995       656905 :                     zoneSizing.CoolFlowSeq(TimeStepIndex) = MaxOfMinCoolMassFlow;
    2996              :                 }
    2997              :             }
    2998              :         }
    2999              :     }
    3000              :     // IF cooling flow rate is 0, this data may be used to size a HP so initialize DDNum, TimeStepatPeak, and sizing data (end of IF)
    3001         3883 :     if (zsFinalSizing.DesCoolLoad == 0) {
    3002              :         // Check CoolDDNum and TimeStepNumAtCoolMax value and default to 1 if not set, carried over from previous code
    3003           82 :         if (zsCalcFinalSizing.CoolDDNum == 0) {
    3004            0 :             zsCalcFinalSizing.CoolDDNum = 1;
    3005              :         }
    3006           82 :         if (zsCalcFinalSizing.TimeStepNumAtCoolMax == 0) {
    3007            0 :             zsCalcFinalSizing.TimeStepNumAtCoolMax = 1;
    3008              :         }
    3009           82 :         zsFinalSizing.TimeStepNumAtCoolMax = zsCalcFinalSizing.TimeStepNumAtCoolMax;
    3010           82 :         zsFinalSizing.CoolDDNum = zsCalcFinalSizing.CoolDDNum;
    3011           82 :         zsFinalSizing.CoolDesDay = zsCalcFinalSizing.CoolDesDay;
    3012           82 :         int DDNumF = zsFinalSizing.CoolDDNum;
    3013           82 :         auto &zoneSizingF = zsSizing(DDNumF, zoneOrSpaceNum);
    3014           82 :         int TimeStepAtPeakF = zsFinalSizing.TimeStepNumAtCoolMax;
    3015              : 
    3016              :         // initialize sizing conditions if they have not been set (i.e., no corresponding load) to zone condition
    3017              :         // issue 6006, heating coils sizing to 0 when no heating load in zone
    3018           82 :         if (zoneSizingF.DesCoolSetPtSeq.empty()) {
    3019            0 :             ShowSevereError(
    3020              :                 state,
    3021            0 :                 format("{}:  Thermostat cooling set point temperatures are not initialized for Zone = {}", RoutineName, zsFinalSizing.ZoneName));
    3022            0 :             ShowFatalError(state, "Please send your input file to the EnergyPlus support/development team for further investigation.");
    3023              :         } else {
    3024           82 :             zsFinalSizing.ZoneTempAtCoolPeak = *std::min_element(zoneSizingF.DesCoolSetPtSeq.begin(), zoneSizingF.DesCoolSetPtSeq.end());
    3025              :         }
    3026           82 :         zsFinalSizing.OutTempAtCoolPeak = *std::min_element(zoneSizingF.CoolOutTempSeq.begin(), zoneSizingF.CoolOutTempSeq.end());
    3027           82 :         zsFinalSizing.OutHumRatAtCoolPeak = zoneSizingF.CoolOutHumRatSeq(TimeStepAtPeakF);
    3028           82 :         zsFinalSizing.ZoneHumRatAtCoolPeak = zoneSizingF.CoolDesHumRat;
    3029           82 :         zsCalcFinalSizing.ZoneTempAtCoolPeak = zoneSizingF.CoolZoneTempSeq(TimeStepAtPeakF);
    3030           82 :         zsCalcFinalSizing.ZoneHumRatAtCoolPeak = zoneSizingF.CoolZoneHumRatSeq(TimeStepAtPeakF);
    3031           82 :         zsCalcFinalSizing.ZoneRetTempAtCoolPeak = zsCalcFinalSizing.ZoneTempAtCoolPeak;
    3032           82 :         zsFinalSizing.DesCoolCoilInTemp = zsFinalSizing.ZoneTempAtCoolPeak;
    3033           82 :         zsFinalSizing.DesCoolCoilInHumRat = zsFinalSizing.ZoneHumRatAtCoolPeak;
    3034           82 :         zsFinalSizing.ZoneRetTempAtCoolPeak = zsFinalSizing.ZoneTempAtCoolPeak;
    3035              :     }
    3036              :     // update non air system design load and air flow to include the sizing factor
    3037         3883 :     zsFinalSizing.NonAirSysDesHeatLoad *= zsFinalSizing.HeatSizingFactor;
    3038         3883 :     zsFinalSizing.NonAirSysDesHeatVolFlow *= zsFinalSizing.HeatSizingFactor;
    3039              :     // Now take into account the user specified sizing factor or user specified heating design air flow rate (which overrides the
    3040              :     // sizing factor)
    3041         3883 :     Real64 TotHeatSizMult = 0.0;
    3042              :     // Calculate a sizing factor from the user specified heating design air flow rate
    3043         3883 :     if (zsFinalSizing.InpDesHeatAirFlow > 0.0 && zsFinalSizing.HeatAirDesMethod == AirflowSizingMethod::InpDesAirFlow &&
    3044            0 :         zsFinalSizing.DesHeatVolFlow > 0.0) {
    3045            0 :         TotHeatSizMult = (zsFinalSizing.InpDesHeatAirFlow / zsFinalSizing.DesHeatVolFlow) * zsFinalSizing.HeatSizingFactor;
    3046              :         // Calculate a sizing factor from the user specified max heating design air flow rates
    3047         3883 :     } else if (zsFinalSizing.HeatAirDesMethod == AirflowSizingMethod::DesAirFlowWithLim && zsFinalSizing.DesHeatVolFlow > 0.0) {
    3048            0 :         Real64 MaxHeatVolFlow = max(
    3049            0 :             zsFinalSizing.DesHeatMaxAirFlow, zsFinalSizing.DesHeatMaxAirFlow2, zsFinalSizing.DesCoolVolFlow * zsFinalSizing.DesHeatMaxAirFlowFrac);
    3050            0 :         if (MaxHeatVolFlow < zsFinalSizing.DesHeatVolFlow) {
    3051            0 :             TotHeatSizMult = (MaxHeatVolFlow / zsFinalSizing.DesHeatVolFlow) * zsFinalSizing.HeatSizingFactor;
    3052              :         } else {
    3053            0 :             TotHeatSizMult = zsFinalSizing.HeatSizingFactor;
    3054              :         }
    3055              :         // If no user specified heating design air flow rate input, use the user specified sizing factor
    3056            0 :     } else {
    3057         3883 :         TotHeatSizMult = zsFinalSizing.HeatSizingFactor;
    3058              :     }
    3059              : 
    3060         3883 :     if (std::abs(TotHeatSizMult - 1.0) > 0.00001) {
    3061         2521 :         if (zsFinalSizing.DesHeatVolFlow > 0.0) {
    3062         2453 :             auto &desDayWeath = state.dataSize->DesDayWeath(zsFinalSizing.HeatDDNum);
    3063         2453 :             zsFinalSizing.DesHeatVolFlow = zsCalcFinalSizing.DesHeatVolFlow * TotHeatSizMult;
    3064         2453 :             zsFinalSizing.DesHeatMassFlow = zsCalcFinalSizing.DesHeatMassFlow * TotHeatSizMult;
    3065         2453 :             zsFinalSizing.DesHeatLoad = zsCalcFinalSizing.DesHeatLoad * TotHeatSizMult;
    3066       306485 :             for (int i = 0; i < (int)zsFinalSizing.HeatFlowSeq.size(); ++i) {
    3067       304032 :                 zsFinalSizing.HeatFlowSeq[i] = zsCalcFinalSizing.HeatFlowSeq[i] * TotHeatSizMult;
    3068       304032 :                 zsFinalSizing.HeatLoadSeq[i] = zsCalcFinalSizing.HeatLoadSeq[i] * TotHeatSizMult;
    3069              :             }
    3070         2453 :             Real64 OAFrac = zsFinalSizing.MinOA / zsFinalSizing.DesHeatVolFlow;
    3071         2453 :             OAFrac = min(1.0, max(0.0, OAFrac));
    3072         2453 :             zsFinalSizing.DesHeatCoilInTemp =
    3073         2453 :                 OAFrac * desDayWeath.Temp(zsFinalSizing.TimeStepNumAtHeatMax) + (1.0 - OAFrac) * zsFinalSizing.ZoneTempAtHeatPeak;
    3074         2453 :             zsFinalSizing.DesHeatCoilInHumRat =
    3075         2453 :                 OAFrac * desDayWeath.HumRat(zsFinalSizing.TimeStepNumAtHeatMax) + (1.0 - OAFrac) * zsFinalSizing.ZoneHumRatAtHeatPeak;
    3076              :         } else {
    3077           68 :             zsFinalSizing.DesHeatVolFlow = zsFinalSizing.InpDesHeatAirFlow;
    3078           68 :             zsFinalSizing.DesHeatMassFlow = zsFinalSizing.DesHeatVolFlow * zsFinalSizing.DesHeatDens;
    3079              :         }
    3080         7739 :         for (int DDNum = 1; DDNum <= state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays; ++DDNum) {
    3081         5218 :             auto &zoneSizingDD = zsSizing(DDNum, zoneOrSpaceNum);
    3082         5218 :             if (zoneSizingDD.DesHeatVolFlow > 0.0) {
    3083         2532 :                 auto &calcZoneSizing = zsCalcSizing(DDNum, zoneOrSpaceNum);
    3084         2532 :                 int TimeStepAtPeak = zoneSizingDD.TimeStepNumAtHeatMax;
    3085         2532 :                 zoneSizingDD.DesHeatVolFlow = calcZoneSizing.DesHeatVolFlow * TotHeatSizMult;
    3086         2532 :                 zoneSizingDD.DesHeatMassFlow = calcZoneSizing.DesHeatMassFlow * TotHeatSizMult;
    3087         2532 :                 zoneSizingDD.DesHeatLoad = calcZoneSizing.DesHeatLoad * TotHeatSizMult;
    3088       315156 :                 for (int i = 0; i < (int)zoneSizingDD.HeatFlowSeq.size(); ++i) {
    3089       312624 :                     zoneSizingDD.HeatFlowSeq[i] = calcZoneSizing.HeatFlowSeq[i] * TotHeatSizMult;
    3090       312624 :                     zoneSizingDD.HeatLoadSeq[i] = calcZoneSizing.HeatLoadSeq[i] * TotHeatSizMult;
    3091              :                 }
    3092         2532 :                 Real64 OAFrac = zoneSizingDD.MinOA / zoneSizingDD.DesHeatVolFlow;
    3093         2532 :                 OAFrac = min(1.0, max(0.0, OAFrac));
    3094         2532 :                 zoneSizingDD.DesHeatCoilInTemp =
    3095         2532 :                     OAFrac * state.dataSize->DesDayWeath(DDNum).Temp(TimeStepAtPeak) + (1.0 - OAFrac) * zoneSizingDD.ZoneTempAtHeatPeak;
    3096         2532 :                 zoneSizingDD.DesHeatCoilInHumRat =
    3097         2532 :                     OAFrac * state.dataSize->DesDayWeath(DDNum).HumRat(TimeStepAtPeak) + (1.0 - OAFrac) * zoneSizingDD.ZoneHumRatAtHeatPeak;
    3098              :             } else {
    3099         2686 :                 zoneSizingDD.DesHeatVolFlow = zoneSizingDD.InpDesHeatAirFlow;
    3100         2686 :                 zoneSizingDD.DesHeatMassFlow = zoneSizingDD.DesHeatVolFlow * zoneSizingDD.DesHeatDens;
    3101              :             }
    3102              :             // Save heating flows without MinOA for use later
    3103         5218 :             zoneSizingDD.HeatFlowSeqNoOA = zoneSizingDD.HeatFlowSeq;
    3104         5218 :             zoneSizingDD.DesHeatVolFlowNoOA = zoneSizingDD.DesHeatVolFlow;
    3105         5218 :             zoneSizingDD.DesHeatMassFlowNoOA = zoneSizingDD.DesHeatMassFlow;
    3106              :         }
    3107              :     } else {
    3108         4560 :         for (int DDNum = 1; DDNum <= state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays; ++DDNum) {
    3109              :             // initialize HeatFlowSeqNoOA before any adjustments to HeatFlowSeq
    3110         3198 :             auto &zoneSizing = zsSizing(DDNum, zoneOrSpaceNum);
    3111         3198 :             zoneSizing.HeatFlowSeqNoOA = zoneSizing.HeatFlowSeq;
    3112         3198 :             zoneSizing.DesHeatVolFlowNoOA = zoneSizing.DesHeatVolFlow;
    3113         3198 :             zoneSizing.DesHeatMassFlowNoOA = zoneSizing.DesHeatMassFlow;
    3114              :         }
    3115              :     }
    3116              : 
    3117              :     // Save a set of design heating air flow rates before the MinOA adjustment
    3118              :     // just in zsFinalSizing to use for TermUnit sizing adjustments in SizingManager::UpdateTermUnitFinalZoneSizing
    3119         3883 :     zsFinalSizing.DesHeatVolFlowNoOA = zsFinalSizing.DesHeatVolFlow;
    3120         3883 :     zsFinalSizing.DesHeatMassFlowNoOA = zsFinalSizing.DesHeatMassFlow;
    3121       470011 :     for (int TimeStepIndex = 1; TimeStepIndex <= state.dataZoneEquipmentManager->NumOfTimeStepInDay; ++TimeStepIndex) {
    3122       466128 :         zsFinalSizing.HeatFlowSeqNoOA(TimeStepIndex) = zsFinalSizing.HeatFlowSeq(TimeStepIndex);
    3123              :     }
    3124              : 
    3125              :     // Now make sure that the design heating air flow rates are greater than or equal to MinOA
    3126         3883 :     Real64 MinOAMass = zsFinalSizing.MinOA * zsFinalSizing.DesHeatDens;
    3127         3883 :     if (zsFinalSizing.MinOA > zsFinalSizing.DesHeatVolFlow) {
    3128         1217 :         zsFinalSizing.DesHeatVolFlow = zsFinalSizing.MinOA;
    3129         1217 :         zsFinalSizing.DesHeatMassFlow = MinOAMass;
    3130              :     }
    3131       470011 :     for (int TimeStepIndex = 1; TimeStepIndex <= state.dataZoneEquipmentManager->NumOfTimeStepInDay; ++TimeStepIndex) {
    3132       466128 :         if (MinOAMass > zsFinalSizing.HeatFlowSeq(TimeStepIndex)) {
    3133       155470 :             zsFinalSizing.HeatFlowSeq(TimeStepIndex) = MinOAMass;
    3134              :         }
    3135              :     }
    3136        12299 :     for (int DDNum = 1; DDNum <= state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays; ++DDNum) {
    3137         8416 :         auto &zoneSizingDD = zsSizing(DDNum, zoneOrSpaceNum);
    3138         8416 :         MinOAMass = zoneSizingDD.MinOA * zoneSizingDD.DesHeatDens;
    3139         8416 :         if (zoneSizingDD.MinOA > zoneSizingDD.DesHeatVolFlow) {
    3140         5505 :             zoneSizingDD.DesHeatVolFlow = zoneSizingDD.MinOA;
    3141         5505 :             zoneSizingDD.DesHeatMassFlow = MinOAMass;
    3142              :         }
    3143      1027072 :         for (int TimeStepIndex = 1; TimeStepIndex <= state.dataZoneEquipmentManager->NumOfTimeStepInDay; ++TimeStepIndex) {
    3144      1018656 :             if (MinOAMass > zoneSizingDD.HeatFlowSeq(TimeStepIndex)) {
    3145       680435 :                 zoneSizingDD.HeatFlowSeq(TimeStepIndex) = MinOAMass;
    3146              :             }
    3147              :         }
    3148              :     }
    3149              :     // IF heating flow rate is 0, this data may be used to size a HP so initialize DDNum, TimeStepatPeak, and sizing data
    3150         3883 :     if (zsFinalSizing.DesHeatLoad == 0) {
    3151              :         // Check HDDNum and TimeStepNumAtHeatMax value and default to 1 if not set, carried over from previous code
    3152          202 :         if (zsCalcFinalSizing.HeatDDNum == 0) {
    3153            4 :             zsCalcFinalSizing.HeatDDNum = 1;
    3154              :         }
    3155          202 :         if (zsCalcFinalSizing.TimeStepNumAtHeatMax == 0) {
    3156            0 :             zsCalcFinalSizing.TimeStepNumAtHeatMax = 1;
    3157              :         }
    3158          202 :         zsFinalSizing.TimeStepNumAtHeatMax = zsCalcFinalSizing.TimeStepNumAtHeatMax;
    3159          202 :         zsFinalSizing.HeatDDNum = zsCalcFinalSizing.HeatDDNum;
    3160          202 :         zsFinalSizing.HeatDesDay = zsCalcFinalSizing.HeatDesDay;
    3161          202 :         int DDNumF = zsFinalSizing.HeatDDNum;
    3162          202 :         auto &zoneSizingDDF = zsSizing(DDNumF, zoneOrSpaceNum);
    3163          202 :         int TimeStepAtPeakF = zsFinalSizing.TimeStepNumAtHeatMax;
    3164              : 
    3165              :         // initialize sizing conditions if they have not been set (i.e., no corresponding load) to zone condition
    3166              :         // issue 6006, heating coils sizing to 0 when no heating load in zone
    3167          202 :         if (zoneSizingDDF.DesHeatSetPtSeq.empty()) {
    3168            0 :             ShowSevereError(
    3169            0 :                 state, format("{}:  Thermostat heating set point temperatures not initialized for Zone = {}", RoutineName, zsFinalSizing.ZoneName));
    3170            0 :             ShowFatalError(state, "Please send your input file to the EnergyPlus support/development team for further investigation.");
    3171              :         } else {
    3172          202 :             zsFinalSizing.ZoneTempAtHeatPeak = *std::max_element(zoneSizingDDF.DesHeatSetPtSeq.begin(), zoneSizingDDF.DesHeatSetPtSeq.end());
    3173              :         }
    3174          202 :         zsFinalSizing.OutTempAtHeatPeak = *std::min_element(zoneSizingDDF.HeatOutTempSeq.begin(), zoneSizingDDF.HeatOutTempSeq.end());
    3175          202 :         zsFinalSizing.OutHumRatAtHeatPeak = zoneSizingDDF.HeatOutHumRatSeq(TimeStepAtPeakF);
    3176          202 :         zsFinalSizing.ZoneHumRatAtHeatPeak = zoneSizingDDF.HeatDesHumRat;
    3177          202 :         zsCalcFinalSizing.ZoneTempAtHeatPeak = zoneSizingDDF.HeatZoneTempSeq(TimeStepAtPeakF);
    3178          202 :         zsCalcFinalSizing.ZoneHumRatAtHeatPeak = zoneSizingDDF.HeatZoneHumRatSeq(TimeStepAtPeakF);
    3179          202 :         zsCalcFinalSizing.ZoneRetTempAtHeatPeak = zsCalcFinalSizing.ZoneTempAtHeatPeak;
    3180          202 :         zsFinalSizing.DesHeatCoilInTemp = zsFinalSizing.ZoneTempAtHeatPeak;
    3181          202 :         zsFinalSizing.DesHeatCoilInHumRat = zsFinalSizing.ZoneHumRatAtHeatPeak;
    3182          202 :         zsFinalSizing.ZoneRetTempAtHeatPeak = zsFinalSizing.ZoneTempAtHeatPeak;
    3183              :     }
    3184              : 
    3185              :     // set the zone minimum cooling supply air flow rate. This will be used for autosizing VAV terminal unit
    3186              :     // minimum flow rates (comment seems incorrect, really used as a minimum lower limit for the maximum air flow)
    3187         3883 :     zsFinalSizing.DesCoolVolFlowMin =
    3188         3883 :         max(zsFinalSizing.DesCoolMinAirFlow, zsFinalSizing.DesCoolMinAirFlow2, zsFinalSizing.DesCoolVolFlow * zsFinalSizing.DesCoolMinAirFlowFrac);
    3189              :     // set the zone maximum heating supply air flow rate. This will be used for autosizing VAV terminal unit
    3190              :     // max heating flow rates
    3191         7766 :     zsFinalSizing.DesHeatVolFlowMax = max(zsFinalSizing.DesHeatMaxAirFlow,
    3192              :                                           zsFinalSizing.DesHeatMaxAirFlow2,
    3193         3883 :                                           max(zsFinalSizing.DesCoolVolFlow, zsFinalSizing.DesHeatVolFlow) * zsFinalSizing.DesHeatMaxAirFlowFrac);
    3194              :     // Determine the design cooling supply air temperature if the supply air temperature difference is specified by user.
    3195         3883 :     if (zsFinalSizing.ZnCoolDgnSAMethod == TemperatureDifference) {
    3196          110 :         zsFinalSizing.CoolDesTemp = zsFinalSizing.ZoneTempAtCoolPeak - std::abs(zsFinalSizing.CoolDesTempDiff);
    3197              :     }
    3198              :     // Determine the design heating supply air temperature if the supply air temperature difference is specified by user.
    3199         3883 :     if (zsFinalSizing.ZnHeatDgnSAMethod == TemperatureDifference) {
    3200          110 :         zsFinalSizing.HeatDesTemp = zsFinalSizing.ZoneTempAtHeatPeak + std::abs(zsFinalSizing.HeatDesTempDiff);
    3201              :     }
    3202         3883 : }
    3203              : 
    3204       142240 : void UpdateZoneSizing(EnergyPlusData &state, Constant::CallIndicator const CallIndicator)
    3205              : {
    3206              : 
    3207              :     // SUBROUTINE INFORMATION:
    3208              :     //       AUTHOR         Fred Buhl
    3209              :     //       DATE WRITTEN   December 2000
    3210              : 
    3211              :     // PURPOSE OF THIS SUBROUTINE:
    3212              :     // Update the result variables of the zone sizing calculation
    3213              : 
    3214              :     // METHODOLOGY EMPLOYED:
    3215              :     // CallIndicator = 1 (BeginDay) zero the result arrays
    3216              :     // CallIndicator = 2 (DuringDay) fill arrays, averaging over 1 zone time step
    3217              :     // CallIndicator = 3 (EndDay) calculate daily maxima
    3218              :     // CallIndicator = 4 (EndZoneSizingCalc) write out results
    3219              : 
    3220       142240 :     switch (CallIndicator) {
    3221          973 :     case Constant::CallIndicator::BeginDay: {
    3222        10379 :         for (int CtrlZoneNum = 1; CtrlZoneNum <= state.dataGlobal->NumOfZones; ++CtrlZoneNum) {
    3223              : 
    3224         9406 :             if (!state.dataZoneEquip->ZoneEquipConfig(CtrlZoneNum).IsControlled) {
    3225         1046 :                 continue;
    3226              :             }
    3227              : 
    3228              :             // auto &calcZoneSizing = state.dataSize->CalcZoneSizing(state.dataSize->CurOverallSimDay, CtrlZoneNum);
    3229         8360 :             updateZoneSizingBeginDay(state, state.dataSize->CalcZoneSizing(state.dataSize->CurOverallSimDay, CtrlZoneNum));
    3230         8360 :             if (state.dataHeatBal->doSpaceHeatBalanceSizing) {
    3231           96 :                 for (int spaceNum : state.dataHeatBal->Zone(CtrlZoneNum).spaceIndexes) {
    3232           56 :                     updateZoneSizingBeginDay(state, state.dataSize->CalcSpaceSizing(state.dataSize->CurOverallSimDay, spaceNum));
    3233           40 :                 }
    3234              :             }
    3235              :         }
    3236          973 :     } break;
    3237       138899 :     case Constant::CallIndicator::DuringDay: {
    3238       138899 :         int timeStepInDay = (state.dataGlobal->HourOfDay - 1) * state.dataGlobal->TimeStepsInHour + state.dataGlobal->TimeStep;
    3239       138899 :         Real64 fracTimeStepZone = state.dataHVACGlobal->FracTimeStepZone;
    3240              : 
    3241              :         // save the results of the ideal zone component calculation in the CalcZoneSizing sequence variables
    3242      1472192 :         for (int CtrlZoneNum = 1; CtrlZoneNum <= state.dataGlobal->NumOfZones; ++CtrlZoneNum) {
    3243      1333293 :             if (!state.dataZoneEquip->ZoneEquipConfig(CtrlZoneNum).IsControlled) {
    3244       151559 :                 continue;
    3245              :             }
    3246              : 
    3247      1181734 :             auto const &zoneTstatSetpt = state.dataHeatBalFanSys->zoneTstatSetpts(CtrlZoneNum);
    3248              :             // auto &zoneSizing = state.dataSize->ZoneSizing(state.dataSize->CurOverallSimDay, CtrlZoneNum);
    3249              :             // auto &calcZoneSizing = state.dataSize->CalcZoneSizing(state.dataSize->CurOverallSimDay, CtrlZoneNum);
    3250              :             // auto const &zoneThermostatHi = state.dataHeatBalFanSys->ZoneThermostatSetPointHi(CtrlZoneNum);
    3251              :             // auto const &zoneThermostatLo = state.dataHeatBalFanSys->ZoneThermostatSetPointLo(CtrlZoneNum);
    3252      1181734 :             updateZoneSizingDuringDay(state.dataSize->ZoneSizing(state.dataSize->CurOverallSimDay, CtrlZoneNum),
    3253      1181734 :                                       state.dataSize->CalcZoneSizing(state.dataSize->CurOverallSimDay, CtrlZoneNum),
    3254      1181734 :                                       zoneTstatSetpt.setptHi,
    3255      1181734 :                                       zoneTstatSetpt.setptLo,
    3256      1181734 :                                       state.dataSize->FinalZoneSizing(CtrlZoneNum).ZoneSizThermSetPtHi,
    3257      1181734 :                                       state.dataSize->FinalZoneSizing(CtrlZoneNum).ZoneSizThermSetPtLo,
    3258              :                                       timeStepInDay,
    3259              :                                       fracTimeStepZone);
    3260      1181734 :             if (state.dataHeatBal->doSpaceHeatBalanceSizing) {
    3261        10876 :                 for (int spaceNum : state.dataHeatBal->Zone(CtrlZoneNum).spaceIndexes) {
    3262         6386 :                     updateZoneSizingDuringDay(state.dataSize->SpaceSizing(state.dataSize->CurOverallSimDay, spaceNum),
    3263         6386 :                                               state.dataSize->CalcSpaceSizing(state.dataSize->CurOverallSimDay, spaceNum),
    3264         6386 :                                               zoneTstatSetpt.setptHi,
    3265         6386 :                                               zoneTstatSetpt.setptLo,
    3266         6386 :                                               state.dataSize->FinalZoneSizing(CtrlZoneNum).ZoneSizThermSetPtHi,
    3267         6386 :                                               state.dataSize->FinalZoneSizing(CtrlZoneNum).ZoneSizThermSetPtLo,
    3268              :                                               timeStepInDay,
    3269              :                                               fracTimeStepZone);
    3270         4490 :                 }
    3271              :             }
    3272              :         }
    3273       138899 :     } break;
    3274         1913 :     case Constant::CallIndicator::EndDay: {
    3275              :         // average some of the zone sequences to reduce peakiness
    3276        20584 :         for (int CtrlZoneNum = 1; CtrlZoneNum <= state.dataGlobal->NumOfZones; ++CtrlZoneNum) {
    3277        18671 :             if (!state.dataZoneEquip->ZoneEquipConfig(CtrlZoneNum).IsControlled) {
    3278         2092 :                 continue;
    3279              :             }
    3280              :             // auto &calcZoneSizing(state.dataSize->CalcZoneSizing(state.dataSize->CurOverallSimDay, CtrlZoneNum));
    3281        16579 :             updateZoneSizingEndDayMovingAvg(state.dataSize->CalcZoneSizing(state.dataSize->CurOverallSimDay, CtrlZoneNum),
    3282        16579 :                                             state.dataSize->NumTimeStepsInAvg);
    3283        16579 :             if (state.dataHeatBal->doSpaceHeatBalanceSizing) {
    3284          192 :                 for (int spaceNum : state.dataHeatBal->Zone(CtrlZoneNum).spaceIndexes) {
    3285          112 :                     updateZoneSizingEndDayMovingAvg(state.dataSize->CalcSpaceSizing(state.dataSize->CurOverallSimDay, spaceNum),
    3286          112 :                                                     state.dataSize->NumTimeStepsInAvg);
    3287           80 :                 }
    3288              :             }
    3289              :         }
    3290              : 
    3291              :         // auto &desDayWeath = state.dataSize->DesDayWeath(state.dataSize->CurOverallSimDay);
    3292        20584 :         for (int CtrlZoneNum = 1; CtrlZoneNum <= state.dataGlobal->NumOfZones; ++CtrlZoneNum) {
    3293        18671 :             if (!state.dataZoneEquip->ZoneEquipConfig(CtrlZoneNum).IsControlled) {
    3294         2092 :                 continue;
    3295              :             }
    3296              :             // auto &calcZoneSizing = state.dataSize->CalcZoneSizing(state.dataSize->CurOverallSimDay, CtrlZoneNum);
    3297              :             // auto &calcFinalZoneSizing = state.dataSize->CalcFinalZoneSizing(CtrlZoneNum);
    3298        16579 :             updateZoneSizingEndDay(state.dataSize->CalcZoneSizing(state.dataSize->CurOverallSimDay, CtrlZoneNum),
    3299        16579 :                                    state.dataSize->CalcFinalZoneSizing(CtrlZoneNum),
    3300        16579 :                                    state.dataZoneEquipmentManager->NumOfTimeStepInDay,
    3301        16579 :                                    state.dataSize->DesDayWeath(state.dataSize->CurOverallSimDay),
    3302        16579 :                                    state.dataEnvrn->StdRhoAir);
    3303        16579 :             if (state.dataHeatBal->doSpaceHeatBalanceSizing) {
    3304          192 :                 for (int spaceNum : state.dataHeatBal->Zone(CtrlZoneNum).spaceIndexes) {
    3305          112 :                     updateZoneSizingEndDay(state.dataSize->CalcSpaceSizing(state.dataSize->CurOverallSimDay, spaceNum),
    3306          112 :                                            state.dataSize->CalcFinalSpaceSizing(spaceNum),
    3307          112 :                                            state.dataZoneEquipmentManager->NumOfTimeStepInDay,
    3308          112 :                                            state.dataSize->DesDayWeath(state.dataSize->CurOverallSimDay),
    3309          112 :                                            state.dataEnvrn->StdRhoAir);
    3310           80 :                 }
    3311              :             }
    3312              :         }
    3313         1913 :     } break;
    3314          455 :     case Constant::CallIndicator::EndZoneSizingCalc: {
    3315              :         // candidate EMS calling point to customize CalcFinalZoneSizing
    3316              :         bool anyEMSRan;
    3317          455 :         EMSManager::ManageEMS(state, EMSManager::EMSCallFrom::ZoneSizing, anyEMSRan, ObjexxFCL::Optional_int_const());
    3318              : 
    3319              :         // now apply EMS overrides (if any)
    3320          455 :         if (state.dataGlobal->AnyEnergyManagementSystemInModel) {
    3321         1274 :             for (int CtrlZoneNum = 1; CtrlZoneNum <= state.dataGlobal->NumOfZones; ++CtrlZoneNum) {
    3322         1215 :                 auto &calcFinalZoneSizing = state.dataSize->CalcFinalZoneSizing(CtrlZoneNum);
    3323         1215 :                 if (calcFinalZoneSizing.EMSOverrideDesHeatMassOn) {
    3324            0 :                     if (calcFinalZoneSizing.DesHeatMassFlow > 0.0) {
    3325            0 :                         calcFinalZoneSizing.DesHeatMassFlow = calcFinalZoneSizing.EMSValueDesHeatMassFlow;
    3326              :                     }
    3327              :                 }
    3328         1215 :                 if (calcFinalZoneSizing.EMSOverrideDesCoolMassOn) {
    3329            0 :                     if (calcFinalZoneSizing.DesCoolMassFlow > 0.0) {
    3330            0 :                         calcFinalZoneSizing.DesCoolMassFlow = calcFinalZoneSizing.EMSValueDesCoolMassFlow;
    3331              :                     }
    3332              :                 }
    3333         1215 :                 if (calcFinalZoneSizing.EMSOverrideDesHeatLoadOn) {
    3334            0 :                     if (calcFinalZoneSizing.DesHeatLoad > 0.0) {
    3335            0 :                         calcFinalZoneSizing.DesHeatLoad = calcFinalZoneSizing.EMSValueDesHeatLoad;
    3336              :                     }
    3337              :                 }
    3338         1215 :                 if (calcFinalZoneSizing.EMSOverrideDesCoolLoadOn) {
    3339            0 :                     if (calcFinalZoneSizing.DesCoolLoad > 0.0) {
    3340            0 :                         calcFinalZoneSizing.DesCoolLoad = calcFinalZoneSizing.EMSValueDesCoolLoad;
    3341              :                     }
    3342              :                 }
    3343         1215 :                 if (calcFinalZoneSizing.EMSOverrideDesHeatVolOn) {
    3344            0 :                     if (calcFinalZoneSizing.DesHeatVolFlow > 0.0) {
    3345            0 :                         calcFinalZoneSizing.DesHeatVolFlow = calcFinalZoneSizing.EMSValueDesHeatVolFlow;
    3346              :                     }
    3347              :                 }
    3348         1215 :                 if (calcFinalZoneSizing.EMSOverrideDesCoolVolOn) {
    3349            0 :                     if (calcFinalZoneSizing.DesCoolVolFlow > 0.0) {
    3350            0 :                         calcFinalZoneSizing.DesCoolVolFlow = calcFinalZoneSizing.EMSValueDesCoolVolFlow;
    3351              :                     }
    3352              :                 }
    3353              :             }
    3354              :         }
    3355              : 
    3356          455 :         if (!state.dataGlobal->isPulseZoneSizing) {
    3357              : 
    3358              :             // Apply non-coincident zone sizing - only if space sizing is active, and only if there is more than one space in the zone
    3359          428 :             if (state.dataHeatBal->doSpaceHeatBalanceSizing) {
    3360           14 :                 for (int ctrlZoneNum = 1; ctrlZoneNum <= state.dataGlobal->NumOfZones; ++ctrlZoneNum) {
    3361           12 :                     if (!state.dataZoneEquip->ZoneEquipConfig(ctrlZoneNum).IsControlled) {
    3362            2 :                         continue;
    3363              :                     }
    3364           10 :                     if (state.dataHeatBal->Zone(ctrlZoneNum).numSpaces == 1) {
    3365            8 :                         continue;
    3366              :                     }
    3367            2 :                     updateZoneSizingEndZoneSizingCalc1(state, ctrlZoneNum);
    3368              :                 }
    3369              :             }
    3370              : 
    3371         4589 :             for (int CtrlZoneNum = 1; CtrlZoneNum <= state.dataGlobal->NumOfZones; ++CtrlZoneNum) {
    3372         4161 :                 if (!state.dataZoneEquip->ZoneEquipConfig(CtrlZoneNum).IsControlled) {
    3373          491 :                     continue;
    3374              :                 }
    3375         3670 :                 updateZoneSizingEndZoneSizingCalc2(state, state.dataSize->CalcFinalZoneSizing(CtrlZoneNum));
    3376         3670 :                 if (state.dataHeatBal->doSpaceHeatBalanceSizing) {
    3377           24 :                     for (int spaceNum : state.dataHeatBal->Zone(CtrlZoneNum).spaceIndexes) {
    3378           14 :                         updateZoneSizingEndZoneSizingCalc2(state, state.dataSize->CalcFinalSpaceSizing(spaceNum));
    3379           10 :                     }
    3380              :                 }
    3381              :             }
    3382              : 
    3383              :             // Write zone sizing (zsz) and space sizing (spsz) outputs
    3384          428 :             if (state.dataSize->SizingFileColSep == DataStringGlobals::CharComma) {
    3385          428 :                 state.files.zsz.filePath = state.files.outputZszCsvFilePath;
    3386            0 :             } else if (state.dataSize->SizingFileColSep == DataStringGlobals::CharTab) {
    3387            0 :                 state.files.zsz.filePath = state.files.outputZszTabFilePath;
    3388              :             } else {
    3389            0 :                 state.files.zsz.filePath = state.files.outputZszTxtFilePath;
    3390              :             }
    3391          856 :             state.files.zsz.ensure_open(state, "UpdateZoneSizing", state.files.outputControl.zsz);
    3392              : 
    3393          428 :             bool forSpaces = false;
    3394          856 :             writeZszSpsz(
    3395          428 :                 state, state.files.zsz, state.dataGlobal->NumOfZones, state.dataSize->CalcFinalZoneSizing, state.dataSize->CalcZoneSizing, forSpaces);
    3396              : 
    3397          428 :             if (state.dataHeatBal->doSpaceHeatBalanceSizing) {
    3398            2 :                 if (state.dataSize->SizingFileColSep == DataStringGlobals::CharComma) {
    3399            2 :                     state.files.spsz.filePath = state.files.outputSpszCsvFilePath;
    3400            0 :                 } else if (state.dataSize->SizingFileColSep == DataStringGlobals::CharTab) {
    3401            0 :                     state.files.spsz.filePath = state.files.outputSpszTabFilePath;
    3402              :                 } else {
    3403            0 :                     state.files.spsz.filePath = state.files.outputSpszTxtFilePath;
    3404              :                 }
    3405            4 :                 state.files.spsz.ensure_open(state, "UpdateZoneSizing", state.files.outputControl.spsz);
    3406              : 
    3407            2 :                 forSpaces = true;
    3408            4 :                 writeZszSpsz(state,
    3409            2 :                              state.files.spsz,
    3410            2 :                              state.dataGlobal->numSpaces,
    3411            2 :                              state.dataSize->CalcFinalSpaceSizing,
    3412            2 :                              state.dataSize->CalcSpaceSizing,
    3413              :                              forSpaces);
    3414              :             }
    3415              : 
    3416              :             // Move sizing data into final sizing array according to sizing method
    3417         4589 :             for (int zoneNum = 1; zoneNum <= state.dataGlobal->NumOfZones; ++zoneNum) {
    3418         4161 :                 if (!state.dataZoneEquip->ZoneEquipConfig(zoneNum).IsControlled) {
    3419          491 :                     continue;
    3420              :                 }
    3421              :                 // if this zone does not use latent sizing, skip zone and retain sensible load variables
    3422         3670 :                 if (!state.dataSize->CalcFinalZoneSizing(zoneNum).zoneLatentSizing) {
    3423         3662 :                     continue;
    3424              :                 }
    3425            8 :                 updateZoneSizingEndZoneSizingCalc3(
    3426            8 :                     state.dataSize->CalcFinalZoneSizing(zoneNum), state.dataSize->CalcZoneSizing, state.dataHeatBal->isAnyLatentLoad, zoneNum);
    3427            8 :                 if (state.dataHeatBal->doSpaceHeatBalanceSizing) {
    3428            0 :                     for (int spaceNum : state.dataHeatBal->Zone(zoneNum).spaceIndexes) {
    3429            0 :                         updateZoneSizingEndZoneSizingCalc3(state.dataSize->CalcFinalSpaceSizing(spaceNum),
    3430            0 :                                                            state.dataSize->CalcSpaceSizing,
    3431            0 :                                                            state.dataHeatBal->isAnyLatentLoad,
    3432              :                                                            spaceNum);
    3433            0 :                     }
    3434              :                 }
    3435              :             }
    3436              :         }
    3437              : 
    3438              :         // Move data from Calc arrays to user modified arrays
    3439              : 
    3440         9861 :         for (std::size_t i = 0; i < state.dataSize->ZoneSizing.size(); ++i) {
    3441         9406 :             updateZoneSizingEndZoneSizingCalc4(state.dataSize->ZoneSizing[i], state.dataSize->CalcZoneSizing[i]);
    3442         9406 :             if (state.dataHeatBal->doSpaceHeatBalanceSizing) {
    3443          816 :                 for (std::size_t j = 0; j < state.dataSize->SpaceSizing.size(); ++j) {
    3444          768 :                     updateZoneSizingEndZoneSizingCalc4(state.dataSize->SpaceSizing[j], state.dataSize->CalcSpaceSizing[j]);
    3445              :                 }
    3446              :             }
    3447              :         }
    3448              : 
    3449         4831 :         for (std::size_t i = 0; i < state.dataSize->FinalZoneSizing.size(); ++i) {
    3450         4376 :             updateZoneSizingEndZoneSizingCalc5(state.dataSize->FinalZoneSizing[i], state.dataSize->CalcFinalZoneSizing[i]);
    3451         4376 :             if (state.dataHeatBal->doSpaceHeatBalanceSizing) {
    3452          216 :                 for (std::size_t j = 0; j < state.dataSize->FinalSpaceSizing.size(); ++j) {
    3453          192 :                     updateZoneSizingEndZoneSizingCalc5(state.dataSize->FinalSpaceSizing[j], state.dataSize->CalcFinalSpaceSizing[j]);
    3454              :                 }
    3455              :             }
    3456              :         }
    3457              : 
    3458         1428 :         for (int DesDayNum = 1; DesDayNum <= state.dataEnvrn->TotDesDays + state.dataEnvrn->TotRunDesPersDays; ++DesDayNum) {
    3459        10379 :             for (int CtrlZoneNum = 1; CtrlZoneNum <= state.dataGlobal->NumOfZones; ++CtrlZoneNum) {
    3460         9406 :                 if (!state.dataZoneEquip->ZoneEquipConfig(CtrlZoneNum).IsControlled) {
    3461         1046 :                     continue;
    3462              :                 }
    3463         8360 :                 updateZoneSizingEndZoneSizingCalc6(state.dataSize->ZoneSizing(DesDayNum, CtrlZoneNum),
    3464         8360 :                                                    state.dataSize->CalcZoneSizing(DesDayNum, CtrlZoneNum),
    3465         8360 :                                                    state.dataZoneEquipmentManager->NumOfTimeStepInDay);
    3466         8360 :                 if (state.dataHeatBal->doSpaceHeatBalanceSizing) {
    3467           96 :                     for (int spaceNum : state.dataHeatBal->Zone(CtrlZoneNum).spaceIndexes) {
    3468           56 :                         updateZoneSizingEndZoneSizingCalc6(state.dataSize->SpaceSizing(DesDayNum, spaceNum),
    3469           56 :                                                            state.dataSize->CalcSpaceSizing(DesDayNum, spaceNum),
    3470           56 :                                                            state.dataZoneEquipmentManager->NumOfTimeStepInDay);
    3471           40 :                     }
    3472              :                 }
    3473              :             }
    3474              :         }
    3475              : 
    3476         4831 :         for (int CtrlZoneNum = 1; CtrlZoneNum <= state.dataGlobal->NumOfZones; ++CtrlZoneNum) {
    3477         4376 :             if (!state.dataZoneEquip->ZoneEquipConfig(CtrlZoneNum).IsControlled) {
    3478          521 :                 continue;
    3479              :             }
    3480              :             // Yes, call updateZoneSizingEndZoneSizingCalc6 again here to copy the same fields
    3481         3855 :             updateZoneSizingEndZoneSizingCalc6(state.dataSize->FinalZoneSizing(CtrlZoneNum),
    3482         3855 :                                                state.dataSize->CalcFinalZoneSizing(CtrlZoneNum),
    3483         3855 :                                                state.dataZoneEquipmentManager->NumOfTimeStepInDay);
    3484         3855 :             if (state.dataHeatBal->doSpaceHeatBalanceSizing) {
    3485           48 :                 for (int spaceNum : state.dataHeatBal->Zone(CtrlZoneNum).spaceIndexes) {
    3486           28 :                     updateZoneSizingEndZoneSizingCalc6(state.dataSize->FinalSpaceSizing(spaceNum),
    3487           28 :                                                        state.dataSize->CalcFinalSpaceSizing(spaceNum),
    3488           28 :                                                        state.dataZoneEquipmentManager->NumOfTimeStepInDay);
    3489           20 :                 }
    3490              :             }
    3491              :         }
    3492         4831 :         for (int CtrlZoneNum = 1; CtrlZoneNum <= state.dataGlobal->NumOfZones; ++CtrlZoneNum) {
    3493         4376 :             if (!state.dataZoneEquip->ZoneEquipConfig(CtrlZoneNum).IsControlled) {
    3494          521 :                 continue;
    3495              :             }
    3496         7710 :             updateZoneSizingEndZoneSizingCalc7(state,
    3497         3855 :                                                state.dataSize->FinalZoneSizing(CtrlZoneNum),
    3498         3855 :                                                state.dataSize->CalcFinalZoneSizing(CtrlZoneNum),
    3499         3855 :                                                state.dataSize->ZoneSizing,
    3500         3855 :                                                state.dataSize->CalcZoneSizing,
    3501              :                                                CtrlZoneNum);
    3502         3855 :             if (state.dataHeatBal->doSpaceHeatBalanceSizing) {
    3503           48 :                 for (int spaceNum : state.dataHeatBal->Zone(CtrlZoneNum).spaceIndexes) {
    3504           56 :                     updateZoneSizingEndZoneSizingCalc7(state,
    3505           28 :                                                        state.dataSize->FinalSpaceSizing(spaceNum),
    3506           28 :                                                        state.dataSize->CalcFinalSpaceSizing(spaceNum),
    3507           28 :                                                        state.dataSize->SpaceSizing,
    3508           28 :                                                        state.dataSize->CalcSpaceSizing,
    3509              :                                                        spaceNum);
    3510           20 :                 }
    3511              :             }
    3512              :         }
    3513          455 :     } break;
    3514            0 :     default:
    3515            0 :         break;
    3516              :     }
    3517       142240 : }
    3518              : 
    3519      6543197 : void SimZoneEquipment(EnergyPlusData &state, bool const FirstHVACIteration, bool &SimAir)
    3520              : {
    3521              : 
    3522              :     // SUBROUTINE INFORMATION:
    3523              :     //       AUTHOR         Russ Taylor
    3524              :     //       DATE WRITTEN   May 1997
    3525              :     //       MODIFIED       Raustad/Shirey, FSEC, June 2003
    3526              :     //       MODIFIED       Gu, FSEC, Jan. 2004, Don Shirey, Aug 2009 (LatOutputProvided)
    3527              :     //                      July 2012, Chandan Sharma - FSEC: Added zone sys avail managers
    3528              : 
    3529              :     // PURPOSE OF THIS SUBROUTINE:
    3530              :     // This subroutine is responsible for determining
    3531              :     // how much of each type of energy every zone requires.
    3532              :     // In effect, this subroutine defines and simulates all
    3533              :     // the system types and in the case of hybrid systems
    3534              :     // which use more than one type of energy must determine
    3535              :     // how to apportion the load. An example of a hybrid system
    3536              :     // is a water loop heat pump with supplemental air.  In
    3537              :     // this case, a zone will require water from the loop and
    3538              :     // cooled or heated air from the air system. A simpler
    3539              :     // example would be a VAV system with baseboard heaters
    3540              : 
    3541              :     // METHODOLOGY EMPLOYED:
    3542              :     // 1.  Determine zone load - this is zone temperature dependent
    3543              :     // 2.  Determine balance point - the temperature at which the
    3544              :     //     zone load is balanced by the system output. The way the
    3545              :     //     balance point is determined will be different depending on
    3546              :     //     the type of system being simulated.
    3547              :     // 3.  Calculate zone energy requirements
    3548              : 
    3549      6543197 :     bool SupPathInletChanged = false;
    3550      6543197 :     Real64 SysOutputProvided = 0.0; // sensible output delivered by zone equipment (W)
    3551      6543197 :     Real64 LatOutputProvided = 0.0; // latent output delivered by zone equipment (kg/s)
    3552      6543197 :     Real64 AirSysOutput = 0.0;
    3553      6543197 :     Real64 NonAirSysOutput = 0.0;
    3554              : 
    3555              :     // Determine flow rate and temperature of supply air based on type of damper
    3556              : 
    3557      6543197 :     bool FirstCall = true; // indicates first call to supply air path components
    3558      6543197 :     bool ErrorFlag = false;
    3559              : 
    3560     18312030 :     for (int SupplyAirPathNum = 1; SupplyAirPathNum <= state.dataZoneEquip->NumSupplyAirPaths; ++SupplyAirPathNum) {
    3561              : 
    3562     23573100 :         for (int CompNum = 1; CompNum <= state.dataZoneEquip->SupplyAirPath(SupplyAirPathNum).NumOfComponents; ++CompNum) {
    3563              : 
    3564     11804267 :             switch (state.dataZoneEquip->SupplyAirPath(SupplyAirPathNum).ComponentTypeEnum(CompNum)) {
    3565     11765149 :             case DataZoneEquipment::AirLoopHVACZone::Splitter: { // 'AirLoopHVAC:ZoneSplitter'
    3566              : 
    3567     11765149 :                 if (!(state.afn->AirflowNetworkFanActivated && state.afn->distribution_simulated)) {
    3568     11565566 :                     SplitterComponent::SimAirLoopSplitter(state,
    3569     11565566 :                                                           state.dataZoneEquip->SupplyAirPath(SupplyAirPathNum).ComponentName(CompNum),
    3570              :                                                           FirstHVACIteration,
    3571              :                                                           FirstCall,
    3572              :                                                           SupPathInletChanged,
    3573     11565566 :                                                           state.dataZoneEquip->SupplyAirPath(SupplyAirPathNum).ComponentIndex(CompNum));
    3574              :                 }
    3575              : 
    3576     11765149 :                 break;
    3577              :             }
    3578        39118 :             case DataZoneEquipment::AirLoopHVACZone::SupplyPlenum: { // 'AirLoopHVAC:SupplyPlenum'
    3579              : 
    3580        78236 :                 ZonePlenum::SimAirZonePlenum(state,
    3581        39118 :                                              state.dataZoneEquip->SupplyAirPath(SupplyAirPathNum).ComponentName(CompNum),
    3582              :                                              DataZoneEquipment::AirLoopHVACZone::SupplyPlenum,
    3583        39118 :                                              state.dataZoneEquip->SupplyAirPath(SupplyAirPathNum).ComponentIndex(CompNum),
    3584              :                                              FirstHVACIteration,
    3585              :                                              FirstCall,
    3586              :                                              SupPathInletChanged);
    3587              : 
    3588        39118 :                 break;
    3589              :             }
    3590            0 :             default: {
    3591            0 :                 ShowSevereError(state, format("Error found in Supply Air Path={}", state.dataZoneEquip->SupplyAirPath(SupplyAirPathNum).Name));
    3592            0 :                 ShowContinueError(
    3593              :                     state,
    3594            0 :                     format("Invalid Supply Air Path Component={}", state.dataZoneEquip->SupplyAirPath(SupplyAirPathNum).ComponentType(CompNum)));
    3595            0 :                 ShowFatalError(state, "Preceding condition causes termination.");
    3596              : 
    3597            0 :                 break;
    3598              :             }
    3599              :             }
    3600              :         }
    3601              :     }
    3602              : 
    3603      6543197 :     FirstCall = false;
    3604              : 
    3605              :     // Loop over all the primary air loop; simulate their components (equipment)
    3606              :     // and controllers
    3607      6543197 :     if (state.dataHeatBal->ZoneAirMassFlow.EnforceZoneMassBalance) {
    3608         7352 :         if (FirstHVACIteration) {
    3609         3565 :             CalcAirFlowSimple(state, 0);
    3610              :         } else {
    3611         7574 :             CalcAirFlowSimple(
    3612         3787 :                 state, 0, state.dataHeatBal->ZoneAirMassFlow.AdjustZoneMixingFlow, state.dataHeatBal->ZoneAirMassFlow.AdjustZoneInfiltrationFlow);
    3613              :         }
    3614              :     }
    3615              : 
    3616              :     // If SpaceHVAC is active calculate SpaceHVAC:EquipmentMixer outlet conditions before simulating zone equipment
    3617      6543197 :     if (state.dataHeatBal->doSpaceHeatBalanceSimulation && !state.dataGlobal->DoingSizing) {
    3618        12552 :         for (auto &thisSpaceHVACMixer : state.dataZoneEquip->zoneEquipMixer) {
    3619         4464 :             thisSpaceHVACMixer.setOutletConditions(state);
    3620         8088 :         }
    3621              :     }
    3622              : 
    3623     57508524 :     for (int ControlledZoneNum = 1; ControlledZoneNum <= state.dataGlobal->NumOfZones; ++ControlledZoneNum) {
    3624              : 
    3625     50965327 :         if (!state.dataZoneEquip->ZoneEquipConfig(ControlledZoneNum).IsControlled) {
    3626      6939584 :             continue;
    3627              :         }
    3628     44025743 :         auto &thisZoneHB = state.dataZoneTempPredictorCorrector->zoneHeatBalance(ControlledZoneNum);
    3629              : 
    3630     44025743 :         thisZoneHB.NonAirSystemResponse = 0.0;
    3631     44025743 :         thisZoneHB.SysDepZoneLoads = 0.0;
    3632     44025743 :         auto &zoneEquipConfig = state.dataZoneEquip->ZoneEquipConfig(ControlledZoneNum);
    3633     44025743 :         zoneEquipConfig.ZoneExh = 0.0;
    3634     44025743 :         zoneEquipConfig.ZoneExhBalanced = 0.0;
    3635     44025743 :         zoneEquipConfig.PlenumMassFlow = 0.0;
    3636     44025743 :         state.dataSize->CurZoneEqNum = ControlledZoneNum;
    3637     44025743 :         if (state.dataHeatBal->doSpaceHeatBalanceSimulation && !state.dataGlobal->DoingSizing) {
    3638        98736 :             for (int spaceNum : state.dataHeatBal->Zone(ControlledZoneNum).spaceIndexes) {
    3639        58296 :                 auto &thisSpaceHB = state.dataZoneTempPredictorCorrector->spaceHeatBalance(spaceNum);
    3640        58296 :                 thisSpaceHB.NonAirSystemResponse = 0.0;
    3641        58296 :                 thisSpaceHB.SysDepZoneLoads = 0.0;
    3642        58296 :                 auto &thisSpaceEquipConfig = state.dataZoneEquip->spaceEquipConfig(spaceNum);
    3643        58296 :                 if (!thisSpaceEquipConfig.IsControlled) {
    3644        44904 :                     continue;
    3645              :                 }
    3646        13392 :                 thisSpaceEquipConfig.ZoneExh = 0.0;
    3647        13392 :                 thisSpaceEquipConfig.ZoneExhBalanced = 0.0;
    3648        13392 :                 thisSpaceEquipConfig.PlenumMassFlow = 0.0;
    3649        40440 :             }
    3650              :         }
    3651              : 
    3652     44025743 :         InitSystemOutputRequired(state, ControlledZoneNum, FirstHVACIteration, true);
    3653              : 
    3654     94710385 :         for (int EquipTypeNum = 1; EquipTypeNum <= state.dataZoneEquip->ZoneEquipList(ControlledZoneNum).NumOfEquipTypes; ++EquipTypeNum) {
    3655              : 
    3656              :             // Air loop system availability manager status only applies to PIU and exhaust fans
    3657              :             // Reset fan SAM operation flags for zone fans.
    3658     50684642 :             state.dataHVACGlobal->TurnFansOn = false;
    3659     50684642 :             state.dataHVACGlobal->TurnFansOff = false;
    3660              : 
    3661     50684642 :             state.dataHVACGlobal->UnbalExhMassFlow = 0.0;
    3662     50684642 :             state.dataHVACGlobal->BalancedExhMassFlow = 0.0;
    3663     50684642 :             state.dataHVACGlobal->PlenumInducedMassFlow = 0.0;
    3664     50684642 :             const int EquipPtr = state.dataZoneEquipmentManager->PrioritySimOrder(EquipTypeNum).EquipPtr;
    3665     50684642 :             SysOutputProvided = 0.0;
    3666     50684642 :             LatOutputProvided = 0.0;
    3667     50684642 :             NonAirSysOutput = 0.0;
    3668     50684642 :             state.dataSize->DataCoolCoilCap = 0.0; // reset global variable used only for heat pumps (i.e., DX cooling and heating coils)
    3669              : 
    3670              :             // Reset ZoneEqSizing data (because these may change from one equipment type to the next)
    3671     50684642 :             if (state.dataZoneEquipmentManager->FirstPassZoneEquipFlag) {
    3672         5191 :                 auto &zoneEqSizing = state.dataSize->ZoneEqSizing(ControlledZoneNum);
    3673              : 
    3674         5191 :                 zoneEqSizing.AirVolFlow = 0.0;
    3675         5191 :                 zoneEqSizing.MaxHWVolFlow = 0.0;
    3676         5191 :                 zoneEqSizing.MaxCWVolFlow = 0.0;
    3677         5191 :                 zoneEqSizing.OAVolFlow = 0.0;
    3678         5191 :                 zoneEqSizing.DesCoolingLoad = 0.0;
    3679         5191 :                 zoneEqSizing.DesHeatingLoad = 0.0;
    3680         5191 :                 zoneEqSizing.CoolingAirVolFlow = 0.0;
    3681         5191 :                 zoneEqSizing.HeatingAirVolFlow = 0.0;
    3682         5191 :                 zoneEqSizing.SystemAirVolFlow = 0.0;
    3683         5191 :                 zoneEqSizing.AirFlow = false;
    3684         5191 :                 zoneEqSizing.CoolingAirFlow = false;
    3685         5191 :                 zoneEqSizing.HeatingAirFlow = false;
    3686         5191 :                 zoneEqSizing.SystemAirFlow = false;
    3687         5191 :                 zoneEqSizing.Capacity = false;
    3688         5191 :                 zoneEqSizing.CoolingCapacity = false;
    3689         5191 :                 zoneEqSizing.HeatingCapacity = false;
    3690         5191 :                 zoneEqSizing.SystemCapacity = false;
    3691         5191 :                 zoneEqSizing.DesignSizeFromParent = false;
    3692              :             }
    3693              : 
    3694     50684642 :             DataZoneEquipment::ZoneEquipType zoneEquipType = state.dataZoneEquipmentManager->PrioritySimOrder(EquipTypeNum).equipType;
    3695              : 
    3696     50684642 :             auto &zoneEquipList = state.dataZoneEquip->ZoneEquipList(state.dataSize->CurZoneEqNum);
    3697              : 
    3698     50684642 :             const int ZoneCompNum = zoneEquipList.EquipIndex(EquipPtr);
    3699              : 
    3700     50684642 :             bool ValidSAMComp = false;
    3701              : 
    3702     50684642 :             if ((int)zoneEquipType <= NumValidSysAvailZoneComponents) {
    3703      7966590 :                 ValidSAMComp = true;
    3704              :             }
    3705              : 
    3706     50684642 :             if (ZoneCompNum > 0 && ValidSAMComp) {
    3707              : 
    3708      7965954 :                 Avail::GetZoneEqAvailabilityManager(state, zoneEquipType, ZoneCompNum, ErrorFlag);
    3709              : 
    3710      7965954 :                 if (state.dataAvail->ZoneComp((int)zoneEquipType).ZoneCompAvailMgrs(ZoneCompNum).availStatus == Avail::Status::CycleOn) {
    3711         5580 :                     state.dataHVACGlobal->TurnFansOn = true;
    3712         5580 :                     state.dataHVACGlobal->TurnFansOff = false;
    3713      7960374 :                 } else if (state.dataAvail->ZoneComp((int)zoneEquipType).ZoneCompAvailMgrs(ZoneCompNum).availStatus == Avail::Status::ForceOff) {
    3714         2890 :                     state.dataHVACGlobal->TurnFansOn = false;
    3715         2890 :                     state.dataHVACGlobal->TurnFansOff = true;
    3716              :                 }
    3717              :             }
    3718              : 
    3719              :             // If SpaceHVAC is active and this equipment has a space splitter, scale the zone load if needed
    3720     50729546 :             if (state.dataHeatBal->doSpaceHeatBalanceSimulation && !state.dataGlobal->DoingSizing &&
    3721        44904 :                 zoneEquipList.zoneEquipSplitterIndex(EquipPtr) > -1) {
    3722         8928 :                 state.dataZoneEquip->zoneEquipSplitter[zoneEquipList.zoneEquipSplitterIndex(EquipPtr)].adjustLoads(
    3723              :                     state, ControlledZoneNum, EquipTypeNum);
    3724              :             }
    3725              : 
    3726     50684642 :             switch (zoneEquipType) {
    3727     38668215 :             case ZoneEquipType::AirDistributionUnit: { // 'ZoneHVAC:AirDistributionUnit'
    3728              :                 // Air loop system availability manager status only applies to PIU and exhaust fans
    3729              :                 // Check to see if System Availability Managers are asking for fans to cycle on or shut off
    3730              :                 // and set fan on/off flags accordingly.
    3731     55000621 :                 if (state.dataZoneEquip->ZoneEquipAvail(ControlledZoneNum) == Avail::Status::CycleOn ||
    3732     16332406 :                     state.dataZoneEquip->ZoneEquipAvail(ControlledZoneNum) == Avail::Status::CycleOnZoneFansOnly) {
    3733     22335809 :                     state.dataHVACGlobal->TurnFansOn = true;
    3734              :                 }
    3735     38668215 :                 if (state.dataZoneEquip->ZoneEquipAvail(ControlledZoneNum) == Avail::Status::ForceOff) {
    3736      1664958 :                     state.dataHVACGlobal->TurnFansOff = true;
    3737              :                 }
    3738              : 
    3739     38668215 :                 ZoneAirLoopEquipmentManager::ManageZoneAirLoopEquipment(state,
    3740     38668215 :                                                                         state.dataZoneEquipmentManager->PrioritySimOrder(EquipTypeNum).EquipName,
    3741              :                                                                         FirstHVACIteration,
    3742              :                                                                         AirSysOutput,
    3743              :                                                                         NonAirSysOutput,
    3744              :                                                                         LatOutputProvided,
    3745              :                                                                         ControlledZoneNum,
    3746              :                                                                         zoneEquipList.EquipIndex(EquipPtr));
    3747              : 
    3748     38668215 :                 SysOutputProvided = NonAirSysOutput + AirSysOutput;
    3749     38668215 :             } break;
    3750              : 
    3751       237775 :             case ZoneEquipType::VariableRefrigerantFlowTerminal: { // 'ZoneHVAC:TerminalUnit:VariableRefrigerantFlow'
    3752       237775 :                 bool HeatingActive = false;
    3753       237775 :                 bool CoolingActive = false;
    3754       237775 :                 int constexpr OAUnitNum = 0;
    3755       237775 :                 Real64 constexpr OAUCoilOutTemp = 0.0;
    3756       237775 :                 bool constexpr ZoneEquipment = true;
    3757       475550 :                 HVACVariableRefrigerantFlow::SimulateVRF(state,
    3758       237775 :                                                          state.dataZoneEquipmentManager->PrioritySimOrder(EquipTypeNum).EquipName,
    3759              :                                                          FirstHVACIteration,
    3760              :                                                          ControlledZoneNum,
    3761              :                                                          zoneEquipList.EquipIndex(EquipPtr),
    3762              :                                                          HeatingActive,
    3763              :                                                          CoolingActive,
    3764              :                                                          OAUnitNum,
    3765              :                                                          OAUCoilOutTemp,
    3766              :                                                          ZoneEquipment,
    3767              :                                                          SysOutputProvided,
    3768              :                                                          LatOutputProvided);
    3769       237775 :             } break;
    3770              : 
    3771       131436 :             case ZoneEquipType::WindowAirConditioner: { // 'ZoneHVAC:WindowAirConditioner'
    3772       262872 :                 WindowAC::SimWindowAC(state,
    3773       131436 :                                       state.dataZoneEquipmentManager->PrioritySimOrder(EquipTypeNum).EquipName,
    3774              :                                       ControlledZoneNum,
    3775              :                                       FirstHVACIteration,
    3776              :                                       SysOutputProvided,
    3777              :                                       LatOutputProvided,
    3778              :                                       zoneEquipList.EquipIndex(EquipPtr));
    3779       131436 :             } break;
    3780              : 
    3781      3380673 :             case ZoneEquipType::PackagedTerminalHeatPump:           // 'ZoneHVAC:PackagedTerminalHeatPump'
    3782              :             case ZoneEquipType::PackagedTerminalAirConditioner:     // 'ZoneHVAC:PackagedTerminalAirConditioner'
    3783              :             case ZoneEquipType::PackagedTerminalHeatPumpWaterToAir: // 'ZoneHVAC:WaterToAirHeatPump'
    3784              :             case ZoneEquipType::UnitarySystem: {                    // 'AirloopHVAC:UnitarySystem'
    3785      3380673 :                 int AirLoopNum = 0;
    3786      3380673 :                 bool HeatingActive = false;
    3787      3380673 :                 bool CoolingActive = false;
    3788      3380673 :                 int OAUnitNum = 0;
    3789      3380673 :                 Real64 OAUCoilOutTemp = 0.0;
    3790      3380673 :                 bool ZoneEquipFlag = true;
    3791      6761346 :                 zoneEquipList.compPointer[EquipPtr]->simulate(state,
    3792      3380673 :                                                               state.dataZoneEquipmentManager->PrioritySimOrder(EquipTypeNum).EquipName,
    3793              :                                                               FirstHVACIteration,
    3794              :                                                               AirLoopNum,
    3795              :                                                               zoneEquipList.EquipIndex(EquipPtr),
    3796              :                                                               HeatingActive,
    3797              :                                                               CoolingActive,
    3798              :                                                               OAUnitNum,
    3799              :                                                               OAUCoilOutTemp,
    3800              :                                                               ZoneEquipFlag,
    3801              :                                                               SysOutputProvided,
    3802              :                                                               LatOutputProvided);
    3803      3380673 :             } break;
    3804        50990 :             case ZoneEquipType::DehumidifierDX: { // 'ZoneHVAC:Dehumidifier:DX'
    3805        50990 :                 ZoneDehumidifier::SimZoneDehumidifier(state,
    3806        50990 :                                                       state.dataZoneEquipmentManager->PrioritySimOrder(EquipTypeNum).EquipName,
    3807              :                                                       ControlledZoneNum,
    3808              :                                                       FirstHVACIteration,
    3809              :                                                       SysOutputProvided,
    3810              :                                                       LatOutputProvided,
    3811              :                                                       zoneEquipList.EquipIndex(EquipPtr));
    3812              : 
    3813        50990 :                 thisZoneHB.SysDepZoneLoads += SysOutputProvided;
    3814              : 
    3815        50990 :                 SysOutputProvided = 0.0; // Reset to 0.0 since this equipment is controlled based on zone humidity level (not
    3816              :                                          // temperature) SysOutputProvided amount was already sent above to
    3817              :                                          // next Predict-Correct series of calcs via SysDepZoneLoads
    3818        50990 :             } break;
    3819              : 
    3820       515028 :             case ZoneEquipType::FourPipeFanCoil: { // 'ZoneHVAC:FourPipeFanCoil'
    3821      1030056 :                 FanCoilUnits::SimFanCoilUnit(state,
    3822       515028 :                                              state.dataZoneEquipmentManager->PrioritySimOrder(EquipTypeNum).EquipName,
    3823              :                                              ControlledZoneNum,
    3824              :                                              FirstHVACIteration,
    3825              :                                              SysOutputProvided,
    3826              :                                              LatOutputProvided,
    3827              :                                              zoneEquipList.EquipIndex(EquipPtr));
    3828       515028 :             } break;
    3829              : 
    3830       162760 :             case ZoneEquipType::UnitVentilator: { // 'ZoneHVAC:UnitVentilator'
    3831       325520 :                 UnitVentilator::SimUnitVentilator(state,
    3832       162760 :                                                   state.dataZoneEquipmentManager->PrioritySimOrder(EquipTypeNum).EquipName,
    3833              :                                                   ControlledZoneNum,
    3834              :                                                   FirstHVACIteration,
    3835              :                                                   SysOutputProvided,
    3836              :                                                   LatOutputProvided,
    3837              :                                                   zoneEquipList.EquipIndex(EquipPtr));
    3838       162760 :             } break;
    3839              : 
    3840       638585 :             case ZoneEquipType::UnitHeater: { // 'ZoneHVAC:UnitHeater'
    3841      1277170 :                 UnitHeater::SimUnitHeater(state,
    3842       638585 :                                           state.dataZoneEquipmentManager->PrioritySimOrder(EquipTypeNum).EquipName,
    3843              :                                           ControlledZoneNum,
    3844              :                                           FirstHVACIteration,
    3845              :                                           SysOutputProvided,
    3846              :                                           LatOutputProvided,
    3847              :                                           zoneEquipList.EquipIndex(EquipPtr));
    3848       638585 :             } break;
    3849              : 
    3850      2076247 :             case ZoneEquipType::PurchasedAir: { // 'ZoneHVAC:IdealLoadsAirSystem'
    3851      2076247 :                 PurchasedAirManager::SimPurchasedAir(state,
    3852      2076247 :                                                      state.dataZoneEquipmentManager->PrioritySimOrder(EquipTypeNum).EquipName,
    3853              :                                                      SysOutputProvided,
    3854              :                                                      LatOutputProvided,
    3855              :                                                      FirstHVACIteration,
    3856              :                                                      ControlledZoneNum,
    3857              :                                                      zoneEquipList.EquipIndex(EquipPtr));
    3858      2076247 :             } break;
    3859              : 
    3860        89083 :             case ZoneEquipType::BaseboardWater: { // 'ZoneHVAC:Baseboard:RadiantConvective:Water'
    3861        89083 :                 HWBaseboardRadiator::SimHWBaseboard(state,
    3862        89083 :                                                     state.dataZoneEquipmentManager->PrioritySimOrder(EquipTypeNum).EquipName,
    3863              :                                                     ControlledZoneNum,
    3864              :                                                     FirstHVACIteration,
    3865              :                                                     SysOutputProvided,
    3866              :                                                     zoneEquipList.EquipIndex(EquipPtr));
    3867              : 
    3868        89083 :                 NonAirSysOutput = SysOutputProvided;
    3869        89083 :                 LatOutputProvided = 0.0; // This baseboard does not add/remove any latent heat
    3870        89083 :             } break;
    3871              : 
    3872         7356 :             case ZoneEquipType::BaseboardSteam: { // 'ZoneHVAC:Baseboard:RadiantConvective:Steam'
    3873         7356 :                 SteamBaseboardRadiator::SimSteamBaseboard(state,
    3874         7356 :                                                           state.dataZoneEquipmentManager->PrioritySimOrder(EquipTypeNum).EquipName,
    3875              :                                                           ControlledZoneNum,
    3876              :                                                           FirstHVACIteration,
    3877              :                                                           SysOutputProvided,
    3878              :                                                           zoneEquipList.EquipIndex(EquipPtr));
    3879              : 
    3880         7356 :                 NonAirSysOutput = SysOutputProvided;
    3881         7356 :                 LatOutputProvided = 0.0; // This baseboard does not add/remove any latent heat
    3882         7356 :             } break;
    3883              : 
    3884       162355 :             case ZoneEquipType::BaseboardConvectiveWater: { // 'ZoneHVAC:Baseboard:Convective:Water'
    3885       162355 :                 BaseboardRadiator::SimBaseboard(state,
    3886       162355 :                                                 state.dataZoneEquipmentManager->PrioritySimOrder(EquipTypeNum).EquipName,
    3887              :                                                 ControlledZoneNum,
    3888              :                                                 FirstHVACIteration,
    3889              :                                                 SysOutputProvided,
    3890              :                                                 zoneEquipList.EquipIndex(EquipPtr));
    3891              : 
    3892       162355 :                 NonAirSysOutput = SysOutputProvided;
    3893       162355 :                 LatOutputProvided = 0.0; // This baseboard does not add/remove any latent heat
    3894       162355 :             } break;
    3895              : 
    3896       327006 :             case ZoneEquipType::BaseboardConvectiveElectric: { // 'ZoneHVAC:Baseboard:Convective:Electric'
    3897       327006 :                 BaseboardElectric::SimElectricBaseboard(state,
    3898       327006 :                                                         state.dataZoneEquipmentManager->PrioritySimOrder(EquipTypeNum).EquipName,
    3899              :                                                         ControlledZoneNum,
    3900              :                                                         SysOutputProvided,
    3901              :                                                         zoneEquipList.EquipIndex(EquipPtr));
    3902              : 
    3903       327006 :                 NonAirSysOutput = SysOutputProvided;
    3904       327006 :                 LatOutputProvided = 0.0; // This baseboard does not add/remove any latent heat
    3905       327006 :             } break;
    3906              : 
    3907        22415 :             case ZoneEquipType::CoolingPanel: { // 'ZoneHVAC:CoolingPanel:RadiantConvective:Water'
    3908        22415 :                 CoolingPanelSimple::SimCoolingPanel(state,
    3909        22415 :                                                     state.dataZoneEquipmentManager->PrioritySimOrder(EquipTypeNum).EquipName,
    3910              :                                                     ControlledZoneNum,
    3911              :                                                     FirstHVACIteration,
    3912              :                                                     SysOutputProvided,
    3913              :                                                     zoneEquipList.EquipIndex(EquipPtr));
    3914              : 
    3915        22415 :                 NonAirSysOutput = SysOutputProvided;
    3916        22415 :                 LatOutputProvided = 0.0; // This cooling panel does not add/remove any latent heat
    3917        22415 :             } break;
    3918              : 
    3919       129408 :             case ZoneEquipType::HighTemperatureRadiant: { // 'ZoneHVAC:HighTemperatureRadiant'
    3920       258816 :                 HighTempRadiantSystem::SimHighTempRadiantSystem(state,
    3921       129408 :                                                                 state.dataZoneEquipmentManager->PrioritySimOrder(EquipTypeNum).EquipName,
    3922              :                                                                 FirstHVACIteration,
    3923              :                                                                 SysOutputProvided,
    3924              :                                                                 zoneEquipList.EquipIndex(EquipPtr));
    3925       129408 :                 LatOutputProvided = 0.0; // This baseboard currently sends its latent heat gain directly to predictor/corrector
    3926              :                                          // via SumLatentHTRadSys... so setting LatOutputProvided = 0.0
    3927       129408 :             } break;
    3928              : 
    3929       666848 :             case ZoneEquipType::LowTemperatureRadiantConstFlow:
    3930              :             case ZoneEquipType::LowTemperatureRadiantVarFlow:
    3931              :             case ZoneEquipType::LowTemperatureRadiantElectric: {
    3932      1333696 :                 LowTempRadiantSystem::SimLowTempRadiantSystem(state,
    3933       666848 :                                                               state.dataZoneEquipmentManager->PrioritySimOrder(EquipTypeNum).EquipName,
    3934              :                                                               FirstHVACIteration,
    3935              :                                                               SysOutputProvided,
    3936              :                                                               zoneEquipList.EquipIndex(EquipPtr));
    3937       666848 :                 LatOutputProvided = 0.0; // This baseboard does not add/remove any latent heat
    3938       666848 :             } break;
    3939              : 
    3940      1894988 :             case ZoneEquipType::ExhaustFan: { // 'Fan:ZoneExhaust'
    3941              :                 // Air loop system availability manager status only applies to PIU and exhaust fans
    3942              :                 // Check to see if System Availability Managers are asking for fans to cycle on or shut off
    3943              :                 // and set fan on/off flags accordingly.
    3944      2665141 :                 if (state.dataZoneEquip->ZoneEquipAvail(ControlledZoneNum) == Avail::Status::CycleOn ||
    3945       770153 :                     state.dataZoneEquip->ZoneEquipAvail(ControlledZoneNum) == Avail::Status::CycleOnZoneFansOnly) {
    3946      1124835 :                     state.dataHVACGlobal->TurnFansOn = true;
    3947              :                 }
    3948      1894988 :                 if (state.dataZoneEquip->ZoneEquipAvail(ControlledZoneNum) == Avail::Status::ForceOff) {
    3949        48110 :                     state.dataHVACGlobal->TurnFansOff = true;
    3950              :                 }
    3951              : 
    3952      1894988 :                 if (zoneEquipList.EquipIndex(EquipPtr) == 0) { // TODO: Get rid of this
    3953          161 :                     zoneEquipList.EquipIndex(EquipPtr) = Fans::GetFanIndex(state, zoneEquipList.EquipName(EquipPtr));
    3954              :                 }
    3955              : 
    3956      1894988 :                 state.dataFans->fans(zoneEquipList.EquipIndex(EquipPtr))->simulate(state, FirstHVACIteration);
    3957              : 
    3958      1894988 :             } break;
    3959              : 
    3960            0 :             case ZoneEquipType::HeatExchanger: { // 'HeatExchanger:AirToAir:FlatPlate'
    3961            0 :                 HeatRecovery::SimHeatRecovery(state,
    3962            0 :                                               state.dataZoneEquipmentManager->PrioritySimOrder(EquipTypeNum).EquipName,
    3963              :                                               FirstHVACIteration,
    3964              :                                               zoneEquipList.EquipIndex(EquipPtr),
    3965              :                                               HVAC::FanOp::Continuous);
    3966            0 :             } break;
    3967              : 
    3968       653192 :             case ZoneEquipType::EnergyRecoveryVentilator: { // 'ZoneHVAC:EnergyRecoveryVentilator'
    3969      1306384 :                 HVACStandAloneERV::SimStandAloneERV(state,
    3970       653192 :                                                     state.dataZoneEquipmentManager->PrioritySimOrder(EquipTypeNum).EquipName,
    3971              :                                                     ControlledZoneNum,
    3972              :                                                     FirstHVACIteration,
    3973              :                                                     SysOutputProvided,
    3974              :                                                     LatOutputProvided,
    3975              :                                                     zoneEquipList.EquipIndex(EquipPtr));
    3976       653192 :             } break;
    3977              : 
    3978       124230 :             case ZoneEquipType::HeatPumpWaterHeaterPumpedCondenser:
    3979              :             case ZoneEquipType::HeatPumpWaterHeaterWrappedCondenser: {
    3980       124230 :                 WaterThermalTanks::SimHeatPumpWaterHeater(state,
    3981       124230 :                                                           state.dataZoneEquipmentManager->PrioritySimOrder(EquipTypeNum).EquipName,
    3982              :                                                           FirstHVACIteration,
    3983              :                                                           SysOutputProvided,
    3984              :                                                           LatOutputProvided,
    3985       124230 :                                                           state.dataZoneEquip->ZoneEquipList(ControlledZoneNum).EquipIndex(EquipPtr));
    3986       124230 :             } break;
    3987              : 
    3988       105543 :             case ZoneEquipType::VentilatedSlab: { // 'ZoneHVAC:VentilatedSlab'
    3989       105543 :                 VentilatedSlab::SimVentilatedSlab(state,
    3990       105543 :                                                   state.dataZoneEquipmentManager->PrioritySimOrder(EquipTypeNum).EquipName,
    3991              :                                                   ControlledZoneNum,
    3992              :                                                   FirstHVACIteration,
    3993              :                                                   SysOutputProvided,
    3994              :                                                   LatOutputProvided,
    3995              :                                                   zoneEquipList.EquipIndex(EquipPtr));
    3996       105543 :             } break;
    3997              : 
    3998        64818 :             case ZoneEquipType::OutdoorAirUnit: { // 'ZoneHVAC:OutdoorAirUnit'
    3999       129636 :                 OutdoorAirUnit::SimOutdoorAirUnit(state,
    4000        64818 :                                                   state.dataZoneEquipmentManager->PrioritySimOrder(EquipTypeNum).EquipName,
    4001              :                                                   ControlledZoneNum,
    4002              :                                                   FirstHVACIteration,
    4003              :                                                   SysOutputProvided,
    4004              :                                                   LatOutputProvided,
    4005              :                                                   zoneEquipList.EquipIndex(EquipPtr));
    4006        64818 :             } break;
    4007              : 
    4008        11050 :             case ZoneEquipType::BaseboardElectric: { // 'ZoneHVAC:Baseboard:RadiantConvective:Electric'
    4009        11050 :                 ElectricBaseboardRadiator::SimElecBaseboard(state,
    4010        11050 :                                                             state.dataZoneEquipmentManager->PrioritySimOrder(EquipTypeNum).EquipName,
    4011              :                                                             ControlledZoneNum,
    4012              :                                                             FirstHVACIteration,
    4013              :                                                             SysOutputProvided,
    4014              :                                                             zoneEquipList.EquipIndex(EquipPtr));
    4015              : 
    4016        11050 :                 NonAirSysOutput = SysOutputProvided;
    4017        11050 :                 LatOutputProvided = 0.0; // This baseboard does not add/remove any latent heat
    4018        11050 :             } break;
    4019              : 
    4020       356260 :             case ZoneEquipType::RefrigerationChillerSet: { // 'ZoneHVAC:RefrigerationChillerSet'
    4021       356260 :                 RefrigeratedCase::SimAirChillerSet(state,
    4022       356260 :                                                    state.dataZoneEquipmentManager->PrioritySimOrder(EquipTypeNum).EquipName,
    4023              :                                                    ControlledZoneNum,
    4024              :                                                    FirstHVACIteration,
    4025              :                                                    SysOutputProvided,
    4026              :                                                    LatOutputProvided,
    4027              :                                                    zoneEquipList.EquipIndex(EquipPtr));
    4028              : 
    4029       356260 :                 NonAirSysOutput = SysOutputProvided;
    4030       356260 :             } break;
    4031              : 
    4032        24666 :             case ZoneEquipType::UserDefinedHVACForcedAir: {
    4033        49332 :                 UserDefinedComponents::SimZoneAirUserDefined(state,
    4034        24666 :                                                              state.dataZoneEquipmentManager->PrioritySimOrder(EquipTypeNum).EquipName,
    4035              :                                                              ControlledZoneNum,
    4036              :                                                              SysOutputProvided,
    4037              :                                                              LatOutputProvided,
    4038              :                                                              zoneEquipList.EquipIndex(EquipPtr));
    4039        24666 :             } break;
    4040              : 
    4041       170440 :             case ZoneEquipType::EvaporativeCooler: {
    4042       340880 :                 EvaporativeCoolers::SimZoneEvaporativeCoolerUnit(state,
    4043       170440 :                                                                  state.dataZoneEquipmentManager->PrioritySimOrder(EquipTypeNum).EquipName,
    4044              :                                                                  ControlledZoneNum,
    4045              :                                                                  SysOutputProvided,
    4046              :                                                                  LatOutputProvided,
    4047              :                                                                  zoneEquipList.EquipIndex(EquipPtr));
    4048       170440 :             } break;
    4049              : 
    4050        13275 :             case ZoneEquipType::HybridEvaporativeCooler: {
    4051        26550 :                 HybridUnitaryAirConditioners::SimZoneHybridUnitaryAirConditioners(
    4052              :                     state,
    4053        13275 :                     state.dataZoneEquipmentManager->PrioritySimOrder(EquipTypeNum).EquipName,
    4054              :                     ControlledZoneNum,
    4055              :                     SysOutputProvided,
    4056              :                     LatOutputProvided,
    4057              :                     zoneEquipList.EquipIndex(EquipPtr));
    4058        13275 :             } break;
    4059              : 
    4060            0 :             default:
    4061            0 :                 break;
    4062              :             }
    4063              : 
    4064     50684642 :             zoneEquipConfig.ZoneExh +=
    4065     50684642 :                 (state.dataHVACGlobal->UnbalExhMassFlow +
    4066     50684642 :                  state.dataHVACGlobal->BalancedExhMassFlow); // This is the total "exhaust" flow from equipment such as a zone exhaust fan
    4067     50684642 :             zoneEquipConfig.ZoneExhBalanced += state.dataHVACGlobal->BalancedExhMassFlow;
    4068     50684642 :             zoneEquipConfig.PlenumMassFlow += state.dataHVACGlobal->PlenumInducedMassFlow;
    4069              : 
    4070              :             // Store available capacities for load distribution calculations
    4071     50684642 :             if (FirstHVACIteration && (zoneEquipList.LoadDistScheme != DataZoneEquipment::LoadDist::Sequential)) {
    4072        23430 :                 if (SysOutputProvided > 0.0) {
    4073         7553 :                     zoneEquipList.HeatingCapacity(EquipPtr) = SysOutputProvided;
    4074              :                 } else {
    4075        15877 :                     zoneEquipList.CoolingCapacity(EquipPtr) = SysOutputProvided;
    4076              :                 }
    4077              :             }
    4078              : 
    4079              :             // If SpaceHVAC is active and this equipment has a space splitter, distribute the equipment output and update the spaces
    4080     50729546 :             if (state.dataHeatBal->doSpaceHeatBalanceSimulation && !state.dataGlobal->DoingSizing &&
    4081        44904 :                 zoneEquipList.zoneEquipSplitterIndex(EquipPtr) > -1) {
    4082         8928 :                 state.dataZoneEquip->zoneEquipSplitter[zoneEquipList.zoneEquipSplitterIndex(EquipPtr)].distributeOutput(
    4083              :                     state, ControlledZoneNum, SysOutputProvided, LatOutputProvided, NonAirSysOutput, EquipTypeNum);
    4084              :             } else {
    4085     50675714 :                 thisZoneHB.NonAirSystemResponse += NonAirSysOutput;
    4086              :             }
    4087              :             // Space HVAC TODO: For now, update both spaces and zone, but maybe ultimately update one or the other
    4088    101369284 :             updateSystemOutputRequired(state,
    4089              :                                        ControlledZoneNum,
    4090              :                                        SysOutputProvided,
    4091              :                                        LatOutputProvided,
    4092     50684642 :                                        state.dataZoneEnergyDemand->ZoneSysEnergyDemand(ControlledZoneNum),
    4093     50684642 :                                        state.dataZoneEnergyDemand->ZoneSysMoistureDemand(ControlledZoneNum),
    4094              :                                        EquipTypeNum);
    4095              : 
    4096     50684642 :             state.dataSize->CurTermUnitSizingNum = 0;
    4097              :         } // zone equipment loop
    4098              :     } // End of controlled zone loop
    4099              : 
    4100              :     // If SpaceHVAC is active calculate SpaceHVAC:EquipmentMixer inlet flow rates after simulating zone equipment
    4101      6543197 :     if (state.dataHeatBal->doSpaceHeatBalanceSimulation && !state.dataGlobal->DoingSizing) {
    4102        12552 :         for (auto &thisSpaceHVACMixer : state.dataZoneEquip->zoneEquipMixer) {
    4103         4464 :             thisSpaceHVACMixer.setInletFlows(state);
    4104         8088 :         }
    4105              :     }
    4106              : 
    4107      6543197 :     state.dataSize->CurZoneEqNum = 0;
    4108      6543197 :     state.dataZoneEquipmentManager->FirstPassZoneEquipFlag = false;
    4109              : 
    4110              :     // This is the call to the Supply Air Path after the components are simulated to update
    4111              :     //  the path inlets
    4112              : 
    4113              :     // Process supply air path components in reverse order
    4114     18312030 :     for (int SupplyAirPathNum = 1; SupplyAirPathNum <= state.dataZoneEquip->NumSupplyAirPaths; ++SupplyAirPathNum) {
    4115              : 
    4116     11768833 :         SupPathInletChanged = false;
    4117              : 
    4118     23573100 :         for (int CompNum = state.dataZoneEquip->SupplyAirPath(SupplyAirPathNum).NumOfComponents; CompNum >= 1; --CompNum) {
    4119     11804267 :             switch (state.dataZoneEquip->SupplyAirPath(SupplyAirPathNum).ComponentTypeEnum(CompNum)) {
    4120     11765149 :             case DataZoneEquipment::AirLoopHVACZone::Splitter: { // 'AirLoopHVAC:ZoneSplitter'
    4121     11765149 :                 if (!(state.afn->AirflowNetworkFanActivated && state.afn->distribution_simulated)) {
    4122     11565566 :                     SplitterComponent::SimAirLoopSplitter(state,
    4123     11565566 :                                                           state.dataZoneEquip->SupplyAirPath(SupplyAirPathNum).ComponentName(CompNum),
    4124              :                                                           FirstHVACIteration,
    4125              :                                                           FirstCall,
    4126              :                                                           SupPathInletChanged,
    4127     11565566 :                                                           state.dataZoneEquip->SupplyAirPath(SupplyAirPathNum).ComponentIndex(CompNum));
    4128              :                 }
    4129     11765149 :             } break;
    4130        39118 :             case DataZoneEquipment::AirLoopHVACZone::SupplyPlenum: { // 'AirLoopHVAC:SupplyPlenum'
    4131        78236 :                 ZonePlenum::SimAirZonePlenum(state,
    4132        39118 :                                              state.dataZoneEquip->SupplyAirPath(SupplyAirPathNum).ComponentName(CompNum),
    4133              :                                              DataZoneEquipment::AirLoopHVACZone::SupplyPlenum,
    4134        39118 :                                              state.dataZoneEquip->SupplyAirPath(SupplyAirPathNum).ComponentIndex(CompNum),
    4135              :                                              FirstHVACIteration,
    4136              :                                              FirstCall,
    4137              :                                              SupPathInletChanged);
    4138              : 
    4139        39118 :             } break;
    4140            0 :             default: {
    4141            0 :                 ShowSevereError(state, format("Error found in Supply Air Path={}", state.dataZoneEquip->SupplyAirPath(SupplyAirPathNum).Name));
    4142            0 :                 ShowContinueError(
    4143              :                     state,
    4144            0 :                     format("Invalid Supply Air Path Component={}", state.dataZoneEquip->SupplyAirPath(SupplyAirPathNum).ComponentType(CompNum)));
    4145            0 :                 ShowFatalError(state, "Preceding condition causes termination.");
    4146            0 :             } break;
    4147              :             }
    4148              :         }
    4149              : 
    4150     11768833 :         if (SupPathInletChanged) {
    4151              :             // If the supply air path inlet conditions have been changed, the Air Loop must be resimulated
    4152      2166263 :             SimAir = true;
    4153              :         }
    4154              : 
    4155              :     } // end of the Supply Air Path DO Loop
    4156              : 
    4157      6543197 :     ExhaustAirSystemManager::SimZoneHVACExhaustControls(state);
    4158              : 
    4159      6543197 :     ExhaustAirSystemManager::SimExhaustAirSystem(state, FirstHVACIteration);
    4160              : 
    4161      6543197 :     CalcZoneMassBalance(state, FirstHVACIteration);
    4162              : 
    4163      6543197 :     CalcZoneLeavingConditions(state, FirstHVACIteration);
    4164              : 
    4165      6543197 :     ReturnAirPathManager::SimReturnAirPath(state);
    4166      6543197 : }
    4167              : 
    4168     97606322 : void SetZoneEquipSimOrder(EnergyPlusData &state, int const ControlledZoneNum)
    4169              : {
    4170              : 
    4171              :     // SUBROUTINE INFORMATION:
    4172              :     //       AUTHOR         Russ Taylor
    4173              :     //       DATE WRITTEN   May 1997
    4174              : 
    4175              :     // PURPOSE OF THIS SUBROUTINE:
    4176              :     // Set simulation priorities based on user specified priorities and
    4177              :     // required conditions (heating or cooling).
    4178              : 
    4179              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    4180     97606322 :     auto &zeq(state.dataZoneEquip->ZoneEquipList(ControlledZoneNum));
    4181     97606322 :     int const NumOfEquipTypes(zeq.NumOfEquipTypes);
    4182    210150918 :     for (int EquipTypeNum = 1; EquipTypeNum <= NumOfEquipTypes; ++EquipTypeNum) {
    4183    112544596 :         auto &pso(state.dataZoneEquipmentManager->PrioritySimOrder(EquipTypeNum));
    4184    112544596 :         pso.EquipTypeName = zeq.EquipTypeName(EquipTypeNum);
    4185    112544596 :         pso.EquipName = zeq.EquipName(EquipTypeNum);
    4186    112544596 :         pso.equipType = zeq.EquipType(EquipTypeNum);
    4187    112544596 :         pso.CoolingPriority = zeq.CoolingPriority(EquipTypeNum);
    4188    112544596 :         pso.HeatingPriority = zeq.HeatingPriority(EquipTypeNum);
    4189    112544596 :         pso.EquipPtr = EquipTypeNum;
    4190              :     }
    4191     97606322 :     for (int EquipTypeNum = NumOfEquipTypes + 1, EquipTypeNum_end = state.dataZoneEquipmentManager->PrioritySimOrder.u();
    4192    144214169 :          EquipTypeNum <= EquipTypeNum_end;
    4193              :          ++EquipTypeNum) { // Reset unused upper array portion
    4194     46607847 :         auto &pso(state.dataZoneEquipmentManager->PrioritySimOrder(EquipTypeNum));
    4195     46607847 :         pso.EquipTypeName.clear();
    4196     46607847 :         pso.EquipName.clear();
    4197     46607847 :         pso.equipType = DataZoneEquipment::ZoneEquipType::Invalid;
    4198     46607847 :         pso.EquipPtr = 0;
    4199              :     }
    4200              : 
    4201    210150918 :     for (int EquipTypeNum = 1; EquipTypeNum <= NumOfEquipTypes; ++EquipTypeNum) {
    4202    112544596 :         auto &pso(state.dataZoneEquipmentManager->PrioritySimOrder(EquipTypeNum));
    4203              : 
    4204    112544596 :         int CurEqHeatingPriority = pso.HeatingPriority;
    4205    112544596 :         int CurEqCoolingPriority = pso.CoolingPriority;
    4206              : 
    4207    241744159 :         for (int ComparedEquipTypeNum = EquipTypeNum; ComparedEquipTypeNum <= NumOfEquipTypes; ++ComparedEquipTypeNum) {
    4208    129199563 :             auto &psc(state.dataZoneEquipmentManager->PrioritySimOrder(ComparedEquipTypeNum));
    4209              : 
    4210    259352041 :             if ((CurEqCoolingPriority > psc.CoolingPriority &&
    4211    257831562 :                  state.dataZoneEnergyDemand->ZoneSysEnergyDemand(ControlledZoneNum).RemainingOutputRequired < 0.0) ||
    4212    128631999 :                 (CurEqHeatingPriority > psc.HeatingPriority &&
    4213      1518648 :                  state.dataZoneEnergyDemand->ZoneSysEnergyDemand(ControlledZoneNum).RemainingOutputRequired >= 0.0)) {
    4214              : 
    4215              :                 // Tuned C++ string swap avoids copying
    4216      1514930 :                 pso.EquipTypeName.swap(psc.EquipTypeName);
    4217      1514930 :                 pso.EquipName.swap(psc.EquipName);
    4218      1514930 :                 std::swap(pso.EquipPtr, psc.EquipPtr);
    4219      1514930 :                 std::swap(pso.equipType, psc.equipType);
    4220      1514930 :                 std::swap(pso.CoolingPriority, psc.CoolingPriority);
    4221      1514930 :                 std::swap(pso.HeatingPriority, psc.HeatingPriority);
    4222              : 
    4223      1514930 :                 CurEqCoolingPriority = pso.CoolingPriority;
    4224      1514930 :                 CurEqHeatingPriority = pso.HeatingPriority;
    4225              :             }
    4226              :         }
    4227              :     }
    4228     97606322 : }
    4229              : 
    4230     97606322 : void InitSystemOutputRequired(EnergyPlusData &state, int const ZoneNum, bool const FirstHVACIteration, bool const ResetSimOrder)
    4231              : {
    4232              : 
    4233              :     // SUBROUTINE INFORMATION:
    4234              :     //       AUTHOR         Russ Taylor
    4235              :     //       DATE WRITTEN   May 1997
    4236              :     //       MODIFIED       Don Shirey, Aug 2009 (latent/moisture additions)
    4237              : 
    4238              :     // PURPOSE OF THIS SUBROUTINE:
    4239              :     // Initialize remaining output required variables
    4240              : 
    4241              :     // METHODOLOGY EMPLOYED:
    4242              :     // Initialize remaining output variables using predictor calculations
    4243    195212644 :     initOutputRequired(state,
    4244              :                        ZoneNum,
    4245     97606322 :                        state.dataZoneEnergyDemand->ZoneSysEnergyDemand(ZoneNum),
    4246     97606322 :                        state.dataZoneEnergyDemand->ZoneSysMoistureDemand(ZoneNum),
    4247              :                        FirstHVACIteration,
    4248              :                        ResetSimOrder);
    4249              :     // SpaceHB TODO: This may need more work
    4250     97606322 :     if (state.dataHeatBal->doSpaceHeatBalance) {
    4251       282792 :         for (int spaceNum : state.dataHeatBal->Zone(ZoneNum).spaceIndexes) {
    4252       333664 :             initOutputRequired(state,
    4253              :                                ZoneNum,
    4254       166832 :                                state.dataZoneEnergyDemand->spaceSysEnergyDemand(spaceNum),
    4255       166832 :                                state.dataZoneEnergyDemand->spaceSysMoistureDemand(spaceNum),
    4256              :                                FirstHVACIteration,
    4257              :                                ResetSimOrder,
    4258              :                                spaceNum);
    4259       115960 :         }
    4260              :     }
    4261              : 
    4262     97606322 :     DistributeSystemOutputRequired(state, ZoneNum, FirstHVACIteration);
    4263     97606322 : }
    4264              : 
    4265    107381850 : void initOutputRequired(EnergyPlusData &state,
    4266              :                         int const ZoneNum,
    4267              :                         DataZoneEnergyDemands::ZoneSystemSensibleDemand &energy,
    4268              :                         DataZoneEnergyDemands::ZoneSystemMoistureDemand &moisture,
    4269              :                         bool const FirstHVACIteration,
    4270              :                         bool const ResetSimOrder,
    4271              :                         int spaceNum)
    4272              : {
    4273    107381850 :     energy.RemainingOutputRequired = energy.TotalOutputRequired;
    4274    107381850 :     energy.UnadjRemainingOutputRequired = energy.TotalOutputRequired;
    4275    107381850 :     energy.RemainingOutputReqToHeatSP = energy.OutputRequiredToHeatingSP;
    4276    107381850 :     energy.UnadjRemainingOutputReqToHeatSP = energy.OutputRequiredToHeatingSP;
    4277    107381850 :     energy.RemainingOutputReqToCoolSP = energy.OutputRequiredToCoolingSP;
    4278    107381850 :     energy.UnadjRemainingOutputReqToCoolSP = energy.OutputRequiredToCoolingSP;
    4279              : 
    4280    107381850 :     moisture.RemainingOutputRequired = moisture.TotalOutputRequired;
    4281    107381850 :     moisture.UnadjRemainingOutputRequired = moisture.TotalOutputRequired;
    4282    107381850 :     moisture.RemainingOutputReqToHumidSP = moisture.OutputRequiredToHumidifyingSP;
    4283    107381850 :     moisture.UnadjRemainingOutputReqToHumidSP = moisture.OutputRequiredToHumidifyingSP;
    4284    107381850 :     moisture.RemainingOutputReqToDehumidSP = moisture.OutputRequiredToDehumidifyingSP;
    4285    107381850 :     moisture.UnadjRemainingOutputReqToDehumidSP = moisture.OutputRequiredToDehumidifyingSP;
    4286              : 
    4287    107381850 :     if (ResetSimOrder && spaceNum == 0) {
    4288     97606322 :         SetZoneEquipSimOrder(state, ZoneNum);
    4289              :     }
    4290              : 
    4291              :     // If one sequenced load is allocated, then all have been allocated in InitZoneEquipment
    4292    107381850 :     if (allocated(energy.SequencedOutputRequired)) {
    4293              :         // Check if controlled first, because if it's not, there is no zone equipment list
    4294    107381850 :         if (!state.dataHeatBal->Zone(ZoneNum).IsControlled || state.dataGlobal->ZoneSizingCalc) {
    4295              :             // init each sequenced demand to the full output
    4296     19216252 :             energy.SequencedOutputRequired = energy.TotalOutputRequired;                            // array assignment
    4297     19216252 :             energy.SequencedOutputRequiredToHeatingSP = energy.OutputRequiredToHeatingSP;           // array assignment
    4298     19216252 :             energy.SequencedOutputRequiredToCoolingSP = energy.OutputRequiredToCoolingSP;           // array assignment
    4299              :                                                                                                     // init each sequenced demand to the full output
    4300     19216252 :             moisture.SequencedOutputRequired = moisture.TotalOutputRequired;                        // array assignment
    4301     19216252 :             moisture.SequencedOutputRequiredToHumidSP = moisture.OutputRequiredToHumidifyingSP;     // array assignment
    4302     19216252 :             moisture.SequencedOutputRequiredToDehumidSP = moisture.OutputRequiredToDehumidifyingSP; // array assignment
    4303     88165598 :         } else if (FirstHVACIteration) {
    4304     35224967 :             DataZoneEquipment::LoadDist loadDistType = state.dataZoneEquip->ZoneEquipList(ZoneNum).LoadDistScheme;
    4305     35224967 :             if ((loadDistType == DataZoneEquipment::LoadDist::Sequential) || (loadDistType == DataZoneEquipment::LoadDist::Uniform)) {
    4306              :                 // init each sequenced demand to the full output
    4307     35209347 :                 energy.SequencedOutputRequired = energy.TotalOutputRequired;                        // array assignment
    4308     35209347 :                 energy.SequencedOutputRequiredToHeatingSP = energy.OutputRequiredToHeatingSP;       // array assignment
    4309     35209347 :                 energy.SequencedOutputRequiredToCoolingSP = energy.OutputRequiredToCoolingSP;       // array assignment
    4310              :                                                                                                     // init each sequenced demand to the full output
    4311     35209347 :                 moisture.SequencedOutputRequired = moisture.TotalOutputRequired;                    // array assignment
    4312     35209347 :                 moisture.SequencedOutputRequiredToHumidSP = moisture.OutputRequiredToHumidifyingSP; // array assignment
    4313     35209347 :                 moisture.SequencedOutputRequiredToDehumidSP = moisture.OutputRequiredToDehumidifyingSP; // array assignment
    4314        15620 :             } else if ((loadDistType == DataZoneEquipment::LoadDist::UniformPLR) ||
    4315              :                        (loadDistType == DataZoneEquipment::LoadDist::SequentialUniformPLR)) {
    4316              :                 // init each sequenced demand to the zone design load in order to get available capacities from equipment
    4317              :                 // SpaceHB TODO: This may need more work
    4318        15620 :                 if (energy.TotalOutputRequired >= 0.0) {
    4319         5400 :                     energy.SequencedOutputRequired = state.dataSize->FinalZoneSizing(ZoneNum).DesHeatLoad; // array assignment
    4320              :                 } else {
    4321        10220 :                     energy.SequencedOutputRequired = -state.dataSize->FinalZoneSizing(ZoneNum).DesCoolLoad; // array assignment
    4322              :                 }
    4323        15620 :                 if (energy.TotalOutputRequired >= 0.0) {
    4324         5400 :                     energy.SequencedOutputRequiredToHeatingSP = state.dataSize->FinalZoneSizing(ZoneNum).DesHeatLoad; // array assignment
    4325              :                 } else {
    4326        10220 :                     energy.SequencedOutputRequiredToHeatingSP = -state.dataSize->FinalZoneSizing(ZoneNum).DesCoolLoad; // array assignment
    4327              :                 }
    4328        15620 :                 if (energy.TotalOutputRequired >= 0.0) {
    4329         5400 :                     energy.SequencedOutputRequiredToCoolingSP = state.dataSize->FinalZoneSizing(ZoneNum).DesHeatLoad; // array assignment
    4330              :                 } else {
    4331        10220 :                     energy.SequencedOutputRequiredToCoolingSP = -state.dataSize->FinalZoneSizing(ZoneNum).DesCoolLoad; // array assignment
    4332              :                 }
    4333              :                 // init each sequenced moisture demand to the full output
    4334        15620 :                 moisture.SequencedOutputRequired = moisture.TotalOutputRequired;                        // array assignment
    4335        15620 :                 moisture.SequencedOutputRequiredToHumidSP = moisture.OutputRequiredToHumidifyingSP;     // array assignment
    4336        15620 :                 moisture.SequencedOutputRequiredToDehumidSP = moisture.OutputRequiredToDehumidifyingSP; // array assignment
    4337              :             }
    4338              :         } else {
    4339              :             // init first sequenced sensible demand to the full output
    4340     52940631 :             energy.SequencedOutputRequired(1) = energy.TotalOutputRequired;
    4341     52940631 :             energy.SequencedOutputRequiredToHeatingSP(1) = energy.OutputRequiredToHeatingSP;
    4342     52940631 :             energy.SequencedOutputRequiredToCoolingSP(1) = energy.OutputRequiredToCoolingSP;
    4343              :             // init first sequenced moisture demand to the full output
    4344     52940631 :             moisture.SequencedOutputRequired(1) = moisture.TotalOutputRequired;
    4345     52940631 :             moisture.SequencedOutputRequiredToHumidSP(1) = moisture.OutputRequiredToHumidifyingSP;
    4346     52940631 :             moisture.SequencedOutputRequiredToDehumidSP(1) = moisture.OutputRequiredToDehumidifyingSP;
    4347              :         }
    4348              :     }
    4349              : 
    4350    107381850 :     state.dataZoneEnergyDemand->CurDeadBandOrSetback(ZoneNum) = state.dataZoneEnergyDemand->DeadBandOrSetback(ZoneNum);
    4351    107381850 : }
    4352              : 
    4353     97606322 : void DistributeSystemOutputRequired(EnergyPlusData &state, int const ZoneNum, bool const FirstHVACIteration)
    4354              : {
    4355              :     // Distribute zone equipment loads according to load distribution scheme
    4356              : 
    4357              :     // Do nothing if this zone is uncontrolled or doing zone sizing
    4358     97606322 :     if (!state.dataHeatBal->Zone(ZoneNum).IsControlled) {
    4359            0 :         return;
    4360              :     }
    4361     97606322 :     if (state.dataGlobal->ZoneSizingCalc) {
    4362      9557344 :         return;
    4363              :     }
    4364              : 
    4365              :     // Do nothing on FirstHVACIteration if not UniformLoading and not SequentialLoading
    4366    123214823 :     if (FirstHVACIteration && (state.dataZoneEquip->ZoneEquipList(ZoneNum).LoadDistScheme != DataZoneEquipment::LoadDist::Uniform) &&
    4367     35165845 :         (state.dataZoneEquip->ZoneEquipList(ZoneNum).LoadDistScheme != DataZoneEquipment::LoadDist::Sequential)) {
    4368        15620 :         return;
    4369              :     }
    4370              : 
    4371    176066716 :     distributeOutputRequired(
    4372    176066716 :         state, ZoneNum, state.dataZoneEnergyDemand->ZoneSysEnergyDemand(ZoneNum), state.dataZoneEnergyDemand->ZoneSysMoistureDemand(ZoneNum));
    4373              :     // SpaceHB TODO: This may need more work
    4374     88033358 :     if (state.dataHeatBal->doSpaceHeatBalance) {
    4375       197520 :         for (int spaceNum : state.dataHeatBal->Zone(ZoneNum).spaceIndexes) {
    4376       233240 :             distributeOutputRequired(state,
    4377              :                                      ZoneNum,
    4378       116620 :                                      state.dataZoneEnergyDemand->spaceSysEnergyDemand(spaceNum),
    4379       116620 :                                      state.dataZoneEnergyDemand->spaceSysMoistureDemand(spaceNum));
    4380        80900 :         }
    4381              :     }
    4382              : }
    4383              : 
    4384     88149978 : void distributeOutputRequired(EnergyPlusData &state,
    4385              :                               int const ZoneNum,
    4386              :                               DataZoneEnergyDemands::ZoneSystemSensibleDemand &energy,
    4387              :                               DataZoneEnergyDemands::ZoneSystemMoistureDemand &moisture)
    4388              : {
    4389     88149978 :     auto &thisZEqList(state.dataZoneEquip->ZoneEquipList(ZoneNum));
    4390     88149978 :     Real64 heatLoadRatio = 1.0;
    4391     88149978 :     Real64 coolLoadRatio = 1.0;
    4392     88149978 :     Real64 availCap = 0.0;
    4393     88149978 :     Real64 plr = 1.0;
    4394     88149978 :     int numOperating = 0;
    4395              : 
    4396     88149978 :     switch (thisZEqList.LoadDistScheme) {
    4397     88080168 :     case DataZoneEquipment::LoadDist::Sequential:
    4398              :         // Nothing to do here for this case
    4399              :         {
    4400              :             // Set the load (with load fraction) for the first equipment in priority order
    4401     88080168 :             constexpr int priorityNum = 1;
    4402     88080168 :             const int &equipNum = state.dataZoneEquipmentManager->PrioritySimOrder(priorityNum).EquipPtr;
    4403              : 
    4404              :             // Determine whether we're heating or cooling and choose the appropriate fraction
    4405     88080168 :             heatLoadRatio = thisZEqList.SequentialHeatingFraction(state, equipNum);
    4406     88080168 :             coolLoadRatio = thisZEqList.SequentialCoolingFraction(state, equipNum);
    4407     88080168 :             const Real64 loadRatio = (energy.TotalOutputRequired >= 0.0) ? heatLoadRatio : coolLoadRatio;
    4408              : 
    4409              :             // Energy loads
    4410     88080168 :             energy.SequencedOutputRequired(priorityNum) = energy.TotalOutputRequired * loadRatio;
    4411     88080168 :             energy.SequencedOutputRequiredToHeatingSP(priorityNum) = energy.OutputRequiredToHeatingSP * loadRatio;
    4412     88080168 :             energy.SequencedOutputRequiredToCoolingSP(priorityNum) = energy.OutputRequiredToCoolingSP * loadRatio;
    4413     88080168 :             energy.RemainingOutputRequired = energy.SequencedOutputRequired(priorityNum);
    4414     88080168 :             energy.RemainingOutputReqToHeatSP = energy.SequencedOutputRequiredToHeatingSP(priorityNum);
    4415     88080168 :             energy.RemainingOutputReqToCoolSP = energy.SequencedOutputRequiredToCoolingSP(priorityNum);
    4416              : 
    4417              :             // Moisture loads
    4418     88080168 :             moisture.SequencedOutputRequired(priorityNum) = moisture.TotalOutputRequired * loadRatio;
    4419     88080168 :             moisture.SequencedOutputRequiredToHumidSP(priorityNum) = moisture.OutputRequiredToHumidifyingSP * loadRatio;
    4420     88080168 :             moisture.SequencedOutputRequiredToDehumidSP(priorityNum) = moisture.OutputRequiredToDehumidifyingSP * loadRatio;
    4421     88080168 :             moisture.RemainingOutputRequired = moisture.SequencedOutputRequired(priorityNum);
    4422     88080168 :             moisture.RemainingOutputReqToHumidSP = moisture.SequencedOutputRequiredToHumidSP(priorityNum);
    4423     88080168 :             moisture.RemainingOutputReqToDehumidSP = moisture.SequencedOutputRequiredToDehumidSP(priorityNum);
    4424              : 
    4425     88080168 :             break;
    4426              :         }
    4427        15602 :     case DataZoneEquipment::LoadDist::Uniform:
    4428              :         // Distribute load uniformly across all active equipment
    4429        15602 :         if (thisZEqList.NumAvailHeatEquip > 0) {
    4430        15602 :             heatLoadRatio = 1.0 / thisZEqList.NumAvailHeatEquip;
    4431              :         } else {
    4432            0 :             heatLoadRatio = 1.0;
    4433              :         }
    4434        15602 :         if (thisZEqList.NumAvailCoolEquip > 0) {
    4435        15602 :             coolLoadRatio = 1.0 / thisZEqList.NumAvailCoolEquip;
    4436              :         } else {
    4437            0 :             coolLoadRatio = 1.0;
    4438              :         }
    4439        46806 :         for (int equipNum = 1.0; equipNum <= thisZEqList.NumOfEquipTypes; ++equipNum) {
    4440        31204 :             if (energy.TotalOutputRequired >= 0.0) {
    4441        10772 :                 if (thisZEqList.HeatingPriority(equipNum) > 0) {
    4442        10772 :                     energy.SequencedOutputRequired(equipNum) = energy.TotalOutputRequired * heatLoadRatio;
    4443        10772 :                     energy.SequencedOutputRequiredToHeatingSP(equipNum) = energy.OutputRequiredToHeatingSP * heatLoadRatio;
    4444        10772 :                     energy.SequencedOutputRequiredToCoolingSP(equipNum) = energy.OutputRequiredToCoolingSP * heatLoadRatio;
    4445        10772 :                     moisture.SequencedOutputRequired(equipNum) = moisture.TotalOutputRequired * heatLoadRatio;
    4446        10772 :                     moisture.SequencedOutputRequiredToHumidSP(equipNum) = moisture.OutputRequiredToHumidifyingSP * heatLoadRatio;
    4447        10772 :                     moisture.SequencedOutputRequiredToDehumidSP(equipNum) = moisture.OutputRequiredToDehumidifyingSP * heatLoadRatio;
    4448              :                 } else {
    4449            0 :                     energy.SequencedOutputRequired(equipNum) = 0.0;
    4450            0 :                     energy.SequencedOutputRequiredToHeatingSP(equipNum) = 0.0;
    4451            0 :                     energy.SequencedOutputRequiredToCoolingSP(equipNum) = 0.0;
    4452            0 :                     moisture.SequencedOutputRequired(equipNum) = 0.0;
    4453            0 :                     moisture.SequencedOutputRequiredToHumidSP(equipNum) = 0.0;
    4454            0 :                     moisture.SequencedOutputRequiredToDehumidSP(equipNum) = 0.0;
    4455              :                 }
    4456              :             } else {
    4457        20432 :                 if (thisZEqList.CoolingPriority(equipNum) > 0) {
    4458        20432 :                     energy.SequencedOutputRequired(equipNum) = energy.TotalOutputRequired * coolLoadRatio;
    4459        20432 :                     energy.SequencedOutputRequiredToHeatingSP(equipNum) = energy.OutputRequiredToHeatingSP * coolLoadRatio;
    4460        20432 :                     energy.SequencedOutputRequiredToCoolingSP(equipNum) = energy.OutputRequiredToCoolingSP * coolLoadRatio;
    4461        20432 :                     moisture.SequencedOutputRequired(equipNum) = moisture.TotalOutputRequired * coolLoadRatio;
    4462        20432 :                     moisture.SequencedOutputRequiredToHumidSP(equipNum) = moisture.OutputRequiredToHumidifyingSP * coolLoadRatio;
    4463        20432 :                     moisture.SequencedOutputRequiredToDehumidSP(equipNum) = moisture.OutputRequiredToDehumidifyingSP * coolLoadRatio;
    4464              :                 } else {
    4465            0 :                     energy.SequencedOutputRequired(equipNum) = 0.0;
    4466            0 :                     energy.SequencedOutputRequiredToHeatingSP(equipNum) = 0.0;
    4467            0 :                     energy.SequencedOutputRequiredToCoolingSP(equipNum) = 0.0;
    4468            0 :                     moisture.SequencedOutputRequired(equipNum) = 0.0;
    4469            0 :                     moisture.SequencedOutputRequiredToHumidSP(equipNum) = 0.0;
    4470            0 :                     moisture.SequencedOutputRequiredToDehumidSP(equipNum) = 0.0;
    4471              :                 }
    4472              :             }
    4473              :         }
    4474        15602 :         break;
    4475        23208 :     case DataZoneEquipment::LoadDist::UniformPLR:
    4476              :         // Distribute load at uniform PLR across all active equipment
    4477        23208 :         if (energy.TotalOutputRequired >= 0.0) {
    4478        23670 :             for (int equipNum = 1.0; equipNum <= thisZEqList.NumOfEquipTypes; ++equipNum) {
    4479        15780 :                 if (thisZEqList.HeatingPriority(equipNum) > 0) {
    4480        15780 :                     availCap += thisZEqList.HeatingCapacity(equipNum);
    4481              :                 }
    4482              :             }
    4483         7890 :             if (availCap > 0.0) {
    4484         7856 :                 plr = energy.TotalOutputRequired / availCap;
    4485              :             } else {
    4486           34 :                 plr = 0.0;
    4487              :             }
    4488              :         } else {
    4489        45954 :             for (int equipNum = 1.0; equipNum <= thisZEqList.NumOfEquipTypes; ++equipNum) {
    4490        30636 :                 if (thisZEqList.CoolingPriority(equipNum) > 0) {
    4491        30636 :                     availCap += thisZEqList.CoolingCapacity(equipNum);
    4492              :                 }
    4493              :             }
    4494        15318 :             if (availCap < 0.0) {
    4495        15318 :                 plr = energy.TotalOutputRequired / availCap;
    4496              :             } else {
    4497            0 :                 plr = 0.0;
    4498              :             }
    4499              :         }
    4500        23208 :         if (plr <= 0.0) {
    4501          342 :             break; // Don't change anything
    4502              :         }
    4503        68598 :         for (int equipNum = 1.0; equipNum <= thisZEqList.NumOfEquipTypes; ++equipNum) {
    4504        45732 :             if (energy.TotalOutputRequired >= 0.0) {
    4505        15096 :                 if (thisZEqList.HeatingPriority(equipNum) > 0) {
    4506        15096 :                     energy.SequencedOutputRequired(equipNum) = thisZEqList.HeatingCapacity(equipNum) * plr;
    4507        15096 :                     energy.SequencedOutputRequiredToHeatingSP(equipNum) = thisZEqList.HeatingCapacity(equipNum) * plr;
    4508        15096 :                     energy.SequencedOutputRequiredToCoolingSP(equipNum) = thisZEqList.HeatingCapacity(equipNum) * plr;
    4509        15096 :                     if (energy.OutputRequiredToHeatingSP != 0.0) {
    4510        30192 :                         moisture.SequencedOutputRequired(equipNum) =
    4511        15096 :                             moisture.TotalOutputRequired * (thisZEqList.HeatingCapacity(equipNum) * plr) / energy.OutputRequiredToHeatingSP;
    4512        15096 :                         moisture.SequencedOutputRequiredToHumidSP(equipNum) =
    4513        15096 :                             moisture.OutputRequiredToHumidifyingSP * (thisZEqList.HeatingCapacity(equipNum) * plr) / energy.OutputRequiredToHeatingSP;
    4514              :                     } else {
    4515            0 :                         moisture.SequencedOutputRequired(equipNum) = moisture.TotalOutputRequired * plr;
    4516            0 :                         moisture.SequencedOutputRequiredToHumidSP(equipNum) = moisture.OutputRequiredToHumidifyingSP * plr;
    4517              :                     }
    4518        15096 :                     moisture.SequencedOutputRequiredToDehumidSP(equipNum) = 0.0;
    4519              :                 } else {
    4520            0 :                     energy.SequencedOutputRequired(equipNum) = 0.0;
    4521            0 :                     energy.SequencedOutputRequiredToHeatingSP(equipNum) = 0.0;
    4522            0 :                     energy.SequencedOutputRequiredToCoolingSP(equipNum) = 0.0;
    4523            0 :                     moisture.SequencedOutputRequired(equipNum) = 0.0;
    4524            0 :                     moisture.SequencedOutputRequiredToHumidSP(equipNum) = 0.0;
    4525            0 :                     moisture.SequencedOutputRequiredToDehumidSP(equipNum) = 0.0;
    4526              :                 }
    4527              :             } else {
    4528        30636 :                 if (thisZEqList.CoolingPriority(equipNum) > 0) {
    4529        30636 :                     energy.SequencedOutputRequired(equipNum) = thisZEqList.CoolingCapacity(equipNum) * plr;
    4530        30636 :                     energy.SequencedOutputRequiredToHeatingSP(equipNum) = thisZEqList.CoolingCapacity(equipNum) * plr;
    4531        30636 :                     energy.SequencedOutputRequiredToCoolingSP(equipNum) = thisZEqList.CoolingCapacity(equipNum) * plr;
    4532        30636 :                     if (energy.OutputRequiredToCoolingSP != 0.0) {
    4533        61272 :                         moisture.SequencedOutputRequired(equipNum) =
    4534        30636 :                             moisture.TotalOutputRequired * (thisZEqList.CoolingCapacity(equipNum) * plr) / energy.OutputRequiredToCoolingSP;
    4535        30636 :                         moisture.SequencedOutputRequiredToDehumidSP(equipNum) = moisture.OutputRequiredToDehumidifyingSP *
    4536        30636 :                                                                                 (thisZEqList.CoolingCapacity(equipNum) * plr) /
    4537        30636 :                                                                                 energy.OutputRequiredToCoolingSP;
    4538              :                     } else {
    4539            0 :                         moisture.SequencedOutputRequired(equipNum) = moisture.TotalOutputRequired * plr;
    4540            0 :                         moisture.SequencedOutputRequiredToDehumidSP(equipNum) = moisture.OutputRequiredToDehumidifyingSP * plr;
    4541              :                     }
    4542        30636 :                     moisture.SequencedOutputRequiredToHumidSP(equipNum) = 0.0;
    4543              :                 } else {
    4544            0 :                     energy.SequencedOutputRequired(equipNum) = 0.0;
    4545            0 :                     energy.SequencedOutputRequiredToHeatingSP(equipNum) = 0.0;
    4546            0 :                     energy.SequencedOutputRequiredToCoolingSP(equipNum) = 0.0;
    4547            0 :                     moisture.SequencedOutputRequired(equipNum) = 0.0;
    4548            0 :                     moisture.SequencedOutputRequiredToHumidSP(equipNum) = 0.0;
    4549            0 :                     moisture.SequencedOutputRequiredToDehumidSP(equipNum) = 0.0;
    4550              :                 }
    4551              :             }
    4552              :         }
    4553        22866 :         break;
    4554        31000 :     case DataZoneEquipment::LoadDist::SequentialUniformPLR:
    4555              :         // Determine how many pieces of equipment are required to meet the current load,
    4556              :         // then distribute load at uniform PLR across all active equipment
    4557        31000 :         if (energy.TotalOutputRequired >= 0.0) {
    4558              :             // For heating capacities and TotalOutputRequired are positive
    4559        31728 :             for (int equipNum = 1.0; equipNum <= thisZEqList.NumOfEquipTypes; ++equipNum) {
    4560        21152 :                 if ((thisZEqList.HeatingCapacity(equipNum) > 0.0) && (availCap < energy.TotalOutputRequired)) {
    4561        19176 :                     if (thisZEqList.HeatingPriority(equipNum) > 0) {
    4562        19176 :                         availCap += thisZEqList.HeatingCapacity(equipNum);
    4563              :                     }
    4564        19176 :                     ++numOperating;
    4565              :                 }
    4566              :             }
    4567        10576 :             if (availCap > 0.0) {
    4568        10064 :                 plr = energy.TotalOutputRequired / availCap;
    4569              :             } else {
    4570          512 :                 plr = 0.0;
    4571          512 :                 numOperating = 0;
    4572              :             }
    4573              :         } else {
    4574        61272 :             for (int equipNum = 1.0; equipNum <= thisZEqList.NumOfEquipTypes; ++equipNum) {
    4575              :                 // For cooling capacities and TotalOutputRequired are negative
    4576        40848 :                 if ((thisZEqList.CoolingCapacity(equipNum) < 0.0) && (availCap > energy.TotalOutputRequired)) {
    4577        26008 :                     if (thisZEqList.CoolingPriority(equipNum) > 0) {
    4578        26008 :                         availCap += thisZEqList.CoolingCapacity(equipNum);
    4579              :                     }
    4580        26008 :                     ++numOperating;
    4581              :                 }
    4582              :             }
    4583        20424 :             if (availCap < 0.0) {
    4584        20424 :                 plr = energy.TotalOutputRequired / availCap;
    4585              :             } else {
    4586            0 :                 plr = 0.0;
    4587            0 :                 numOperating = 0;
    4588              :             }
    4589              :         }
    4590        31000 :         if (plr <= 0.0) {
    4591          512 :             break; // Don't change anything
    4592              :         }
    4593              :         // Set loads for operating equipment
    4594        75672 :         for (int equipNum = 1.0; equipNum <= numOperating; ++equipNum) {
    4595        45184 :             if (energy.TotalOutputRequired >= 0.0) {
    4596        19176 :                 if (thisZEqList.HeatingPriority(equipNum) > 0) {
    4597        19176 :                     energy.SequencedOutputRequired(equipNum) = thisZEqList.HeatingCapacity(equipNum) * plr;
    4598        19176 :                     energy.SequencedOutputRequiredToHeatingSP(equipNum) = thisZEqList.HeatingCapacity(equipNum) * plr;
    4599        19176 :                     energy.SequencedOutputRequiredToCoolingSP(equipNum) = thisZEqList.HeatingCapacity(equipNum) * plr;
    4600        19176 :                     if (energy.OutputRequiredToHeatingSP != 0.0) {
    4601        38352 :                         moisture.SequencedOutputRequired(equipNum) =
    4602        19176 :                             moisture.TotalOutputRequired * (thisZEqList.HeatingCapacity(equipNum) * plr) / energy.OutputRequiredToHeatingSP;
    4603        19176 :                         moisture.SequencedOutputRequiredToHumidSP(equipNum) =
    4604        19176 :                             moisture.OutputRequiredToHumidifyingSP * (thisZEqList.HeatingCapacity(equipNum) * plr) / energy.OutputRequiredToHeatingSP;
    4605              :                     } else {
    4606            0 :                         moisture.SequencedOutputRequired(equipNum) = moisture.TotalOutputRequired * plr;
    4607            0 :                         moisture.SequencedOutputRequiredToHumidSP(equipNum) = moisture.OutputRequiredToHumidifyingSP * plr;
    4608              :                     }
    4609        19176 :                     moisture.SequencedOutputRequiredToDehumidSP(equipNum) = 0.0;
    4610              :                 } else {
    4611            0 :                     energy.SequencedOutputRequired(equipNum) = 0.0;
    4612            0 :                     energy.SequencedOutputRequiredToHeatingSP(equipNum) = 0.0;
    4613            0 :                     energy.SequencedOutputRequiredToCoolingSP(equipNum) = 0.0;
    4614            0 :                     moisture.SequencedOutputRequired(equipNum) = 0.0;
    4615            0 :                     moisture.SequencedOutputRequiredToHumidSP(equipNum) = 0.0;
    4616            0 :                     moisture.SequencedOutputRequiredToDehumidSP(equipNum) = 0.0;
    4617              :                 }
    4618              :             } else {
    4619        26008 :                 if (thisZEqList.CoolingPriority(equipNum) > 0) {
    4620        26008 :                     energy.SequencedOutputRequired(equipNum) = thisZEqList.CoolingCapacity(equipNum) * plr;
    4621        26008 :                     energy.SequencedOutputRequiredToHeatingSP(equipNum) = thisZEqList.CoolingCapacity(equipNum) * plr;
    4622        26008 :                     energy.SequencedOutputRequiredToCoolingSP(equipNum) = thisZEqList.CoolingCapacity(equipNum) * plr;
    4623        26008 :                     if (energy.OutputRequiredToCoolingSP != 0.0) {
    4624        52016 :                         moisture.SequencedOutputRequired(equipNum) =
    4625        26008 :                             moisture.TotalOutputRequired * (thisZEqList.CoolingCapacity(equipNum) * plr) / energy.OutputRequiredToCoolingSP;
    4626        26008 :                         moisture.SequencedOutputRequiredToDehumidSP(equipNum) = moisture.OutputRequiredToDehumidifyingSP *
    4627        26008 :                                                                                 (thisZEqList.CoolingCapacity(equipNum) * plr) /
    4628        26008 :                                                                                 energy.OutputRequiredToCoolingSP;
    4629              :                     } else {
    4630            0 :                         moisture.SequencedOutputRequired(equipNum) = moisture.TotalOutputRequired * plr;
    4631            0 :                         moisture.SequencedOutputRequiredToDehumidSP(equipNum) = moisture.OutputRequiredToDehumidifyingSP * plr;
    4632              :                     }
    4633        26008 :                     moisture.SequencedOutputRequiredToHumidSP(equipNum) = 0.0;
    4634              :                 } else {
    4635            0 :                     energy.SequencedOutputRequired(equipNum) = 0.0;
    4636            0 :                     energy.SequencedOutputRequiredToHeatingSP(equipNum) = 0.0;
    4637            0 :                     energy.SequencedOutputRequiredToCoolingSP(equipNum) = 0.0;
    4638            0 :                     moisture.SequencedOutputRequired(equipNum) = 0.0;
    4639            0 :                     moisture.SequencedOutputRequiredToHumidSP(equipNum) = 0.0;
    4640            0 :                     moisture.SequencedOutputRequiredToDehumidSP(equipNum) = 0.0;
    4641              :                 }
    4642              :             }
    4643              :         }
    4644              :         // Set loads to zero for remaining equipment
    4645        46280 :         for (int equipNum = numOperating + 1; equipNum <= thisZEqList.NumOfEquipTypes; ++equipNum) {
    4646        15792 :             energy.SequencedOutputRequired(equipNum) = 0.0;
    4647        15792 :             energy.SequencedOutputRequiredToHeatingSP(equipNum) = 0.0;
    4648        15792 :             energy.SequencedOutputRequiredToCoolingSP(equipNum) = 0.0;
    4649        15792 :             moisture.SequencedOutputRequired(equipNum) = 0.0;
    4650        15792 :             moisture.SequencedOutputRequiredToHumidSP(equipNum) = 0.0;
    4651        15792 :             moisture.SequencedOutputRequiredToDehumidSP(equipNum) = 0.0;
    4652              :         }
    4653        30488 :         break;
    4654            0 :     default:
    4655            0 :         ShowFatalError(state, "DistributeSystemOutputRequired: Illegal load distribution scheme type.");
    4656            0 :         break;
    4657              :     }
    4658              :     // For every load distribution scheme except SequentialLoad
    4659              :     //  set the remaining loads to the first equipment type's load to support equipment types that don't use the sequenced loads
    4660     88149978 :     if (thisZEqList.LoadDistScheme != DataZoneEquipment::LoadDist::Sequential) {
    4661        69810 :         energy.RemainingOutputRequired = energy.SequencedOutputRequired(1);
    4662        69810 :         moisture.RemainingOutputRequired = moisture.SequencedOutputRequired(1);
    4663        69810 :         energy.RemainingOutputReqToHeatSP = energy.SequencedOutputRequiredToHeatingSP(1);
    4664        69810 :         moisture.RemainingOutputReqToHumidSP = moisture.SequencedOutputRequiredToHumidSP(1);
    4665        69810 :         energy.RemainingOutputReqToCoolSP = energy.SequencedOutputRequiredToCoolingSP(1);
    4666        69810 :         moisture.RemainingOutputReqToDehumidSP = moisture.SequencedOutputRequiredToDehumidSP(1);
    4667              :     }
    4668     88149978 : }
    4669              : 
    4670     60559438 : void updateSystemOutputRequired(EnergyPlusData &state,
    4671              :                                 int const ZoneNum,
    4672              :                                 Real64 const SysOutputProvided, // sensible output provided by zone equipment (W)
    4673              :                                 Real64 const LatOutputProvided, // latent output provided by zone equipment (kg/s)
    4674              :                                 DataZoneEnergyDemands::ZoneSystemSensibleDemand &energy,
    4675              :                                 DataZoneEnergyDemands::ZoneSystemMoistureDemand &moisture,
    4676              :                                 int const EquipPriorityNum // optional index in PrioritySimOrder for this update
    4677              : )
    4678              : {
    4679              : 
    4680              :     // SUBROUTINE INFORMATION:
    4681              :     //       AUTHOR         Russ Taylor
    4682              :     //       MODIFIED       B. Griffith Sept 2011, add storage of requirements by sequence
    4683              : 
    4684              :     // If zone is uncontrolled use original method for remaining output
    4685     60559438 :     if (!state.dataHeatBal->Zone(ZoneNum).IsControlled) {
    4686              :         // SequentialLoading, use original method for remaining output
    4687            0 :         energy.UnadjRemainingOutputRequired -= SysOutputProvided;
    4688            0 :         energy.RemainingOutputRequired = energy.UnadjRemainingOutputRequired;
    4689            0 :         energy.UnadjRemainingOutputReqToHeatSP -= SysOutputProvided;
    4690            0 :         energy.RemainingOutputReqToHeatSP = energy.UnadjRemainingOutputReqToHeatSP;
    4691            0 :         energy.UnadjRemainingOutputReqToCoolSP -= SysOutputProvided;
    4692            0 :         energy.RemainingOutputReqToCoolSP = energy.UnadjRemainingOutputReqToCoolSP;
    4693              :         // Latent output updates
    4694            0 :         moisture.UnadjRemainingOutputRequired -= LatOutputProvided;
    4695            0 :         moisture.RemainingOutputRequired = moisture.UnadjRemainingOutputRequired;
    4696            0 :         moisture.UnadjRemainingOutputReqToHumidSP -= LatOutputProvided;
    4697            0 :         moisture.RemainingOutputReqToHumidSP = moisture.UnadjRemainingOutputReqToHumidSP;
    4698            0 :         moisture.UnadjRemainingOutputReqToDehumidSP -= LatOutputProvided;
    4699            0 :         moisture.RemainingOutputReqToDehumidSP = moisture.UnadjRemainingOutputReqToDehumidSP;
    4700              : 
    4701              :         // re-evaluate if loads are now such that in dead band or set back
    4702            0 :         switch (state.dataHeatBalFanSys->TempControlType(ZoneNum)) {
    4703            0 :         case HVAC::SetptType::Uncontrolled: {
    4704              :             // uncontrolled zone; shouldn't ever get here, but who knows
    4705            0 :             state.dataZoneEnergyDemand->CurDeadBandOrSetback(ZoneNum) = false;
    4706            0 :         } break;
    4707              : 
    4708            0 :         case HVAC::SetptType::SingleHeat: {
    4709            0 :             state.dataZoneEnergyDemand->CurDeadBandOrSetback(ZoneNum) = ((energy.RemainingOutputRequired - 1.0) < 0.0);
    4710            0 :         } break;
    4711              : 
    4712            0 :         case HVAC::SetptType::SingleCool: {
    4713            0 :             state.dataZoneEnergyDemand->CurDeadBandOrSetback(ZoneNum) = ((energy.RemainingOutputRequired + 1.0) > 0.0);
    4714            0 :         } break;
    4715              : 
    4716            0 :         case HVAC::SetptType::SingleHeatCool: {
    4717            0 :             state.dataZoneEnergyDemand->CurDeadBandOrSetback(ZoneNum) =
    4718            0 :                 (energy.RemainingOutputReqToHeatSP < 0.0 && energy.RemainingOutputReqToCoolSP > 0.0);
    4719            0 :         } break;
    4720              : 
    4721            0 :         case HVAC::SetptType::DualHeatCool: {
    4722            0 :             state.dataZoneEnergyDemand->CurDeadBandOrSetback(ZoneNum) =
    4723            0 :                 (energy.RemainingOutputReqToHeatSP < 0.0 && energy.RemainingOutputReqToCoolSP > 0.0);
    4724            0 :         } break;
    4725              : 
    4726            0 :         default: {
    4727            0 :         } break;
    4728              :         } // swtich
    4729              : 
    4730            0 :         if (EquipPriorityNum > -1) {
    4731              :             // now store remaining load at the by sequence level
    4732            0 :             if (EquipPriorityNum + 1 <= energy.NumZoneEquipment) {
    4733            0 :                 energy.SequencedOutputRequired(EquipPriorityNum + 1) = energy.RemainingOutputRequired;
    4734            0 :                 moisture.SequencedOutputRequired(EquipPriorityNum + 1) = moisture.RemainingOutputRequired;
    4735              :             }
    4736              : 
    4737            0 :             if (state.dataZoneEquipmentManager->PrioritySimOrder(EquipPriorityNum).HeatingPriority + 1 <= energy.NumZoneEquipment) {
    4738            0 :                 energy.SequencedOutputRequiredToHeatingSP(state.dataZoneEquipmentManager->PrioritySimOrder(EquipPriorityNum).HeatingPriority + 1) =
    4739            0 :                     energy.RemainingOutputReqToHeatSP;
    4740            0 :                 moisture.SequencedOutputRequiredToHumidSP(state.dataZoneEquipmentManager->PrioritySimOrder(EquipPriorityNum).HeatingPriority + 1) =
    4741            0 :                     moisture.RemainingOutputReqToHumidSP;
    4742              :             }
    4743            0 :             if (state.dataZoneEquipmentManager->PrioritySimOrder(EquipPriorityNum).CoolingPriority + 1 <= energy.NumZoneEquipment) {
    4744            0 :                 energy.SequencedOutputRequiredToCoolingSP(state.dataZoneEquipmentManager->PrioritySimOrder(EquipPriorityNum).CoolingPriority + 1) =
    4745            0 :                     energy.RemainingOutputReqToCoolSP;
    4746            0 :                 moisture.SequencedOutputRequiredToDehumidSP(state.dataZoneEquipmentManager->PrioritySimOrder(EquipPriorityNum).CoolingPriority + 1) =
    4747            0 :                     moisture.RemainingOutputReqToDehumidSP;
    4748              :             }
    4749              :         }
    4750            0 :         return;
    4751              :     }
    4752              : 
    4753              :     // Sensible output updates
    4754     60559438 :     auto &thisZEqList(state.dataZoneEquip->ZoneEquipList(ZoneNum));
    4755     60559438 :     switch (thisZEqList.LoadDistScheme) {
    4756     60462269 :     case DataZoneEquipment::LoadDist::Sequential: {
    4757              :         // Subtract the system output from the unadjusted loads required
    4758     60462269 :         energy.UnadjRemainingOutputRequired -= SysOutputProvided;
    4759     60462269 :         energy.UnadjRemainingOutputReqToHeatSP -= SysOutputProvided;
    4760     60462269 :         energy.UnadjRemainingOutputReqToCoolSP -= SysOutputProvided;
    4761     60462269 :         moisture.UnadjRemainingOutputRequired -= LatOutputProvided;
    4762     60462269 :         moisture.UnadjRemainingOutputReqToHumidSP -= LatOutputProvided;
    4763     60462269 :         moisture.UnadjRemainingOutputReqToDehumidSP -= LatOutputProvided;
    4764              : 
    4765     60462269 :         if ((EquipPriorityNum > -1) && (EquipPriorityNum < thisZEqList.NumOfEquipTypes)) {
    4766              : 
    4767              :             // Look up the next system in priority order
    4768      6629576 :             int nextEquipPriorityNum = EquipPriorityNum + 1;
    4769      6629576 :             const int &nextSystem = state.dataZoneEquipmentManager->PrioritySimOrder(nextEquipPriorityNum).EquipPtr;
    4770              : 
    4771              :             // Determine the load ratio based on whether we're heating or cooling
    4772      6629576 :             const Real64 loadRatio = (energy.TotalOutputRequired >= 0.0) ? thisZEqList.SequentialHeatingFraction(state, nextSystem)
    4773      3064249 :                                                                          : thisZEqList.SequentialCoolingFraction(state, nextSystem);
    4774              : 
    4775              :             // Update the zone energy demands
    4776      6629576 :             energy.RemainingOutputRequired = loadRatio * energy.UnadjRemainingOutputRequired;
    4777      6629576 :             energy.RemainingOutputReqToHeatSP = loadRatio * energy.UnadjRemainingOutputReqToHeatSP;
    4778      6629576 :             energy.RemainingOutputReqToCoolSP = loadRatio * energy.UnadjRemainingOutputReqToCoolSP;
    4779      6629576 :             moisture.RemainingOutputRequired = loadRatio * moisture.UnadjRemainingOutputRequired;
    4780      6629576 :             moisture.RemainingOutputReqToHumidSP = loadRatio * moisture.UnadjRemainingOutputReqToHumidSP;
    4781      6629576 :             moisture.RemainingOutputReqToDehumidSP = loadRatio * moisture.UnadjRemainingOutputReqToDehumidSP;
    4782              : 
    4783              :             // now store remaining load at the sequence level
    4784      6629576 :             energy.SequencedOutputRequired(nextEquipPriorityNum) = energy.RemainingOutputRequired;
    4785      6629576 :             energy.SequencedOutputRequiredToHeatingSP(nextEquipPriorityNum) = energy.RemainingOutputReqToHeatSP;
    4786      6629576 :             energy.SequencedOutputRequiredToCoolingSP(nextEquipPriorityNum) = energy.RemainingOutputReqToCoolSP;
    4787      6629576 :             moisture.SequencedOutputRequired(nextEquipPriorityNum) = moisture.RemainingOutputRequired;
    4788      6629576 :             moisture.SequencedOutputRequiredToHumidSP(nextEquipPriorityNum) = moisture.RemainingOutputReqToHumidSP;
    4789      6629576 :             moisture.SequencedOutputRequiredToDehumidSP(nextEquipPriorityNum) = moisture.RemainingOutputReqToDehumidSP;
    4790      6629576 :         } else {
    4791              :             // SequentialLoading, use original method for remaining output
    4792     53832693 :             energy.RemainingOutputRequired = energy.UnadjRemainingOutputRequired;
    4793     53832693 :             energy.RemainingOutputReqToHeatSP = energy.UnadjRemainingOutputReqToHeatSP;
    4794     53832693 :             energy.RemainingOutputReqToCoolSP = energy.UnadjRemainingOutputReqToCoolSP;
    4795              :             // Latent output updates
    4796     53832693 :             moisture.RemainingOutputRequired = moisture.UnadjRemainingOutputRequired;
    4797     53832693 :             moisture.RemainingOutputReqToHumidSP = moisture.UnadjRemainingOutputReqToHumidSP;
    4798     53832693 :             moisture.RemainingOutputReqToDehumidSP = moisture.UnadjRemainingOutputReqToDehumidSP;
    4799              :         }
    4800              : 
    4801              :         // re-evaluate if loads are now such that in dead band or set back
    4802     60462269 :         switch (state.dataHeatBalFanSys->TempControlType(ZoneNum)) {
    4803       974160 :         case HVAC::SetptType::Uncontrolled: {
    4804              :             // uncontrolled zone; shouldn't ever get here, but who knows
    4805       974160 :             state.dataZoneEnergyDemand->CurDeadBandOrSetback(ZoneNum) = false;
    4806       974160 :         } break;
    4807              : 
    4808      4553602 :         case HVAC::SetptType::SingleHeat: {
    4809      4553602 :             state.dataZoneEnergyDemand->CurDeadBandOrSetback(ZoneNum) = ((energy.RemainingOutputRequired - 1.0) < 0.0);
    4810      4553602 :         } break;
    4811              : 
    4812      5542439 :         case HVAC::SetptType::SingleCool: {
    4813      5542439 :             state.dataZoneEnergyDemand->CurDeadBandOrSetback(ZoneNum) = ((energy.RemainingOutputRequired + 1.0) > 0.0);
    4814      5542439 :         } break;
    4815              : 
    4816       180550 :         case HVAC::SetptType::SingleHeatCool: {
    4817       180550 :             state.dataZoneEnergyDemand->CurDeadBandOrSetback(ZoneNum) =
    4818       180550 :                 (energy.RemainingOutputReqToHeatSP < 0.0 && energy.RemainingOutputReqToCoolSP > 0.0);
    4819       180550 :         } break;
    4820              : 
    4821     49211518 :         case HVAC::SetptType::DualHeatCool: {
    4822     49211518 :             state.dataZoneEnergyDemand->CurDeadBandOrSetback(ZoneNum) =
    4823     49211518 :                 (energy.RemainingOutputReqToHeatSP < 0.0 && energy.RemainingOutputReqToCoolSP > 0.0);
    4824     49211518 :         } break;
    4825              : 
    4826            0 :         default: {
    4827            0 :         } break;
    4828              : 
    4829              :         } // switch
    4830              : 
    4831     60462269 :     } break;
    4832        97169 :     case DataZoneEquipment::LoadDist::Uniform:
    4833              :     case DataZoneEquipment::LoadDist::UniformPLR:
    4834              :     case DataZoneEquipment::LoadDist::SequentialUniformPLR:
    4835              :         // For every load distribution scheme except SequentialLoad, do not touch the sequenced loads,
    4836              :         // but set the remaining loads to the next equipment type's load to support equipment types that don't use the sequenced loads
    4837        97169 :         if (EquipPriorityNum > -1) {
    4838        85430 :             if (EquipPriorityNum + 1 <= energy.NumZoneEquipment) {
    4839        42715 :                 energy.RemainingOutputRequired = energy.SequencedOutputRequired(EquipPriorityNum + 1);
    4840        42715 :                 moisture.RemainingOutputRequired = moisture.SequencedOutputRequired(EquipPriorityNum + 1);
    4841              :             }
    4842              : 
    4843        85430 :             if (state.dataZoneEquipmentManager->PrioritySimOrder(EquipPriorityNum).HeatingPriority + 1 <= energy.NumZoneEquipment) {
    4844        42715 :                 energy.RemainingOutputReqToHeatSP =
    4845        42715 :                     energy.SequencedOutputRequiredToHeatingSP(state.dataZoneEquipmentManager->PrioritySimOrder(EquipPriorityNum).HeatingPriority + 1);
    4846        42715 :                 moisture.RemainingOutputReqToHumidSP =
    4847        42715 :                     moisture.SequencedOutputRequiredToHumidSP(state.dataZoneEquipmentManager->PrioritySimOrder(EquipPriorityNum).HeatingPriority + 1);
    4848              :             }
    4849        85430 :             if (state.dataZoneEquipmentManager->PrioritySimOrder(EquipPriorityNum).CoolingPriority + 1 <= energy.NumZoneEquipment) {
    4850        42715 :                 energy.RemainingOutputReqToCoolSP =
    4851        42715 :                     energy.SequencedOutputRequiredToCoolingSP(state.dataZoneEquipmentManager->PrioritySimOrder(EquipPriorityNum).CoolingPriority + 1);
    4852        42715 :                 moisture.RemainingOutputReqToDehumidSP = moisture.SequencedOutputRequiredToDehumidSP(
    4853        42715 :                     state.dataZoneEquipmentManager->PrioritySimOrder(EquipPriorityNum).CoolingPriority + 1);
    4854              :             }
    4855              :         }
    4856        97169 :         break;
    4857            0 :     default:
    4858            0 :         ShowFatalError(state, "UpdateSystemOutputRequired: Illegal load distribution scheme type.");
    4859            0 :         break;
    4860              :     }
    4861              : }
    4862              : 
    4863         8928 : void adjustSystemOutputRequired(Real64 const sensibleRatio, // sensible load adjustment
    4864              :                                 Real64 const latentRatio,   // latent load adjustment
    4865              :                                 DataZoneEnergyDemands::ZoneSystemSensibleDemand &energy,
    4866              :                                 DataZoneEnergyDemands::ZoneSystemMoistureDemand &moisture,
    4867              :                                 int const equipPriorityNum // index in PrioritySimOrder
    4868              : )
    4869              : {
    4870              :     // Adjust the zone energy demands for space thermostat control
    4871         8928 :     energy.RemainingOutputRequired *= sensibleRatio;
    4872         8928 :     energy.RemainingOutputReqToHeatSP *= sensibleRatio;
    4873         8928 :     energy.RemainingOutputReqToCoolSP *= sensibleRatio;
    4874         8928 :     moisture.RemainingOutputRequired *= latentRatio;
    4875         8928 :     moisture.RemainingOutputReqToHumidSP *= latentRatio;
    4876         8928 :     moisture.RemainingOutputReqToDehumidSP *= latentRatio;
    4877              : 
    4878         8928 :     energy.SequencedOutputRequired(equipPriorityNum) *= sensibleRatio;
    4879         8928 :     energy.SequencedOutputRequiredToHeatingSP(equipPriorityNum) *= sensibleRatio;
    4880         8928 :     energy.SequencedOutputRequiredToCoolingSP(equipPriorityNum) *= sensibleRatio;
    4881         8928 :     moisture.SequencedOutputRequired(equipPriorityNum) *= latentRatio;
    4882         8928 :     moisture.SequencedOutputRequiredToHumidSP(equipPriorityNum) *= latentRatio;
    4883         8928 :     moisture.SequencedOutputRequiredToDehumidSP(equipPriorityNum) *= latentRatio;
    4884         8928 : }
    4885              : 
    4886      7587463 : void CalcZoneMassBalance(EnergyPlusData &state, bool const FirstHVACIteration)
    4887              : {
    4888              : 
    4889              :     // SUBROUTINE INFORMATION:
    4890              :     //       AUTHOR         Russ Taylor
    4891              :     //       DATE WRITTEN   May 1997
    4892              : 
    4893              :     // PURPOSE OF THIS SUBROUTINE:
    4894              :     // Perform zone mass balance to get outlet air flow conditions.
    4895              : 
    4896              :     // METHODOLOGY EMPLOYED:
    4897              :     // Mass continuity equation.
    4898              : 
    4899      7587463 :     int constexpr IterMax(25);
    4900      7587463 :     Real64 constexpr ConvergenceTolerance(0.000010);
    4901              : 
    4902      7587463 :     state.dataHVACGlobal->ZoneMassBalanceHVACReSim = false;
    4903      7587463 :     int Iteration = 0;
    4904      7587463 :     Real64 BuildingZoneMixingFlow = 0.0;
    4905      7587463 :     Real64 BuildingZoneMixingFlowOld = 0.0;
    4906      7587463 :     Real64 BuildingZoneReturnFlow = 0.0;
    4907      7587463 :     Real64 BuildingZoneReturnFlowOld = 0.0;
    4908              : 
    4909      7587463 :     auto &Node(state.dataLoopNodes->Node);
    4910              : 
    4911              :     // Total loop supply and recirc flows (these have been zeroed earlier in InitZoneEquipment
    4912     46255678 :     for (int airDistUnit = 1; airDistUnit <= (int)state.dataDefineEquipment->AirDistUnit.size(); ++airDistUnit) {
    4913     38668215 :         auto &airDisUnit = state.dataDefineEquipment->AirDistUnit(airDistUnit);
    4914     38668215 :         if (airDisUnit.AirLoopNum > 0) {
    4915     38539412 :             auto &airLoopFlow = state.dataAirLoop->AirLoopFlow(airDisUnit.AirLoopNum);
    4916     38539412 :             airLoopFlow.SupFlow += airDisUnit.MassFlowRateSup;
    4917     38539412 :             airLoopFlow.RecircFlow += airDisUnit.MassFlowRatePlenInd;
    4918     38539412 :             airLoopFlow.LeakFlow += airDisUnit.MassFlowRateDnStrLk + airDisUnit.MassFlowRateUpStrLk;
    4919              :         }
    4920              :     }
    4921              : 
    4922              :     // Set max OA flow and frac for systems which are all OA (no OASys)
    4923     19895297 :     for (int airLoop = 1; airLoop <= state.dataHVACGlobal->NumPrimaryAirSys; ++airLoop) {
    4924     12307834 :         if (state.dataAirSystemsData->PrimaryAirSystems(airLoop).isAllOA) {
    4925        15269 :             auto &airLoopFlow = state.dataAirLoop->AirLoopFlow(airLoop);
    4926        15269 :             airLoopFlow.MaxOutAir = airLoopFlow.SupFlow;
    4927        15269 :             airLoopFlow.OAFlow = airLoopFlow.SupFlow;
    4928        15269 :             airLoopFlow.OAFrac = 1.0;
    4929              :         }
    4930              :     }
    4931              : 
    4932              :     do {
    4933      7693168 :         if (state.dataHeatBal->ZoneAirMassFlow.EnforceZoneMassBalance) {
    4934              :             // These are also reset in ZoneEquipmentManager::InitZoneEquipment, reset again here for each zone mass balance iteration
    4935       190268 :             for (int airLoop = 1; airLoop <= state.dataHVACGlobal->NumPrimaryAirSys; ++airLoop) {
    4936        70767 :                 auto &airLoopFlow = state.dataAirLoop->AirLoopFlow(airLoop);
    4937        70767 :                 airLoopFlow.ZoneRetFlow = 0.0;
    4938        70767 :                 airLoopFlow.SysRetFlow = 0.0;
    4939        70767 :                 airLoopFlow.ExcessZoneExhFlow = 0.0;
    4940              :             }
    4941       836507 :             for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) {
    4942       717006 :                 if (!state.dataZoneEquip->ZoneEquipConfig(ZoneNum).IsControlled) {
    4943       119501 :                     continue;
    4944              :                 }
    4945       597505 :                 state.dataHeatBalFanSys->ZoneInfiltrationFlag(ZoneNum) = false;
    4946       597505 :                 state.dataHeatBal->MassConservation(ZoneNum).IncludeInfilToZoneMassBal = 0.0;
    4947       597505 :                 state.dataHeatBal->MassConservation(ZoneNum).RetMassFlowRate = 0.0;
    4948       597505 :                 state.dataZoneEquip->ZoneEquipConfig(ZoneNum).ExcessZoneExh = 0.0;
    4949       597505 :                 if (state.dataHeatBal->doSpaceHeatBalance) {
    4950            0 :                     for (int spaceNum : state.dataHeatBal->Zone(ZoneNum).spaceIndexes) {
    4951            0 :                         if (!state.dataZoneEquip->spaceEquipConfig(spaceNum).IsControlled) {
    4952            0 :                             continue;
    4953              :                         }
    4954            0 :                         state.dataZoneEquip->spaceEquipConfig(spaceNum).ExcessZoneExh = 0.0;
    4955            0 :                     }
    4956              :                 }
    4957              :             }
    4958              :         }
    4959      7693168 :         BuildingZoneMixingFlowOld = BuildingZoneMixingFlow;
    4960      7693168 :         BuildingZoneMixingFlow = 0.0;
    4961              : 
    4962      7693168 :         BuildingZoneReturnFlowOld = BuildingZoneReturnFlow;
    4963      7693168 :         BuildingZoneReturnFlow = 0.0;
    4964              : 
    4965     70209402 :         for (int ZoneNum1 = 1; ZoneNum1 <= state.dataGlobal->NumOfZones; ++ZoneNum1) {
    4966     62516234 :             int ZoneNum = ZoneNum1;
    4967     62516234 :             if (state.dataHeatBal->ZoneAirMassFlow.EnforceZoneMassBalance) {
    4968       717006 :                 ZoneNum = state.dataHeatBalFanSys->ZoneReOrder(ZoneNum1);
    4969              :             }
    4970     62516234 :             if (!state.dataZoneEquip->ZoneEquipConfig(ZoneNum).IsControlled) {
    4971      8403482 :                 continue;
    4972              :             }
    4973     54112752 :             auto &massConservation = state.dataHeatBal->MassConservation(ZoneNum);
    4974     54112752 :             auto &zoneEquipConfig = state.dataZoneEquip->ZoneEquipConfig(ZoneNum);
    4975     54112752 :             Real64 TotExhaustAirMassFlowRate = 0.0;
    4976              : 
    4977     54112752 :             zoneEquipConfig.TotExhaustAirMassFlowRate = 0.0;
    4978              : 
    4979     54112752 :             Real64 ZoneMixingAirMassFlowRate = 0.0;
    4980     54112752 :             Real64 ZoneMixingNetAirMassFlowRate = 0.0;
    4981     54112752 :             Real64 ZoneReturnAirMassFlowRate = 0.0;
    4982              : 
    4983              :             // SpaceHVAC TODO: For now, ZoneMassBalance happens at the zone level, not space
    4984     54112752 :             zoneEquipConfig.setTotalInletFlows(state);
    4985     54112752 :             Real64 TotInletAirMassFlowRate = zoneEquipConfig.TotInletAirMassFlowRate;
    4986     54112752 :             if (state.dataHeatBal->doSpaceHeatBalance) {
    4987       184032 :                 for (int spaceNum : state.dataHeatBal->Zone(ZoneNum).spaceIndexes) {
    4988       108522 :                     auto &spaceEquipConfig = state.dataZoneEquip->spaceEquipConfig(spaceNum);
    4989       108522 :                     if (spaceEquipConfig.IsControlled) {
    4990        24759 :                         spaceEquipConfig.setTotalInletFlows(state);
    4991              :                     } else {
    4992              :                         // If space is not controlled, allocate zone-level airflow by volume
    4993        83763 :                         auto &thisSpace = state.dataHeatBal->space(spaceNum);
    4994        83763 :                         Real64 spaceFrac = thisSpace.fracZoneVolume;
    4995        83763 :                         DataZoneEquipment::scaleInletFlows(state, zoneEquipConfig.ZoneNode, thisSpace.SystemZoneNodeNumber, spaceFrac);
    4996              :                     }
    4997        75510 :                 }
    4998              :             }
    4999              : 
    5000     64906092 :             for (int NodeNum = 1; NodeNum <= zoneEquipConfig.NumExhaustNodes; ++NodeNum) {
    5001              : 
    5002     10793340 :                 if (state.afn->AirflowNetworkNumOfExhFan == 0) {
    5003     10437075 :                     zoneEquipConfig.TotExhaustAirMassFlowRate += Node(zoneEquipConfig.ExhaustNode(NodeNum)).MassFlowRate;
    5004              :                 }
    5005              :             }
    5006     54112752 :             TotExhaustAirMassFlowRate = zoneEquipConfig.TotExhaustAirMassFlowRate;
    5007              : 
    5008              :             // Include zone mixing mass flow rate
    5009     54112752 :             if (state.dataHeatBalFanSys->ZoneMassBalanceFlag(ZoneNum)) {
    5010       597505 :                 int NumRetNodes = zoneEquipConfig.NumReturnNodes;
    5011      1195010 :                 for (int NodeNumHere = 1; NodeNumHere <= NumRetNodes; ++NodeNumHere) {
    5012       597505 :                     int RetNode = zoneEquipConfig.ReturnNode(NodeNumHere);
    5013       597505 :                     if (RetNode > 0) {
    5014       597505 :                         ZoneReturnAirMassFlowRate += Node(RetNode).MassFlowRate;
    5015              :                     }
    5016              :                 }
    5017              :                 // Set zone mixing incoming mass flow rate
    5018      1126030 :                 if ((Iteration == 0) || state.dataHeatBal->ZoneAirMassFlow.ZoneFlowAdjustment == DataHeatBalance::AdjustmentType::AdjustReturnOnly ||
    5019       528525 :                     state.dataHeatBal->ZoneAirMassFlow.ZoneFlowAdjustment == DataHeatBalance::AdjustmentType::AdjustReturnThenMixing) {
    5020        68980 :                     ZoneMixingAirMassFlowRate = state.dataZoneTempPredictorCorrector->zoneHeatBalance(ZoneNum).MixingMassFlowZone;
    5021              :                 } else {
    5022       528525 :                     ZoneMixingAirMassFlowRate = max(0.0,
    5023       528525 :                                                     ZoneReturnAirMassFlowRate + TotExhaustAirMassFlowRate - TotInletAirMassFlowRate +
    5024       528525 :                                                         massConservation.MixingSourceMassFlowRate);
    5025              :                 }
    5026       597505 :                 CalcZoneMixingFlowRateOfReceivingZone(state, ZoneNum, ZoneMixingAirMassFlowRate);
    5027       597505 :                 ZoneMixingNetAirMassFlowRate = massConservation.MixingMassFlowRate - massConservation.MixingSourceMassFlowRate;
    5028              :             }
    5029              : 
    5030              :             // Calculate standard return air flow rate using default method of inlets minus exhausts adjusted for "balanced" exhaust flow
    5031     54112752 :             Real64 StdTotalReturnMassFlow =
    5032     54112752 :                 TotInletAirMassFlowRate + ZoneMixingNetAirMassFlowRate - (TotExhaustAirMassFlowRate - zoneEquipConfig.ZoneExhBalanced);
    5033              : 
    5034     54112752 :             if (!state.dataHeatBal->ZoneAirMassFlow.EnforceZoneMassBalance) {
    5035     53515247 :                 if (StdTotalReturnMassFlow < 0.0) {
    5036       316645 :                     zoneEquipConfig.ExcessZoneExh = -StdTotalReturnMassFlow;
    5037       316645 :                     StdTotalReturnMassFlow = 0.0;
    5038              :                 } else {
    5039     53198602 :                     zoneEquipConfig.ExcessZoneExh = 0.0;
    5040              :                 }
    5041              :             } else {
    5042       597505 :                 zoneEquipConfig.ExcessZoneExh = 0.0;
    5043       597505 :                 StdTotalReturnMassFlow = max(0.0, StdTotalReturnMassFlow);
    5044              :             }
    5045              : 
    5046     54112752 :             Real64 FinalTotalReturnMassFlow = 0;
    5047     54112752 :             zoneEquipConfig.calcReturnFlows(state, StdTotalReturnMassFlow, FinalTotalReturnMassFlow);
    5048     54112752 :             if (state.dataHeatBal->ZoneAirMassFlow.EnforceZoneMassBalance) {
    5049              :                 // set mass conservation variables
    5050       597505 :                 massConservation.InMassFlowRate = TotInletAirMassFlowRate;
    5051       597505 :                 massConservation.ExhMassFlowRate = TotExhaustAirMassFlowRate;
    5052              : 
    5053       597505 :                 if (state.dataHeatBal->ZoneAirMassFlow.ZoneFlowAdjustment == DataHeatBalance::AdjustmentType::AdjustMixingOnly ||
    5054            0 :                     state.dataHeatBal->ZoneAirMassFlow.ZoneFlowAdjustment == DataHeatBalance::AdjustmentType::AdjustMixingThenReturn) {
    5055       597505 :                     massConservation.RetMassFlowRate = FinalTotalReturnMassFlow;
    5056       597505 :                     ZoneReturnAirMassFlowRate = FinalTotalReturnMassFlow;
    5057       597505 :                     if (state.dataHeatBal->ZoneAirMassFlow.ZoneFlowAdjustment == DataHeatBalance::AdjustmentType::AdjustMixingThenReturn) {
    5058              : 
    5059              :                         // Calculate return air flow rate using mass conservation equation
    5060              :                         Real64 AdjustedTotalReturnMassFlow =
    5061            0 :                             max(0.0, TotInletAirMassFlowRate - TotExhaustAirMassFlowRate + ZoneMixingNetAirMassFlowRate);
    5062            0 :                         if (!state.dataGlobal->DoingSizing) {
    5063            0 :                             AdjustedTotalReturnMassFlow = min(AdjustedTotalReturnMassFlow, zoneEquipConfig.AirLoopDesSupply);
    5064              :                         }
    5065              :                         // add adjust zone return node air flow calc
    5066            0 :                         zoneEquipConfig.calcReturnFlows(state, AdjustedTotalReturnMassFlow, FinalTotalReturnMassFlow);
    5067            0 :                         massConservation.RetMassFlowRate = FinalTotalReturnMassFlow;
    5068            0 :                         ZoneReturnAirMassFlowRate = FinalTotalReturnMassFlow;
    5069              :                     }
    5070              :                     // Set zone infiltration air flow rate
    5071       597505 :                     CalcZoneInfiltrationFlows(state, ZoneNum, ZoneReturnAirMassFlowRate);
    5072              : 
    5073            0 :                 } else if (state.dataHeatBal->ZoneAirMassFlow.ZoneFlowAdjustment == DataHeatBalance::AdjustmentType::AdjustReturnOnly ||
    5074            0 :                            state.dataHeatBal->ZoneAirMassFlow.ZoneFlowAdjustment == DataHeatBalance::AdjustmentType::AdjustReturnThenMixing) {
    5075              : 
    5076              :                     // Calculate return air flow rate using mass conservation equation
    5077            0 :                     Real64 AdjustedTotalReturnMassFlow = max(0.0, TotInletAirMassFlowRate - TotExhaustAirMassFlowRate + ZoneMixingNetAirMassFlowRate);
    5078            0 :                     if (!state.dataGlobal->DoingSizing) {
    5079            0 :                         AdjustedTotalReturnMassFlow = min(AdjustedTotalReturnMassFlow, zoneEquipConfig.AirLoopDesSupply);
    5080              :                     }
    5081              : 
    5082              :                     // add adjust zone return node air flow calculation
    5083            0 :                     zoneEquipConfig.calcReturnFlows(state, AdjustedTotalReturnMassFlow, FinalTotalReturnMassFlow);
    5084            0 :                     massConservation.RetMassFlowRate = FinalTotalReturnMassFlow;
    5085            0 :                     ZoneReturnAirMassFlowRate = FinalTotalReturnMassFlow;
    5086              : 
    5087            0 :                     if (state.dataHeatBal->ZoneAirMassFlow.ZoneFlowAdjustment == DataHeatBalance::AdjustmentType::AdjustReturnThenMixing) {
    5088            0 :                         ZoneMixingAirMassFlowRate = max(0.0,
    5089            0 :                                                         ZoneReturnAirMassFlowRate + TotExhaustAirMassFlowRate - TotInletAirMassFlowRate +
    5090            0 :                                                             massConservation.MixingSourceMassFlowRate);
    5091            0 :                         CalcZoneMixingFlowRateOfReceivingZone(state, ZoneNum, ZoneMixingAirMassFlowRate);
    5092            0 :                         ZoneMixingNetAirMassFlowRate = massConservation.MixingMassFlowRate - massConservation.MixingSourceMassFlowRate;
    5093              : 
    5094              :                         // Calculate return air flow rate using mass conservation equation
    5095            0 :                         AdjustedTotalReturnMassFlow = max(0.0, TotInletAirMassFlowRate - TotExhaustAirMassFlowRate + ZoneMixingNetAirMassFlowRate);
    5096            0 :                         if (!state.dataGlobal->DoingSizing) {
    5097            0 :                             AdjustedTotalReturnMassFlow = min(AdjustedTotalReturnMassFlow, zoneEquipConfig.AirLoopDesSupply);
    5098              :                         }
    5099              : 
    5100              :                         // add adjust zone return node air flow calc
    5101            0 :                         zoneEquipConfig.calcReturnFlows(state, AdjustedTotalReturnMassFlow, FinalTotalReturnMassFlow);
    5102            0 :                         massConservation.RetMassFlowRate = FinalTotalReturnMassFlow;
    5103            0 :                         ZoneReturnAirMassFlowRate = FinalTotalReturnMassFlow;
    5104              :                     }
    5105              : 
    5106              :                     // Set zone infiltration air flow rate
    5107            0 :                     CalcZoneInfiltrationFlows(state, ZoneNum, ZoneReturnAirMassFlowRate);
    5108              :                 } else {
    5109              :                     // if infiltration treatment method is not None
    5110              :                     // Set zone infiltration air flow rate
    5111            0 :                     CalcZoneInfiltrationFlows(state, ZoneNum, ZoneReturnAirMassFlowRate);
    5112              :                 }
    5113              :             }
    5114              : 
    5115     54112752 :             BuildingZoneMixingFlow += massConservation.MixingMassFlowRate;
    5116     54112752 :             BuildingZoneReturnFlow += massConservation.RetMassFlowRate;
    5117              : 
    5118              :             // Accumulate airloop total return flows and allocate excess exhaust flows
    5119    108313251 :             for (int returnNum = 1; returnNum <= zoneEquipConfig.NumReturnNodes; ++returnNum) {
    5120     54200499 :                 int retNode = zoneEquipConfig.ReturnNode(returnNum);
    5121     54200499 :                 int airLoop = zoneEquipConfig.ReturnNodeAirLoopNum(returnNum);
    5122     54200499 :                 if (airLoop > 0) {
    5123     38905121 :                     state.dataAirLoop->AirLoopFlow(airLoop).ZoneRetFlow += Node(retNode).MassFlowRate;
    5124     38905121 :                     if (zoneEquipConfig.TotAvailAirLoopOA > 0.0) {
    5125     36462391 :                         state.dataAirLoop->AirLoopFlow(airLoop).ExcessZoneExhFlow +=
    5126     36462391 :                             zoneEquipConfig.ExcessZoneExh * state.dataAirLoop->AirLoopFlow(airLoop).MaxOutAir / zoneEquipConfig.TotAvailAirLoopOA;
    5127              :                     }
    5128              :                 }
    5129              :             }
    5130              :         }
    5131              : 
    5132              :         // adjust the zone return air flow rates to match any excess zone exhaust flows
    5133     20064419 :         for (int airLoopNum = 1; airLoopNum <= state.dataHVACGlobal->NumPrimaryAirSys; ++airLoopNum) {
    5134     12371251 :             auto &thisAirLoopFlow(state.dataAirLoop->AirLoopFlow(airLoopNum));
    5135     12371251 :             Real64 adjZoneRetFlow = max(0.0, thisAirLoopFlow.ZoneRetFlow - thisAirLoopFlow.ExcessZoneExhFlow);
    5136     12371251 :             if (thisAirLoopFlow.ZoneRetFlow > 0.0) {
    5137      9981850 :                 thisAirLoopFlow.ZoneRetFlowRatio = adjZoneRetFlow / thisAirLoopFlow.ZoneRetFlow;
    5138              :             } else {
    5139      2389401 :                 thisAirLoopFlow.ZoneRetFlowRatio = 1.0;
    5140              :             }
    5141     12371251 :             thisAirLoopFlow.ZoneRetFlow = 0.0; // reset to zero and re-accumulate below
    5142              :         }
    5143              : 
    5144     70209402 :         for (int zoneNum = 1; zoneNum <= state.dataGlobal->NumOfZones; ++zoneNum) {
    5145     62516234 :             auto &thisZoneEquip(state.dataZoneEquip->ZoneEquipConfig(zoneNum));
    5146     62516234 :             auto const &thisZoneHB = state.dataZoneTempPredictorCorrector->zoneHeatBalance(zoneNum);
    5147     62516234 :             if (!thisZoneEquip.IsControlled) {
    5148      8403482 :                 continue;
    5149              :             }
    5150     54112752 :             int numRetNodes = thisZoneEquip.NumReturnNodes;
    5151     54112752 :             Real64 totalZoneReturnMassFlow = 0.0;
    5152    108313251 :             for (int returnNum = 1; returnNum <= numRetNodes; ++returnNum) {
    5153     54200499 :                 int retNode = thisZoneEquip.ReturnNode(returnNum);
    5154     54200499 :                 int airLoopNum = thisZoneEquip.ReturnNodeAirLoopNum(returnNum);
    5155     54200499 :                 if (retNode > 0) {
    5156     54200499 :                     if (airLoopNum > 0) {
    5157     38905121 :                         auto &thisAirLoopFlow(state.dataAirLoop->AirLoopFlow(airLoopNum));
    5158     38905121 :                         Node(retNode).MassFlowRate *= thisAirLoopFlow.ZoneRetFlowRatio;
    5159     38905121 :                         thisAirLoopFlow.ZoneRetFlow += Node(retNode).MassFlowRate;
    5160              :                     }
    5161     54200499 :                     totalZoneReturnMassFlow += Node(retNode).MassFlowRate;
    5162              :                 }
    5163              :             }
    5164              :             // Check zone flow balance but not when zone air mass balance is active
    5165    107627999 :             if (!state.dataHeatBal->ZoneAirMassFlow.EnforceZoneMassBalance && !state.dataGlobal->DoingSizing &&
    5166    107627999 :                 !state.dataGlobal->DoingHVACSizingSimulations && !state.dataGlobal->WarmupFlag && !FirstHVACIteration) {
    5167      4716879 :                 if (!thisZoneEquip.FlowError) {
    5168              :                     // Net system flows first (sum leaving flows, less entering flows)
    5169      4709181 :                     Real64 sysUnbalExhaust = (thisZoneEquip.TotExhaustAirMassFlowRate - thisZoneEquip.ZoneExhBalanced);
    5170      4709181 :                     Real64 sysUnbalancedFlow = sysUnbalExhaust + totalZoneReturnMassFlow - thisZoneEquip.TotInletAirMassFlowRate;
    5171      4709181 :                     if (sysUnbalancedFlow > HVAC::SmallMassFlow) {
    5172              :                         // Now include infiltration, ventilation, and mixing flows (these are all entering the zone, so subtract them)
    5173           11 :                         Real64 incomingFlow = thisZoneHB.OAMFL + thisZoneHB.VAMFL + thisZoneHB.MixingMassFlowZone;
    5174           11 :                         Real64 unbalancedFlow = max(0.0, sysUnbalancedFlow - incomingFlow);
    5175           11 :                         if (unbalancedFlow > HVAC::SmallMassFlow) {
    5176              :                             // Re-check on volume basis - use current zone density for incoming, standard density for HVAC sys
    5177           11 :                             Real64 zoneTemp = Node(thisZoneEquip.ZoneNode).Temp;
    5178           11 :                             Real64 zoneHumRat = Node(thisZoneEquip.ZoneNode).HumRat;
    5179           11 :                             Real64 rhoZone = PsyRhoAirFnPbTdbW(state, state.dataEnvrn->OutBaroPress, zoneTemp, zoneHumRat, "CalcZoneMassBalance");
    5180           11 :                             Real64 incomingVolFlow = incomingFlow / rhoZone;
    5181           11 :                             Real64 sysUnbalancedVolFlow = sysUnbalancedFlow / state.dataEnvrn->StdRhoAir;
    5182           11 :                             Real64 unbalancedVolFlow = max(0.0, sysUnbalancedVolFlow - incomingVolFlow);
    5183           11 :                             if (unbalancedVolFlow > HVAC::SmallAirVolFlow) {
    5184           22 :                                 ShowWarningError(state,
    5185           22 :                                                  format("In zone {} there is unbalanced air flow. Load due to induced outdoor air is neglected.",
    5186           11 :                                                         thisZoneEquip.ZoneName));
    5187           22 :                                 ShowContinueErrorTimeStamp(state, "");
    5188           22 :                                 ShowContinueError(state,
    5189           22 :                                                   format("  Flows [m3/s]: Inlets: {:.6R}  Unbalanced exhausts: {:.6R}  Returns: {:.6R}",
    5190           11 :                                                          thisZoneEquip.TotInletAirMassFlowRate / state.dataEnvrn->StdRhoAir,
    5191           11 :                                                          sysUnbalExhaust / state.dataEnvrn->StdRhoAir,
    5192           11 :                                                          totalZoneReturnMassFlow / state.dataEnvrn->StdRhoAir));
    5193           22 :                                 ShowContinueError(state,
    5194           22 :                                                   format("  Infiltration: {:.6R}  Zone Ventilation: {:.6R}  Mixing (incoming): {:.6R}",
    5195            0 :                                                          thisZoneHB.OAMFL / rhoZone,
    5196            0 :                                                          thisZoneHB.VAMFL / rhoZone,
    5197           11 :                                                          thisZoneHB.MixingMassFlowZone / rhoZone));
    5198           22 :                                 ShowContinueError(
    5199              :                                     state,
    5200           22 :                                     format("  Imbalance (excess outflow): {:.6R}  Total system OA flow (for all airloops serving this zone): {:.6R}",
    5201              :                                            unbalancedVolFlow,
    5202           11 :                                            thisZoneEquip.TotAvailAirLoopOA / state.dataEnvrn->StdRhoAir));
    5203           22 :                                 ShowContinueError(state, "  This error will only be reported once per zone.");
    5204           11 :                                 thisZoneEquip.FlowError = true;
    5205              :                             }
    5206              :                         }
    5207              :                     }
    5208              :                 }
    5209              :             }
    5210              :         }
    5211              : 
    5212              :         // update the
    5213      7693168 :         if (Iteration > 0) {
    5214       105705 :             Real64 totalResidual = 0.0;
    5215       105705 :             totalResidual =
    5216       105705 :                 std::abs(BuildingZoneMixingFlow - BuildingZoneMixingFlowOld) + std::abs(BuildingZoneReturnFlow - BuildingZoneReturnFlowOld);
    5217       105705 :             if (totalResidual < ConvergenceTolerance) {
    5218        11219 :                 state.dataHVACGlobal->ZoneMassBalanceHVACReSim = false;
    5219        11219 :                 break;
    5220              :             } else {
    5221        94486 :                 state.dataHVACGlobal->ZoneMassBalanceHVACReSim = true;
    5222              :             }
    5223              :         }
    5224      7681949 :         if (!state.dataHeatBal->ZoneAirMassFlow.EnforceZoneMassBalance) {
    5225      7573667 :             break;
    5226              :         }
    5227       108282 :         Iteration += 1;
    5228              : 
    5229       108282 :     } while (Iteration < IterMax);
    5230              :     // Set system return flows
    5231     19895297 :     for (int AirLoopNum = 1; AirLoopNum <= state.dataHVACGlobal->NumPrimaryAirSys; ++AirLoopNum) {
    5232     12307834 :         auto &thisAirLoopFlow(state.dataAirLoop->AirLoopFlow(AirLoopNum));
    5233     12307834 :         thisAirLoopFlow.SysRetFlow = thisAirLoopFlow.ZoneRetFlow - thisAirLoopFlow.RecircFlow + thisAirLoopFlow.LeakFlow;
    5234              :     }
    5235      7587463 : }
    5236              : 
    5237       597505 : void CalcZoneInfiltrationFlows(EnergyPlusData &state,
    5238              :                                int const ZoneNum,                      // current zone index
    5239              :                                Real64 const &ZoneReturnAirMassFlowRate // zone total zone return air mass flow rate
    5240              : )
    5241              : {
    5242       597505 :     Real64 constexpr ConvergenceTolerance(0.000010);
    5243       597505 :     Real64 ZoneInfiltrationMassFlowRate = 0.0;
    5244       597505 :     auto &massConservation = state.dataHeatBal->MassConservation(ZoneNum);
    5245              : 
    5246              :     // Set zone infiltration flow rate
    5247       597505 :     if (state.dataHeatBal->ZoneAirMassFlow.InfiltrationTreatment != DataHeatBalance::InfiltrationFlow::No) {
    5248       597505 :         if (massConservation.InfiltrationPtr > 0) {
    5249       478004 :             if (massConservation.IsOnlySourceZone ||
    5250            0 :                 (state.dataHeatBal->ZoneAirMassFlow.InfiltrationForZones == DataHeatBalance::InfiltrationZoneType::AllZones)) {
    5251      1434012 :                 ZoneInfiltrationMassFlowRate = massConservation.MixingSourceMassFlowRate - massConservation.MixingMassFlowRate +
    5252       478004 :                                                state.dataZoneEquip->ZoneEquipConfig(ZoneNum).TotExhaustAirMassFlowRate + ZoneReturnAirMassFlowRate -
    5253       478004 :                                                state.dataZoneEquip->ZoneEquipConfig(ZoneNum).TotInletAirMassFlowRate;
    5254       478004 :                 if (state.dataHeatBal->ZoneAirMassFlow.InfiltrationTreatment == DataHeatBalance::InfiltrationFlow::Adjust) {
    5255       422888 :                     if (std::abs(ZoneInfiltrationMassFlowRate) > ConvergenceTolerance) {
    5256       422875 :                         state.dataHeatBalFanSys->ZoneInfiltrationFlag(ZoneNum) = true;
    5257       422875 :                         massConservation.InfiltrationMassFlowRate = ZoneInfiltrationMassFlowRate;
    5258       422875 :                         massConservation.IncludeInfilToZoneMassBal = 1;
    5259       422875 :                         state.dataHeatBal->Infiltration(massConservation.InfiltrationPtr).MassFlowRate = ZoneInfiltrationMassFlowRate;
    5260       422875 :                         state.dataHeatBal->Infiltration(massConservation.InfiltrationPtr).MassFlowRate =
    5261       422875 :                             max(0.0, state.dataHeatBal->Infiltration(massConservation.InfiltrationPtr).MassFlowRate);
    5262              :                     } else {
    5263           13 :                         massConservation.InfiltrationMassFlowRate = 0.0;
    5264           13 :                         state.dataHeatBal->Infiltration(massConservation.InfiltrationPtr).MassFlowRate = 0.0;
    5265              :                     }
    5266        55116 :                 } else if (state.dataHeatBal->ZoneAirMassFlow.InfiltrationTreatment == DataHeatBalance::InfiltrationFlow::Add) {
    5267        55116 :                     if (ZoneInfiltrationMassFlowRate > ConvergenceTolerance) {
    5268        18492 :                         state.dataHeatBalFanSys->ZoneInfiltrationFlag(ZoneNum) = true;
    5269        18492 :                         massConservation.InfiltrationMassFlowRate = ZoneInfiltrationMassFlowRate;
    5270        18492 :                         massConservation.IncludeInfilToZoneMassBal = 1;
    5271        18492 :                         state.dataHeatBal->Infiltration(massConservation.InfiltrationPtr).MassFlowRate += ZoneInfiltrationMassFlowRate;
    5272              :                     } else {
    5273        36624 :                         massConservation.InfiltrationMassFlowRate = 0.0;
    5274              :                     }
    5275            0 :                 } else if (state.dataHeatBal->ZoneAirMassFlow.InfiltrationTreatment == DataHeatBalance::InfiltrationFlow::No) {
    5276            0 :                     massConservation.InfiltrationMassFlowRate = 0.0;
    5277              :                 }
    5278              :             } else {
    5279            0 :                 if (state.dataHeatBal->ZoneAirMassFlow.InfiltrationTreatment == DataHeatBalance::InfiltrationFlow::Adjust) {
    5280            0 :                     massConservation.InfiltrationMassFlowRate = state.dataHeatBal->Infiltration(massConservation.InfiltrationPtr).MassFlowRate;
    5281            0 :                 } else if (state.dataHeatBal->ZoneAirMassFlow.InfiltrationTreatment == DataHeatBalance::InfiltrationFlow::Add) {
    5282            0 :                     massConservation.InfiltrationMassFlowRate = 0.0;
    5283            0 :                 } else if (state.dataHeatBal->ZoneAirMassFlow.InfiltrationTreatment == DataHeatBalance::InfiltrationFlow::No) {
    5284            0 :                     massConservation.InfiltrationMassFlowRate = 0.0;
    5285              :                 }
    5286              :             }
    5287              :         } else {
    5288              :             // Zone has no infiltration objects
    5289       119501 :             massConservation.InfiltrationMassFlowRate = 0.0;
    5290              :         }
    5291              :     }
    5292       597505 : }
    5293              : 
    5294      7587463 : void CalcZoneLeavingConditions(EnergyPlusData &state, bool const FirstHVACIteration)
    5295              : {
    5296              : 
    5297              :     // SUBROUTINE INFORMATION:
    5298              :     //       AUTHOR         Richard Liesen
    5299              :     //       DATE WRITTEN   January 2001
    5300              :     //       MODIFIED       June 2003, FCW: add heat from airflow window to return air
    5301              : 
    5302              :     // PURPOSE OF THIS SUBROUTINE:
    5303              :     // Perform zone upate of the leaving conditions.
    5304              : 
    5305              :     // METHODOLOGY EMPLOYED:
    5306              :     // Energy Balance.
    5307              : 
    5308              :     // SUBROUTINE LOCAL VARIABLE DECLARATIONS:
    5309              :     Real64 TempRetAir;  // Return air temperature [C]
    5310              :     Real64 TempZoneAir; // Zone air temperature [C]
    5311              :     Real64 SumRetAirLatentGainRate;
    5312              : 
    5313              :     // If SpaceHVAC is active calculate SpaceHVAC:ReturnMixer inlet and outlet conditions before setting zone return conditions
    5314      7587463 :     if (state.dataHeatBal->doSpaceHeatBalanceSimulation && !state.dataGlobal->DoingSizing) {
    5315        12552 :         for (auto &thisSpaceHVACMixer : state.dataZoneEquip->zoneReturnMixer) {
    5316         4464 :             thisSpaceHVACMixer.setInletFlows(state);
    5317         4464 :             thisSpaceHVACMixer.setInletConditions(state);
    5318         4464 :             thisSpaceHVACMixer.setOutletConditions(state);
    5319         8088 :         }
    5320              :     }
    5321              : 
    5322     69469467 :     for (int ZoneNum = 1; ZoneNum <= state.dataGlobal->NumOfZones; ++ZoneNum) {
    5323     61882004 :         if (!state.dataZoneEquip->ZoneEquipConfig(ZoneNum).IsControlled) {
    5324      8297777 :             continue;
    5325              :         }
    5326              :         // A return air system may not exist for certain systems; Therefore when no return node exists
    5327              :         // there is no update.  Of course if there is no return air system then you cannot update
    5328              :         // the energy for the return air heat gain from the lights statements.
    5329     53584227 :         if (state.dataZoneEquip->ZoneEquipConfig(ZoneNum).NumReturnNodes == 0) {
    5330         3648 :             continue;
    5331              :         }
    5332     53580579 :         int ZoneNode = state.dataZoneEquip->ZoneEquipConfig(ZoneNum).ZoneNode;
    5333     53580579 :         int ZoneMult = state.dataHeatBal->Zone(ZoneNum).Multiplier * state.dataHeatBal->Zone(ZoneNum).ListMultiplier;
    5334     53580579 :         auto &thisZoneHB = state.dataZoneTempPredictorCorrector->zoneHeatBalance(ZoneNum);
    5335    107252553 :         for (int nodeCount = 1; nodeCount <= state.dataZoneEquip->ZoneEquipConfig(ZoneNum).NumReturnNodes; ++nodeCount) {
    5336     53671974 :             int ReturnNode = state.dataZoneEquip->ZoneEquipConfig(ZoneNum).ReturnNode(nodeCount);
    5337     53671974 :             int ReturnNodeExhaustNum = state.dataZoneEquip->ZoneEquipConfig(ZoneNum).ReturnNodeExhaustNodeNum(nodeCount);
    5338              : 
    5339              :             // RETURN AIR HEAT GAIN from the Lights statement; this heat gain is stored in
    5340              :             // Add sensible heat gain from refrigerated cases with under case returns
    5341     53671974 :             Real64 QRetAir = InternalHeatGains::zoneSumAllReturnAirConvectionGains(state, ZoneNum, ReturnNode);
    5342              : 
    5343              :             // Need to add the energy to the return air from lights and from airflow windows. Where the heat
    5344              :             // is added depends on if there is system flow or not.  If there is system flow the heat is added
    5345              :             // to the Zone Return Node.  If there is no system flow then the heat is added back to the zone in the
    5346              :             // Correct step through the SysDepZoneLoads variable.
    5347              : 
    5348     53671974 :             Real64 MassFlowRA = state.dataLoopNodes->Node(ReturnNode).MassFlowRate / ZoneMult;
    5349     53671974 :             if (ReturnNodeExhaustNum > 0 && state.dataLoopNodes->Node(ReturnNodeExhaustNum).MassFlowRate > 0.0) {
    5350         2959 :                 MassFlowRA += state.dataLoopNodes->Node(ReturnNodeExhaustNum).MassFlowRate;
    5351              :             }
    5352              : 
    5353              :             // user defined room air model may feed temp that differs from zone node
    5354              : 
    5355     53712414 :             if (state.dataHeatBal->doSpaceHeatBalanceSimulation && !state.dataGlobal->DoingSizing &&
    5356        40440 :                 (state.dataZoneEquip->ZoneEquipConfig(ZoneNum).returnNodeSpaceMixerIndex(nodeCount) > -1)) {
    5357              :                 // If a SpaceHVAC:ZoneReturnMixer feeds this node, use the node conditions which was set above in
    5358              :                 // thisSpaceHVACMixer.setOutletConditions
    5359         4464 :                 TempZoneAir = state.dataLoopNodes->Node(ReturnNode).Temp;
    5360         4464 :                 TempRetAir = TempZoneAir;
    5361     53667510 :             } else if (allocated(state.dataRoomAir->AirPatternZoneInfo)) {
    5362        58482 :                 if ((state.dataRoomAir->AirPatternZoneInfo(ZoneNum).IsUsed) && (!state.dataGlobal->BeginEnvrnFlag)) {
    5363        58122 :                     TempZoneAir = state.dataRoomAir->AirPatternZoneInfo(ZoneNum).Tleaving;
    5364        58122 :                     TempRetAir = TempZoneAir;
    5365              :                 } else {
    5366          360 :                     TempZoneAir = state.dataLoopNodes->Node(ZoneNode).Temp;
    5367          360 :                     TempRetAir = TempZoneAir;
    5368              :                 }
    5369              :             } else {
    5370     53609028 :                 TempZoneAir = state.dataLoopNodes->Node(ZoneNode).Temp;
    5371     53609028 :                 TempRetAir = TempZoneAir;
    5372              :             }
    5373              : 
    5374     53671974 :             Real64 WinGapFlowToRA = 0.0;  // Mass flow to return air from all airflow windows in zone [kg/s]
    5375     53671974 :             Real64 WinGapTtoRA = 0.0;     // Temp of outlet flow mixture to return air from all airflow windows in zone [C]
    5376     53671974 :             Real64 WinGapFlowTtoRA = 0.0; // Sum of mass flow times outlet temp for all airflow windows in zone [(kg/s)-C]
    5377              : 
    5378     53671974 :             if (state.dataHeatBal->Zone(ZoneNum).HasAirFlowWindowReturn) {
    5379            0 :                 for (int spaceNum : state.dataHeatBal->Zone(ZoneNum).spaceIndexes) {
    5380            0 :                     auto const &thisSpace = state.dataHeatBal->space(spaceNum);
    5381            0 :                     for (int SurfNum = thisSpace.HTSurfaceFirst; SurfNum <= thisSpace.HTSurfaceLast; ++SurfNum) {
    5382            0 :                         if (state.dataSurface->SurfWinAirflowThisTS(SurfNum) > 0.0 &&
    5383            0 :                             state.dataSurface->SurfWinAirflowDestination(SurfNum) == DataSurfaces::WindowAirFlowDestination::Return) {
    5384            0 :                             Real64 FlowThisTS = PsyRhoAirFnPbTdbW(state,
    5385            0 :                                                                   state.dataEnvrn->OutBaroPress,
    5386            0 :                                                                   state.dataSurface->SurfWinTAirflowGapOutlet(SurfNum),
    5387            0 :                                                                   state.dataLoopNodes->Node(ZoneNode).HumRat) *
    5388            0 :                                                 state.dataSurface->SurfWinAirflowThisTS(SurfNum) * state.dataSurface->Surface(SurfNum).Width;
    5389            0 :                             WinGapFlowToRA += FlowThisTS;
    5390            0 :                             WinGapFlowTtoRA += FlowThisTS * state.dataSurface->SurfWinTAirflowGapOutlet(SurfNum);
    5391              :                         }
    5392              :                     }
    5393            0 :                 }
    5394              :             }
    5395     53671974 :             if (WinGapFlowToRA > 0.0) {
    5396            0 :                 WinGapTtoRA = WinGapFlowTtoRA / WinGapFlowToRA;
    5397              :             }
    5398              :             // the flag NoHeatToReturnAir is TRUE if the system is zonal only or is central with on/off air flow. In these
    5399              :             // cases the heat to return air is treated as a zone heat gain and dealt with in CalcZoneSums in
    5400              :             // MODULE ZoneTempPredictorCorrector.
    5401     53671974 :             if (!state.dataHeatBal->Zone(ZoneNum).NoHeatToReturnAir) {
    5402     45651249 :                 Real64 CpAir = PsyCpAirFnW(state.dataLoopNodes->Node(ZoneNode).HumRat);
    5403     45651249 :                 if (MassFlowRA > 0.0) {
    5404     38315018 :                     if (WinGapFlowToRA > 0.0) {
    5405              :                         // Add heat-to-return from window gap airflow
    5406            0 :                         if (MassFlowRA >= WinGapFlowToRA) {
    5407            0 :                             TempRetAir = (WinGapFlowTtoRA + (MassFlowRA - WinGapFlowToRA) * TempZoneAir) / MassFlowRA;
    5408              :                         } else {
    5409              :                             // All of return air comes from flow through airflow windows
    5410            0 :                             TempRetAir = WinGapTtoRA;
    5411              :                             // Put heat from window airflow that exceeds return air flow into zone air
    5412            0 :                             thisZoneHB.SysDepZoneLoads += (WinGapFlowToRA - MassFlowRA) * CpAir * (WinGapTtoRA - TempZoneAir);
    5413              :                         }
    5414              :                     }
    5415              :                     // Add heat-to-return from lights
    5416     38315018 :                     TempRetAir += QRetAir / (MassFlowRA * CpAir);
    5417     38315018 :                     if (TempRetAir > HVAC::RetTempMax) {
    5418        15809 :                         state.dataLoopNodes->Node(ReturnNode).Temp = HVAC::RetTempMax;
    5419        15809 :                         if (!state.dataGlobal->ZoneSizingCalc) {
    5420         3360 :                             thisZoneHB.SysDepZoneLoads += CpAir * MassFlowRA * (TempRetAir - HVAC::RetTempMax);
    5421              :                         }
    5422     38299209 :                     } else if (TempRetAir < HVAC::RetTempMin) {
    5423           25 :                         state.dataLoopNodes->Node(ReturnNode).Temp = HVAC::RetTempMin;
    5424           25 :                         if (!state.dataGlobal->ZoneSizingCalc) {
    5425           21 :                             thisZoneHB.SysDepZoneLoads += CpAir * MassFlowRA * (TempRetAir - HVAC::RetTempMin);
    5426              :                         }
    5427              :                     } else {
    5428     38299184 :                         state.dataLoopNodes->Node(ReturnNode).Temp = TempRetAir;
    5429              :                     }
    5430     38315018 :                     if (ReturnNodeExhaustNum > 0 && state.dataLoopNodes->Node(ReturnNodeExhaustNum).MassFlowRate > 0.0 && QRetAir > 0.0) {
    5431         2959 :                         if (state.dataZoneEquip->ZoneEquipConfig(ZoneNum).SharedExhaustNode(nodeCount) != LightReturnExhaustConfig::Shared) {
    5432         2959 :                             state.dataLoopNodes->Node(ReturnNodeExhaustNum).Temp = TempRetAir;
    5433              :                         } else {
    5434            0 :                             state.dataLoopNodes->Node(ReturnNodeExhaustNum).Temp += QRetAir / (MassFlowRA * CpAir);
    5435              :                         }
    5436              :                     }
    5437              :                 } else { // No return air flow
    5438              :                     // Assign all heat-to-return from window gap airflow to zone air
    5439      7336231 :                     if (WinGapFlowToRA > 0.0) {
    5440            0 :                         thisZoneHB.SysDepZoneLoads += WinGapFlowToRA * CpAir * (WinGapTtoRA - TempZoneAir);
    5441              :                     }
    5442              :                     // Assign all heat-to-return from lights to zone air
    5443      7336231 :                     if (QRetAir > 0.0) {
    5444      1102522 :                         thisZoneHB.SysDepZoneLoads += QRetAir;
    5445              :                     }
    5446      7336231 :                     state.dataLoopNodes->Node(ReturnNode).Temp = state.dataLoopNodes->Node(ZoneNode).Temp;
    5447              :                 }
    5448              :             } else {
    5449              :                 // update the return air node for zonal and central on/off systems
    5450      8020725 :                 state.dataLoopNodes->Node(ReturnNode).Temp = state.dataLoopNodes->Node(ZoneNode).Temp;
    5451              :             }
    5452              : 
    5453              :             // Update the rest of the Return Air Node conditions, if the return air system exists!
    5454     53671974 :             state.dataLoopNodes->Node(ReturnNode).Press = state.dataLoopNodes->Node(ZoneNode).Press;
    5455              : 
    5456              :             // Include impact of under case returns for refrigerated display case when updating the return air node humidity
    5457     53671974 :             if (!state.dataHeatBal->Zone(ZoneNum).NoHeatToReturnAir) {
    5458     45651249 :                 if (MassFlowRA > 0) {
    5459     38315018 :                     SumRetAirLatentGainRate = InternalHeatGains::SumAllReturnAirLatentGains(state, ZoneNum, ReturnNode);
    5460     38315018 :                     Real64 H2OHtOfVap = PsyHgAirFnWTdb(state.dataLoopNodes->Node(ZoneNode).HumRat, state.dataLoopNodes->Node(ReturnNode).Temp);
    5461     38315018 :                     state.dataLoopNodes->Node(ReturnNode).HumRat =
    5462     38315018 :                         state.dataLoopNodes->Node(ZoneNode).HumRat + (SumRetAirLatentGainRate / (H2OHtOfVap * MassFlowRA));
    5463              :                 } else {
    5464              :                     // If no mass flow rate exists, include the latent HVAC case credit with the latent Zone case credit
    5465      7336231 :                     state.dataLoopNodes->Node(ReturnNode).HumRat = state.dataLoopNodes->Node(ZoneNode).HumRat;
    5466      7336231 :                     state.dataHeatBal->RefrigCaseCredit(ZoneNum).LatCaseCreditToZone +=
    5467      7336231 :                         state.dataHeatBal->RefrigCaseCredit(ZoneNum).LatCaseCreditToHVAC;
    5468              :                     // shouldn't the HVAC term be zeroed out then?
    5469      7336231 :                     SumRetAirLatentGainRate = InternalHeatGains::SumAllReturnAirLatentGains(state, ZoneNum, ReturnNode);
    5470      7336231 :                     thisZoneHB.latentGain += SumRetAirLatentGainRate;
    5471              :                 }
    5472              :             } else {
    5473      8020725 :                 state.dataLoopNodes->Node(ReturnNode).HumRat = state.dataLoopNodes->Node(ZoneNode).HumRat;
    5474      8020725 :                 state.dataHeatBal->RefrigCaseCredit(ZoneNum).LatCaseCreditToZone += state.dataHeatBal->RefrigCaseCredit(ZoneNum).LatCaseCreditToHVAC;
    5475              :                 // shouldn't the HVAC term be zeroed out then?
    5476      8020725 :                 SumRetAirLatentGainRate = InternalHeatGains::SumAllReturnAirLatentGains(state, ZoneNum, ReturnNode);
    5477      8020725 :                 thisZoneHB.latentGain += SumRetAirLatentGainRate;
    5478              :             }
    5479              : 
    5480     53671974 :             state.dataLoopNodes->Node(ReturnNode).Enthalpy =
    5481     53671974 :                 PsyHFnTdbW(state.dataLoopNodes->Node(ReturnNode).Temp, state.dataLoopNodes->Node(ReturnNode).HumRat);
    5482              : 
    5483     53671974 :             if (state.dataContaminantBalance->Contaminant.CO2Simulation) {
    5484       693783 :                 state.dataLoopNodes->Node(ReturnNode).CO2 = state.dataLoopNodes->Node(ZoneNode).CO2;
    5485              :             }
    5486     53671974 :             if (state.dataContaminantBalance->Contaminant.GenericContamSimulation) {
    5487       533597 :                 state.dataLoopNodes->Node(ReturnNode).GenContam = state.dataLoopNodes->Node(ZoneNode).GenContam;
    5488              :             }
    5489              : 
    5490              :         } // End of check for a return air node, which implies a return air system.
    5491              : 
    5492              :         // Reset current deadband flags, remaining output required, so no impact beyond zone equipment
    5493     53580579 :         InitSystemOutputRequired(state, ZoneNum, FirstHVACIteration, true);
    5494              :     }
    5495      7587463 : }
    5496              : 
    5497      7587463 : void UpdateZoneEquipment(EnergyPlusData &state, bool &SimAir)
    5498              : {
    5499              :     // SUBROUTINE INFORMATION:
    5500              :     //       AUTHOR         Russ Taylor
    5501              :     //       DATE WRITTEN   Nov 1997
    5502              : 
    5503              :     // PURPOSE OF THIS SUBROUTINE:
    5504              :     // This subroutine performs the update for Zone Equipment Management.
    5505              :     // Specifically, it transfers the conditions from the zone equipment return air nodes across
    5506              :     // to the air loop side, allowing for multiple return air nodes
    5507              : 
    5508              :     // Transfer the conditions from the zone equipment return air nodes across
    5509              :     // to the air loop side, allowing for multiple return air nodes
    5510     19895297 :     for (int ZoneGroupNum = 1; ZoneGroupNum <= state.dataHVACGlobal->NumPrimaryAirSys; ++ZoneGroupNum) {
    5511     24615668 :         for (int RetAirPathNum = 1; RetAirPathNum <= state.dataAirLoop->AirToZoneNodeInfo(ZoneGroupNum).NumReturnNodes; ++RetAirPathNum) {
    5512     24615668 :             HVACInterfaceManager::UpdateHVACInterface(state,
    5513              :                                                       ZoneGroupNum,
    5514              :                                                       DataConvergParams::CalledFrom::AirSystemDemandSide,
    5515     12307834 :                                                       state.dataAirLoop->AirToZoneNodeInfo(ZoneGroupNum).ZoneEquipReturnNodeNum(RetAirPathNum),
    5516     12307834 :                                                       state.dataAirLoop->AirToZoneNodeInfo(ZoneGroupNum).AirLoopReturnNodeNum(RetAirPathNum),
    5517              :                                                       SimAir);
    5518              :         }
    5519              :     }
    5520      7587463 : }
    5521              : 
    5522      3904170 : void CalcAirFlowSimple(EnergyPlusData &state,
    5523              :                        int const SysTimestepLoop,                // System time step index
    5524              :                        bool const AdjustZoneMixingFlowFlag,      // holds zone mixing air flow calc status
    5525              :                        bool const AdjustZoneInfiltrationFlowFlag // holds zone mixing air flow calc status
    5526              : )
    5527              : {
    5528              :     // SUBROUTINE INFORMATION:
    5529              :     //       AUTHOR         Legacy Code
    5530              :     //       MODIFIED       Shirey, Jan 2008 (MIXING objects, use avg. conditions for Cp, Air Density and Hfg)
    5531              :     //       MODIFIED       L. Lawrie and L. GU, Jan. 2008 (Allow multiple infiltration and ventilation objects)
    5532              :     //                      B. Griffith. Jan 2009 add infiltration, residential basic/sherman-grimsrud and enhanced/AIM2
    5533              :     //                      L. Lawrie - March 2009 - move ventilation electric calculation to this routine (for
    5534              :     //                        Electricity Net.
    5535              :     //                      L. Gu - Dec. 2009 - Added a new ventilation object to calculate flow rate based on wind and stack
    5536              :     //                        effect through an opening.
    5537              :     //       MODIFIED       Stovall - Aug 2011 (add refrigerator door mixing)
    5538              : 
    5539              :     // PURPOSE OF THIS SUBROUTINE:
    5540              :     // This subroutine calculates the air component of the heat balance.
    5541              : 
    5542      3904170 :     constexpr Real64 StdGravity(9.80665); // The acceleration of gravity at the sea level (m/s2)
    5543              :     static constexpr std::string_view RoutineNameVentilation("CalcAirFlowSimple:Ventilation");
    5544              :     static constexpr std::string_view RoutineNameMixing("CalcAirFlowSimple:Mixing");
    5545              :     static constexpr std::string_view RoutineNameCrossMixing("CalcAirFlowSimple:CrossMixing");
    5546              :     static constexpr std::string_view RoutineNameRefrigerationDoorMixing("CalcAirFlowSimple:RefrigerationDoorMixing");
    5547              :     static constexpr std::string_view RoutineNameInfiltration("CalcAirFlowSimple:Infiltration");
    5548              :     static constexpr std::string_view RoutineNameZoneAirBalance("CalcAirFlowSimple:ZoneAirBalance");
    5549              : 
    5550     35294522 :     for (auto &thisZoneHB : state.dataZoneTempPredictorCorrector->zoneHeatBalance) {
    5551     31390352 :         thisZoneHB.MCPM = 0.0;
    5552     31390352 :         thisZoneHB.MCPTM = 0.0;
    5553     31390352 :         thisZoneHB.MCPTI = 0.0;
    5554     31390352 :         thisZoneHB.MCPI = 0.0;
    5555     31390352 :         thisZoneHB.OAMFL = 0.0;
    5556     31390352 :         thisZoneHB.MCPTV = 0.0;
    5557     31390352 :         thisZoneHB.MCPV = 0.0;
    5558     31390352 :         thisZoneHB.VAMFL = 0.0;
    5559     31390352 :         thisZoneHB.MDotCPOA = 0.0;
    5560     31390352 :         thisZoneHB.MDotOA = 0.0;
    5561     31390352 :         thisZoneHB.MCPThermChim = 0.0;
    5562     31390352 :         thisZoneHB.ThermChimAMFL = 0.0;
    5563     31390352 :         thisZoneHB.MCPTThermChim = 0.0;
    5564     31390352 :         thisZoneHB.MixingMassFlowZone = 0.0;
    5565     31390352 :         thisZoneHB.MixingMassFlowXHumRat = 0.0;
    5566      3904170 :     }
    5567      3904170 :     if (state.dataHeatBal->doSpaceHeatBalance) {
    5568        97027 :         for (auto &thisSpaceHB : state.dataZoneTempPredictorCorrector->spaceHeatBalance) {
    5569        86394 :             thisSpaceHB.MCPM = 0.0;
    5570        86394 :             thisSpaceHB.MCPTM = 0.0;
    5571        86394 :             thisSpaceHB.MCPTI = 0.0;
    5572        86394 :             thisSpaceHB.MCPI = 0.0;
    5573        86394 :             thisSpaceHB.OAMFL = 0.0;
    5574        86394 :             thisSpaceHB.MCPTV = 0.0;
    5575        86394 :             thisSpaceHB.MCPV = 0.0;
    5576        86394 :             thisSpaceHB.VAMFL = 0.0;
    5577        86394 :             thisSpaceHB.MDotCPOA = 0.0;
    5578        86394 :             thisSpaceHB.MDotOA = 0.0;
    5579        86394 :             thisSpaceHB.MCPThermChim = 0.0;
    5580        86394 :             thisSpaceHB.ThermChimAMFL = 0.0;
    5581        86394 :             thisSpaceHB.MCPTThermChim = 0.0;
    5582        86394 :             thisSpaceHB.MixingMassFlowZone = 0.0;
    5583        86394 :             thisSpaceHB.MixingMassFlowXHumRat = 0.0;
    5584        10633 :         }
    5585              :     }
    5586      3965367 :     if (state.dataContaminantBalance->Contaminant.CO2Simulation &&
    5587        61197 :         state.dataHeatBal->TotMixing + state.dataHeatBal->TotCrossMixing + state.dataHeatBal->TotRefDoorMixing > 0) {
    5588        17810 :         state.dataContaminantBalance->MixingMassFlowCO2 = 0.0;
    5589              :     }
    5590      3927780 :     if (state.dataContaminantBalance->Contaminant.GenericContamSimulation &&
    5591        23610 :         state.dataHeatBal->TotMixing + state.dataHeatBal->TotCrossMixing + state.dataHeatBal->TotRefDoorMixing > 0) {
    5592        17810 :         state.dataContaminantBalance->MixingMassFlowGC = 0.0;
    5593              :     }
    5594              : 
    5595      3904170 :     if (!state.dataHeatBal->AirFlowFlag) {
    5596            0 :         return;
    5597              :     }
    5598              :     // AirflowNetwork Multizone field /= SIMPLE
    5599      4057318 :     if (!(state.afn->simulation_control.type == AirflowNetwork::ControlType::NoMultizoneOrDistribution ||
    5600       153148 :           state.afn->simulation_control.type == AirflowNetwork::ControlType::MultizoneWithDistributionOnlyDuringFanOperation)) {
    5601       146497 :         return;
    5602              :     }
    5603              : 
    5604      3757673 :     EarthTube::ManageEarthTube(state);
    5605      3757673 :     CoolTower::ManageCoolTower(state);
    5606      3757673 :     ThermalChimney::ManageThermalChimney(state);
    5607              : 
    5608              :     // Assign zone air temperature
    5609     34654398 :     for (auto &thisZoneHB : state.dataZoneTempPredictorCorrector->zoneHeatBalance) {
    5610     30896725 :         thisZoneHB.MixingMAT = thisZoneHB.MAT;
    5611     30896725 :         thisZoneHB.MixingHumRat = thisZoneHB.airHumRat;
    5612              :         // This is only temporary fix for CR8867.  (L. Gu 8/12)
    5613     30896725 :         if (SysTimestepLoop == 1) {
    5614      3104896 :             thisZoneHB.MixingMAT = thisZoneHB.XMPT;
    5615      3104896 :             thisZoneHB.MixingHumRat = thisZoneHB.WTimeMinusP;
    5616              :         }
    5617      3757673 :     }
    5618      3757673 :     if (state.dataHeatBal->doSpaceHeatBalance) {
    5619        97027 :         for (auto &thisSpaceHB : state.dataZoneTempPredictorCorrector->spaceHeatBalance) {
    5620        86394 :             thisSpaceHB.MixingMAT = thisSpaceHB.MAT;
    5621        86394 :             thisSpaceHB.MixingHumRat = thisSpaceHB.airHumRat;
    5622              :             // This is only temporary fix for CR8867.  (L. Gu 8/12)
    5623        86394 :             if (SysTimestepLoop == 1) {
    5624         8426 :                 thisSpaceHB.MixingMAT = thisSpaceHB.XMPT;
    5625         8426 :                 thisSpaceHB.MixingHumRat = thisSpaceHB.WTimeMinusP;
    5626              :             }
    5627        10633 :         }
    5628              :     }
    5629              : 
    5630              :     // Initialization of ZoneAirBalance
    5631      3757673 :     if (state.dataHeatBal->TotZoneAirBalance > 0) {
    5632        28634 :         for (auto &e : state.dataHeatBal->ZoneAirBalance) {
    5633        14317 :             e.BalMassFlowRate = 0.0;
    5634        14317 :             e.InfMassFlowRate = 0.0;
    5635        14317 :             e.NatMassFlowRate = 0.0;
    5636        14317 :             e.ExhMassFlowRate = 0.0;
    5637        14317 :             e.IntMassFlowRate = 0.0;
    5638        14317 :             e.ERVMassFlowRate = 0.0;
    5639        14317 :         }
    5640              :     }
    5641              : 
    5642      3757673 :     if (state.dataHeatBal->TotVentilation > 0) {
    5643      1277749 :         for (auto &e : state.dataHeatBal->ZnAirRpt) {
    5644      1110510 :             e.VentilFanElec = 0.0;
    5645       167239 :         }
    5646              :     }
    5647              : 
    5648              :     // Process the scheduled Ventilation for air heat balance
    5649      4374182 :     for (int j = 1; j <= state.dataHeatBal->TotVentilation; ++j) {
    5650       616509 :         auto &thisVentilation = state.dataHeatBal->Ventilation(j);
    5651       616509 :         int zoneNum = thisVentilation.ZonePtr;
    5652       616509 :         auto &thisZoneHB = state.dataZoneTempPredictorCorrector->zoneHeatBalance(zoneNum);
    5653       616509 :         Real64 thisMixingMAT = 0.0;
    5654       616509 :         if (state.dataHeatBal->doSpaceHeatBalance) {
    5655            0 :             thisMixingMAT = state.dataZoneTempPredictorCorrector->spaceHeatBalance(thisVentilation.spaceIndex).MixingMAT;
    5656              :         } else {
    5657       616509 :             thisMixingMAT = thisZoneHB.MixingMAT;
    5658              :         }
    5659       616509 :         thisVentilation.FanPower = 0.0;
    5660       616509 :         thisVentilation.MCP = 0.0;
    5661              : 
    5662       616509 :         Real64 TempExt = state.dataHeatBal->Zone(zoneNum).OutDryBulbTemp;
    5663       616509 :         Real64 WindSpeedExt = state.dataHeatBal->Zone(zoneNum).WindSpeed;
    5664       616509 :         Real64 WindDirExt = state.dataHeatBal->Zone(zoneNum).WindDir;
    5665       616509 :         Real64 thisMCPV = 0.0;
    5666       616509 :         Real64 thisVAMFL = 0.0;
    5667       616509 :         Real64 thisMCPTV = 0.0;
    5668              : 
    5669              :         // Use air node information linked to the zone if defined
    5670       616509 :         Real64 HumRatExt = 0.0;
    5671       616509 :         Real64 EnthalpyExt = 0.0;
    5672       616509 :         if (state.dataHeatBal->Zone(zoneNum).LinkedOutAirNode > 0) {
    5673            0 :             HumRatExt = state.dataLoopNodes->Node(state.dataHeatBal->Zone(zoneNum).LinkedOutAirNode).HumRat;
    5674            0 :             EnthalpyExt = state.dataLoopNodes->Node(state.dataHeatBal->Zone(zoneNum).LinkedOutAirNode).Enthalpy;
    5675              :         } else {
    5676       616509 :             HumRatExt = state.dataEnvrn->OutHumRat;
    5677       616509 :             EnthalpyExt = state.dataEnvrn->OutEnthalpy;
    5678              :         }
    5679              : 
    5680       616509 :         Real64 AirDensity = 0.0; // Density of air for converting from volume flow to mass flow (kg/m^3)
    5681       616509 :         switch (thisVentilation.densityBasis) {
    5682            0 :         case DataHeatBalance::InfVentDensityBasis::Standard: {
    5683            0 :             AirDensity = state.dataEnvrn->StdRhoAir;
    5684            0 :         } break;
    5685            0 :         case DataHeatBalance::InfVentDensityBasis::Indoor: {
    5686            0 :             if (state.dataHeatBal->doSpaceHeatBalance) {
    5687            0 :                 auto &thisSpaceHB = state.dataZoneTempPredictorCorrector->spaceHeatBalance(thisVentilation.spaceIndex);
    5688            0 :                 AirDensity = Psychrometrics::PsyRhoAirFnPbTdbW(
    5689            0 :                     state, state.dataEnvrn->OutBaroPress, thisMixingMAT, thisSpaceHB.MixingHumRat, RoutineNameInfiltration);
    5690              :             } else {
    5691            0 :                 AirDensity = Psychrometrics::PsyRhoAirFnPbTdbW(
    5692            0 :                     state, state.dataEnvrn->OutBaroPress, thisMixingMAT, thisZoneHB.MixingHumRat, RoutineNameInfiltration);
    5693              :             }
    5694            0 :         } break;
    5695       616509 :         default:
    5696       616509 :             AirDensity = PsyRhoAirFnPbTdbW(state, state.dataEnvrn->OutBaroPress, TempExt, HumRatExt, RoutineNameInfiltration);
    5697       616509 :             break;
    5698              :         }
    5699              : 
    5700       616509 :         Real64 CpAir = PsyCpAirFnW(HumRatExt);
    5701              : 
    5702              :         // Hybrid ventilation global control
    5703       616509 :         int I = 0;
    5704       616509 :         if (thisVentilation.HybridControlType == DataHeatBalance::HybridCtrlType::Global && thisVentilation.HybridControlMasterNum > 0) {
    5705         2592 :             I = thisVentilation.HybridControlMasterNum;
    5706         2592 :             if (j == I) {
    5707         1430 :                 thisVentilation.HybridControlMasterStatus = false;
    5708              :             }
    5709              :         } else {
    5710       613917 :             I = j;
    5711              :         }
    5712       616509 :         auto &hybridControlVentilation = state.dataHeatBal->Ventilation(I);
    5713              :         // Hybrid controlled zone MAT
    5714       616509 :         Real64 hybridControlZoneMAT = state.dataZoneTempPredictorCorrector->zoneHeatBalance(hybridControlVentilation.ZonePtr).MixingMAT;
    5715              : 
    5716              :         // Check scheduled temperatures
    5717       616509 :         if (hybridControlVentilation.minIndoorTempSched != nullptr) {
    5718        35493 :             hybridControlVentilation.MinIndoorTemperature = hybridControlVentilation.minIndoorTempSched->getCurrentVal();
    5719              :         }
    5720       616509 :         if (hybridControlVentilation.maxIndoorTempSched != nullptr) {
    5721        35493 :             hybridControlVentilation.MaxIndoorTemperature = hybridControlVentilation.maxIndoorTempSched->getCurrentVal();
    5722              :         }
    5723              :         // Ensure the minimum indoor temperature <= the maximum indoor temperature
    5724       616509 :         if (hybridControlVentilation.minIndoorTempSched != nullptr || hybridControlVentilation.maxIndoorTempSched != nullptr) {
    5725        35493 :             if (hybridControlVentilation.MinIndoorTemperature > hybridControlVentilation.MaxIndoorTemperature) {
    5726            0 :                 ++hybridControlVentilation.IndoorTempErrCount;
    5727            0 :                 if (hybridControlVentilation.IndoorTempErrCount < 2) {
    5728            0 :                     ShowWarningError(state,
    5729            0 :                                      format("Ventilation indoor temperature control: The minimum indoor temperature is above the maximum indoor "
    5730              :                                             "temperature in {}",
    5731            0 :                                             hybridControlVentilation.Name));
    5732            0 :                     ShowContinueError(state, "The minimum indoor temperature is set to the maximum indoor temperature. Simulation continues.");
    5733            0 :                     ShowContinueErrorTimeStamp(state, " Occurrence info:");
    5734              :                 } else {
    5735            0 :                     ShowRecurringWarningErrorAtEnd(state,
    5736              :                                                    "The minimum indoor temperature is still above the maximum indoor temperature",
    5737            0 :                                                    hybridControlVentilation.IndoorTempErrIndex,
    5738            0 :                                                    hybridControlVentilation.MinIndoorTemperature,
    5739            0 :                                                    hybridControlVentilation.MinIndoorTemperature);
    5740              :                 }
    5741            0 :                 hybridControlVentilation.MinIndoorTemperature = hybridControlVentilation.MaxIndoorTemperature;
    5742              :             }
    5743              :         }
    5744       616509 :         if (hybridControlVentilation.minOutdoorTempSched != nullptr) {
    5745        35493 :             hybridControlVentilation.MinOutdoorTemperature = hybridControlVentilation.minOutdoorTempSched->getCurrentVal();
    5746              :         }
    5747       616509 :         if (hybridControlVentilation.maxOutdoorTempSched != nullptr) {
    5748        35493 :             hybridControlVentilation.MaxOutdoorTemperature = hybridControlVentilation.maxOutdoorTempSched->getCurrentVal();
    5749              :         }
    5750              :         // Ensure the minimum outdoor temperature <= the maximum outdoor temperature
    5751       616509 :         if (hybridControlVentilation.minOutdoorTempSched != nullptr || hybridControlVentilation.maxOutdoorTempSched != nullptr) {
    5752        35493 :             if (hybridControlVentilation.MinOutdoorTemperature > hybridControlVentilation.MaxOutdoorTemperature) {
    5753            0 :                 ++hybridControlVentilation.OutdoorTempErrCount;
    5754            0 :                 if (hybridControlVentilation.OutdoorTempErrCount < 2) {
    5755            0 :                     ShowWarningError(state,
    5756            0 :                                      format("Ventilation outdoor temperature control: The minimum outdoor temperature is above the maximum "
    5757              :                                             "outdoor temperature in {}",
    5758            0 :                                             hybridControlVentilation.Name));
    5759            0 :                     ShowContinueError(state, "The minimum outdoor temperature is set to the maximum outdoor temperature. Simulation continues.");
    5760            0 :                     ShowContinueErrorTimeStamp(state, " Occurrence info:");
    5761              :                 } else {
    5762            0 :                     ShowRecurringWarningErrorAtEnd(state,
    5763              :                                                    "The minimum outdoor temperature is still above the maximum outdoor temperature",
    5764            0 :                                                    hybridControlVentilation.OutdoorTempErrIndex,
    5765            0 :                                                    hybridControlVentilation.MinOutdoorTemperature,
    5766            0 :                                                    hybridControlVentilation.MinOutdoorTemperature);
    5767              :                 }
    5768            0 :                 hybridControlVentilation.MinIndoorTemperature = hybridControlVentilation.MaxIndoorTemperature;
    5769              :             }
    5770              :         }
    5771       616509 :         if (hybridControlVentilation.deltaTempSched != nullptr) {
    5772        35493 :             hybridControlVentilation.DelTemperature = hybridControlVentilation.deltaTempSched->getCurrentVal();
    5773              :         }
    5774              :         // Skip this if the zone is below the minimum indoor temperature limit
    5775       616509 :         if ((hybridControlZoneMAT < hybridControlVentilation.MinIndoorTemperature) && (!thisVentilation.EMSSimpleVentOn)) {
    5776        46284 :             continue;
    5777              :         }
    5778              :         // Skip this if the zone is above the maximum indoor temperature limit
    5779       570225 :         if ((hybridControlZoneMAT > hybridControlVentilation.MaxIndoorTemperature) && (!thisVentilation.EMSSimpleVentOn)) {
    5780         1596 :             continue;
    5781              :         }
    5782              :         // Skip if below the temperature difference limit (3/12/03 Negative DelTemperature allowed now)
    5783       568629 :         if (((hybridControlZoneMAT - TempExt) < hybridControlVentilation.DelTemperature) && (!thisVentilation.EMSSimpleVentOn)) {
    5784        76229 :             continue;
    5785              :         }
    5786              :         // Skip this if the outdoor temperature is below the minimum outdoor temperature limit
    5787       492400 :         if ((TempExt < hybridControlVentilation.MinOutdoorTemperature) && (!thisVentilation.EMSSimpleVentOn)) {
    5788       195348 :             continue;
    5789              :         }
    5790              :         // Skip this if the outdoor temperature is above the maximum outdoor temperature limit
    5791       297052 :         if ((TempExt > hybridControlVentilation.MaxOutdoorTemperature) && (!thisVentilation.EMSSimpleVentOn)) {
    5792        81512 :             continue;
    5793              :         }
    5794              :         // Skip this if the outdoor wind speed is above the maximum windspeed limit
    5795       215540 :         if ((WindSpeedExt > hybridControlVentilation.MaxWindSpeed) && (!thisVentilation.EMSSimpleVentOn)) {
    5796            0 :             continue;
    5797              :         }
    5798              : 
    5799              :         // Hybrid ventilation controls
    5800       215540 :         if ((thisVentilation.HybridControlType == DataHeatBalance::HybridCtrlType::Close) && (!thisVentilation.EMSSimpleVentOn)) {
    5801         9129 :             continue;
    5802              :         }
    5803       206411 :         if (thisVentilation.HybridControlType == DataHeatBalance::HybridCtrlType::Global && thisVentilation.HybridControlMasterNum > 0) {
    5804         2066 :             if (j == I) {
    5805         1142 :                 thisVentilation.HybridControlMasterStatus = true;
    5806              :             }
    5807              :         }
    5808              : 
    5809       206411 :         if (thisVentilation.ModelType == DataHeatBalance::VentilationModelType::DesignFlowRate) {
    5810              :             // CR6845 if calculated < 0, don't propagate.
    5811        99399 :             Real64 VVF = thisVentilation.DesignLevel * thisVentilation.availSched->getCurrentVal(); // VENTILATION FLOW RATE (M**3/SEC)
    5812              : 
    5813        99399 :             if (thisVentilation.EMSSimpleVentOn) {
    5814            0 :                 VVF = thisVentilation.EMSimpleVentFlowRate;
    5815              :             }
    5816              : 
    5817        99399 :             if (VVF < 0.0) {
    5818            0 :                 VVF = 0.0;
    5819              :             }
    5820       198798 :             thisVentilation.MCP = VVF * AirDensity * CpAir *
    5821        99399 :                                   (thisVentilation.ConstantTermCoef + std::abs(TempExt - thisMixingMAT) * thisVentilation.TemperatureTermCoef +
    5822        99399 :                                    WindSpeedExt * (thisVentilation.VelocityTermCoef + WindSpeedExt * thisVentilation.VelocitySQTermCoef));
    5823        99399 :             if (thisVentilation.MCP < 0.0) {
    5824            0 :                 thisVentilation.MCP = 0.0;
    5825              :             }
    5826        99399 :             Real64 VAMFL_temp = thisVentilation.MCP / CpAir;
    5827        99399 :             if (state.dataHeatBal->Zone(zoneNum).zoneOAQuadratureSum) {
    5828         1676 :                 auto &thisZoneAirBalance = state.dataHeatBal->ZoneAirBalance(state.dataHeatBal->Zone(zoneNum).zoneOABalanceIndex);
    5829         1676 :                 switch (thisVentilation.FanType) {
    5830              :                     // ventilation type based calculation
    5831            0 :                 case DataHeatBalance::VentilationType::Exhaust: {
    5832            0 :                     thisZoneAirBalance.ExhMassFlowRate += VAMFL_temp;
    5833            0 :                 } break;
    5834            0 :                 case DataHeatBalance::VentilationType::Intake: {
    5835            0 :                     thisZoneAirBalance.IntMassFlowRate += VAMFL_temp;
    5836            0 :                 } break;
    5837            0 :                 case DataHeatBalance::VentilationType::Natural: {
    5838            0 :                     thisZoneAirBalance.NatMassFlowRate += VAMFL_temp;
    5839            0 :                 } break;
    5840         1676 :                 case DataHeatBalance::VentilationType::Balanced: {
    5841         1676 :                     thisZoneAirBalance.BalMassFlowRate += VAMFL_temp;
    5842         1676 :                 } break;
    5843            0 :                 default:
    5844            0 :                     break;
    5845              :                 }
    5846              :             } else {
    5847        97723 :                 thisMCPV = thisVentilation.MCP;
    5848        97723 :                 thisVAMFL = VAMFL_temp;
    5849              :             }
    5850        99399 :             if (thisVentilation.FanEfficiency > 0.0) {
    5851        99399 :                 thisVentilation.FanPower = VAMFL_temp * thisVentilation.FanPressure / (thisVentilation.FanEfficiency * AirDensity);
    5852        99399 :                 if (thisVentilation.FanType == DataHeatBalance::VentilationType::Balanced) {
    5853        55594 :                     thisVentilation.FanPower *= 2.0;
    5854              :                 }
    5855              :                 // calc electric
    5856        99399 :                 if (state.afn->simulation_control.type == AirflowNetwork::ControlType::MultizoneWithDistributionOnlyDuringFanOperation) {
    5857              :                     // CR7608 IF (.not. TurnFansOn .or. .not. AirflowNetworkZoneFlag(zoneNum)) &
    5858         6982 :                     if (!state.dataGlobal->KickOffSimulation) {
    5859         6951 :                         if (!(state.dataZoneEquip->ZoneEquipAvail(zoneNum) == Avail::Status::CycleOn ||
    5860        10773 :                               state.dataZoneEquip->ZoneEquipAvail(zoneNum) == Avail::Status::CycleOnZoneFansOnly) ||
    5861         3822 :                             !state.afn->AirflowNetworkZoneFlag(zoneNum)) {
    5862         3129 :                             state.dataHeatBal->ZnAirRpt(zoneNum).VentilFanElec += thisVentilation.FanPower * state.dataHVACGlobal->TimeStepSysSec;
    5863              :                         }
    5864           31 :                     } else if (!state.afn->AirflowNetworkZoneFlag(zoneNum)) {
    5865            0 :                         state.dataHeatBal->ZnAirRpt(zoneNum).VentilFanElec += thisVentilation.FanPower * state.dataHVACGlobal->TimeStepSysSec;
    5866              :                     }
    5867              :                 } else {
    5868        92417 :                     state.dataHeatBal->ZnAirRpt(zoneNum).VentilFanElec += thisVentilation.FanPower * state.dataHVACGlobal->TimeStepSysSec;
    5869              :                 }
    5870              :             }
    5871              :             // Intake fans will add some heat to the air, raising the temperature for an intake fan...
    5872        99399 :             if (thisVentilation.FanType == DataHeatBalance::VentilationType::Intake ||
    5873        80297 :                 thisVentilation.FanType == DataHeatBalance::VentilationType::Balanced) {
    5874        74696 :                 Real64 OutletAirEnthalpy = 0.0;
    5875        74696 :                 if (VAMFL_temp == 0.0) {
    5876        12368 :                     OutletAirEnthalpy = EnthalpyExt;
    5877              :                 } else {
    5878        62328 :                     if (thisVentilation.FanPower > 0.0) {
    5879        62328 :                         if (thisVentilation.FanType == DataHeatBalance::VentilationType::Balanced) {
    5880        55594 :                             OutletAirEnthalpy = EnthalpyExt + thisVentilation.FanPower / VAMFL_temp / 2.0; // Half fan power to calculate inlet T
    5881              :                         } else {
    5882         6734 :                             OutletAirEnthalpy = EnthalpyExt + thisVentilation.FanPower / VAMFL_temp;
    5883              :                         }
    5884              :                     } else {
    5885            0 :                         OutletAirEnthalpy = EnthalpyExt;
    5886              :                     }
    5887              :                 }
    5888        74696 :                 thisVentilation.AirTemp = Psychrometrics::PsyTdbFnHW(OutletAirEnthalpy, HumRatExt);
    5889        74696 :             } else {
    5890        24703 :                 thisVentilation.AirTemp = TempExt;
    5891              :             }
    5892        99399 :             if (!state.dataHeatBal->Zone(zoneNum).zoneOAQuadratureSum) {
    5893        97723 :                 thisMCPTV = thisVentilation.MCP * thisVentilation.AirTemp;
    5894              :             }
    5895       107012 :         } else if (thisVentilation.ModelType == DataHeatBalance::VentilationModelType::WindAndStack) {
    5896       107012 :             Real64 Cw = 0.0;    // Opening effectivenss
    5897       107012 :             Real64 Cd = 0.0;    // Discharge coefficent
    5898       107012 :             Real64 angle = 0.0; // Angle between wind direction and effective angle
    5899       107012 :             Real64 Qw = 0.0;    // Volumetric flow driven by wind
    5900       107012 :             Real64 Qst = 0.0;   // Volumetric flow driven by stack effect
    5901       107012 :             if (thisVentilation.OpenEff != Constant::AutoCalculate) {
    5902         1233 :                 Cw = thisVentilation.OpenEff;
    5903              :             } else {
    5904              :                 //   Wind Dir (β1)                                        90°, min effectiveness
    5905              :                 //           ▲                                     (ϕ3) .  ▲
    5906              :                 //     .   ϕ │    Opening Normal (α)                       │  .  Angle (ϕ1)
    5907              :                 //      . ┌──┼─┐ x    . (β4)                     Wind      │
    5908              :                 //       .▼  │ ▼x   .                  <=>       Blowing   │
    5909              :                 //        .  │ x  .                              Opposite  │         . (ϕ4)
    5910              :                 //         . │x                                  Side      │
    5911              :                 //  ─────────┼─────────► North = 0°          (ϕ2).─────────┴─────────► Opening Normal = 0°, max effectiveness
    5912              :                 //          .│.
    5913              :                 //         . │ .
    5914              :                 //        .  │  .
    5915              :                 //  (β2) .   │   . (β3)
    5916              :                 //
    5917              :                 // This is the absolute angle between opening normal and the wind direction, in the [0, 180] range:
    5918              :                 // * 0 means that it's blowing directly towards the opening (what ASHRAE HoF calls "Perpendicular winds"), so maximum
    5919              :                 // effectiveness
    5920              :                 //       │  │
    5921              :                 //       ▼  ▼
    5922              :                 //    ┌──====──┐
    5923              :                 //    │        │
    5924              :                 //    └────────┘
    5925              :                 //
    5926              :                 // * 90 means that the wind direction is perpendicular to the normal (the wind is blowing parallel to the opening's plane), so
    5927              :                 // effectiveness is very small
    5928              :                 //      ~~~~►
    5929              :                 //      ~~~~►
    5930              :                 //    ┌──====──┐
    5931              :                 //    │        │
    5932              :                 //    └────────┘
    5933              :                 //
    5934              :                 // * Anything >90 means the wind is blowing in the opposite direction (on the other side), so effectiveness is nil
    5935              :                 //    ┌──====──┐
    5936              :                 //    │        │
    5937              :                 //    └────────┘
    5938              :                 //       ▲  ▲
    5939              :                 //       │  │
    5940              : 
    5941       105779 :                 angle = 180.0 - std::abs(std::abs(WindDirExt - thisVentilation.EffAngle) - 180);
    5942       105779 :                 if (angle > 90.0) {
    5943        54760 :                     Cw = 0.0; // blowing on the opposite side of the opening
    5944              :                 } else {
    5945              :                     // Linear interpolation between effective angle and wind direction
    5946              :                     // ASHRAE HoF 2009 (Ch 16.14, Equation 37), Q = Cw*A*U, and it describes Cw as :
    5947              :                     // > Cw = effectiness of openings (Cw is assumed to be 0.5 to 0.6 for perpendicular winds and 0.25 to 0.35 for diagonal winds)
    5948              :                     //
    5949              :                     // | ASHRAE description  | min  | max  | mean | Angle* |
    5950              :                     // |---------------------|------|------|------|--------|
    5951              :                     // | Perpendicular winds | 0.5  | 0.6  | 0.55 | 0      |
    5952              :                     // | Diagonal winds      | 0.25 | 0.35 | 0.3  | 45     |
    5953              :                     //
    5954              :                     // * Angle is using our convention described above
    5955        51019 :                     constexpr Real64 slope = (0.3 - 0.55) / (45 - 0.0);
    5956        51019 :                     constexpr Real64 intercept = 0.55;
    5957        51019 :                     Cw = intercept + angle * slope;
    5958              :                 }
    5959              :             }
    5960       107012 :             if (thisVentilation.DiscCoef != Constant::AutoCalculate) {
    5961         1233 :                 Cd = thisVentilation.DiscCoef;
    5962              :             } else {
    5963       105779 :                 Cd = 0.40 + 0.0045 * std::abs(TempExt - thisMixingMAT);
    5964              :             }
    5965       107012 :             Qw = Cw * thisVentilation.OpenArea * thisVentilation.openAreaFracSched->getCurrentVal() * WindSpeedExt;
    5966       107012 :             Qst = Cd * thisVentilation.OpenArea * thisVentilation.openAreaFracSched->getCurrentVal() *
    5967       107012 :                   std::sqrt(2.0 * 9.81 * thisVentilation.DH * std::abs(TempExt - thisMixingMAT) / (thisMixingMAT + 273.15));
    5968       107012 :             Real64 VVF = std::sqrt(Qw * Qw + Qst * Qst); // VENTILATION FLOW RATE (M**3/SEC)
    5969       107012 :             if (thisVentilation.EMSSimpleVentOn) {
    5970            0 :                 VVF = thisVentilation.EMSimpleVentFlowRate;
    5971              :             }
    5972       107012 :             if (VVF < 0.0) {
    5973            0 :                 VVF = 0.0;
    5974              :             }
    5975       107012 :             thisVentilation.MCP = VVF * AirDensity * CpAir;
    5976       107012 :             if (thisVentilation.MCP < 0.0) {
    5977            0 :                 thisVentilation.MCP = 0.0;
    5978              :             }
    5979       107012 :             if (state.dataHeatBal->Zone(zoneNum).zoneOAQuadratureSum) {
    5980            0 :                 state.dataHeatBal->ZoneAirBalance(state.dataHeatBal->Zone(zoneNum).zoneOABalanceIndex).NatMassFlowRate += thisVentilation.MCP / CpAir;
    5981              :             } else {
    5982       107012 :                 thisMCPV = thisVentilation.MCP;
    5983       107012 :                 thisVAMFL = thisVentilation.MCP / CpAir;
    5984       107012 :                 thisVentilation.AirTemp = TempExt;
    5985       107012 :                 thisMCPTV = thisVentilation.MCP * thisVentilation.AirTemp;
    5986              :             }
    5987              :         }
    5988              :         // Accumulate for zone and space
    5989       206411 :         thisZoneHB.MCPV += thisMCPV;
    5990       206411 :         thisZoneHB.VAMFL += thisVAMFL;
    5991       206411 :         thisZoneHB.MCPTV += thisMCPTV;
    5992       206411 :         if (state.dataHeatBal->doSpaceHeatBalance) {
    5993            0 :             auto &thisSpaceHB = state.dataZoneTempPredictorCorrector->spaceHeatBalance(thisVentilation.spaceIndex);
    5994            0 :             thisSpaceHB.MCPV += thisMCPV;
    5995            0 :             thisSpaceHB.VAMFL += thisVAMFL;
    5996            0 :             thisSpaceHB.MCPTV += thisMCPTV;
    5997              :         }
    5998              :     }
    5999              : 
    6000              :     // Process Mixing
    6001      4454175 :     for (int j = 1; j <= state.dataHeatBal->TotMixing; ++j) {
    6002       696502 :         auto &thisMixing = state.dataHeatBal->Mixing(j);
    6003       696502 :         int thisZoneNum = thisMixing.ZonePtr;
    6004       696502 :         auto &thisZoneHB = state.dataZoneTempPredictorCorrector->zoneHeatBalance(thisZoneNum);
    6005       696502 :         int fromZoneNum = thisMixing.FromZone;
    6006       696502 :         Real64 TD = thisMixing.DeltaTemperature; // Delta Temp limit
    6007       696502 :         thisMixing.ReportFlag = false;
    6008              : 
    6009              :         // Get scheduled delta temperature
    6010       696502 :         if (thisMixing.deltaTempSched != nullptr) {
    6011        23018 :             TD = thisMixing.deltaTempSched->getCurrentVal();
    6012              :         }
    6013       696502 :         Real64 TZN = 0.0;      // Temperature of this Zone/Space
    6014       696502 :         Real64 TZM = 0.0;      // Temperature of From Zone/Space
    6015       696502 :         Real64 HumRatZN = 0.0; // HumRat of this Zone/Space
    6016       696502 :         Real64 HumRatZM = 0.0; // HumRat of From Zone/Space
    6017       696502 :         if (state.dataHeatBal->doSpaceHeatBalance) {
    6018            0 :             auto const &thisSpaceHB = state.dataZoneTempPredictorCorrector->spaceHeatBalance(thisMixing.spaceIndex);
    6019            0 :             TZN = thisSpaceHB.MixingMAT;         // Temperature of this Space
    6020            0 :             HumRatZN = thisSpaceHB.MixingHumRat; // HumRat of this Space
    6021            0 :             if (thisMixing.fromSpaceIndex == 0) {
    6022            0 :                 auto const &fromZoneHB = state.dataZoneTempPredictorCorrector->zoneHeatBalance(fromZoneNum);
    6023            0 :                 TZM = fromZoneHB.MixingMAT;         // Temperature of From Zone
    6024            0 :                 HumRatZM = fromZoneHB.MixingHumRat; // HumRat of From Zone
    6025              :             } else {
    6026            0 :                 auto const &fromSpaceHB = state.dataZoneTempPredictorCorrector->spaceHeatBalance(thisMixing.fromSpaceIndex);
    6027            0 :                 TZM = fromSpaceHB.MixingMAT;         // Temperature of From Space
    6028            0 :                 HumRatZM = fromSpaceHB.MixingHumRat; // HumRat of From Space
    6029              :             }
    6030              :         } else {
    6031       696502 :             auto const &fromZoneHB = state.dataZoneTempPredictorCorrector->zoneHeatBalance(fromZoneNum);
    6032       696502 :             TZN = thisZoneHB.MixingMAT;         // Temperature of this zone
    6033       696502 :             TZM = fromZoneHB.MixingMAT;         // Temperature of From Zone
    6034       696502 :             HumRatZN = thisZoneHB.MixingHumRat; // HumRat of this zone
    6035       696502 :             HumRatZM = fromZoneHB.MixingHumRat; // HumRat of From Zone
    6036              :         }
    6037       696502 :         Real64 thisMCPM = 0.0;
    6038       696502 :         Real64 thisMCPTM = 0.0;
    6039       696502 :         Real64 thisMixingMassFlow = 0.0;
    6040       696502 :         Real64 thisMixingMassFlowXHumRat = 0.0;
    6041              : 
    6042              :         // Hybrid ventilation controls
    6043       696502 :         if (thisMixing.HybridControlType == DataHeatBalance::HybridCtrlType::Close) {
    6044        10704 :             continue;
    6045              :         }
    6046              :         // Check temperature limit
    6047       685798 :         bool MixingLimitFlag = false;
    6048              : 
    6049              :         // Hybrid ventilation global control
    6050       685798 :         if (thisMixing.HybridControlType == DataHeatBalance::HybridCtrlType::Global && thisMixing.HybridControlMasterNum > 0) {
    6051         2011 :             int I = thisMixing.HybridControlMasterNum;
    6052         2011 :             if (!state.dataHeatBal->Ventilation(I).HybridControlMasterStatus) {
    6053          407 :                 continue;
    6054              :             }
    6055         1604 :         } else {
    6056              :             // Ensure the minimum indoor temperature <= the maximum indoor temperature
    6057       683787 :             Real64 MixingTmin = 0.0;
    6058       683787 :             Real64 MixingTmax = 0.0;
    6059       683787 :             if (thisMixing.minIndoorTempSched != nullptr) {
    6060        10303 :                 MixingTmin = thisMixing.minIndoorTempSched->getCurrentVal();
    6061              :             }
    6062       683787 :             if (thisMixing.maxIndoorTempSched != nullptr) {
    6063        10303 :                 MixingTmax = thisMixing.maxIndoorTempSched->getCurrentVal();
    6064              :             }
    6065       683787 :             if (thisMixing.minIndoorTempSched != nullptr && thisMixing.maxIndoorTempSched != nullptr) {
    6066        10303 :                 if (MixingTmin > MixingTmax) {
    6067            0 :                     ++thisMixing.IndoorTempErrCount;
    6068            0 :                     if (thisMixing.IndoorTempErrCount < 2) {
    6069            0 :                         ShowWarningError(
    6070              :                             state,
    6071            0 :                             format("Mixing zone temperature control: The minimum zone temperature is above the maximum zone temperature in {}",
    6072            0 :                                    thisMixing.Name));
    6073            0 :                         ShowContinueError(state, "The minimum zone temperature is set to the maximum zone temperature. Simulation continues.");
    6074            0 :                         ShowContinueErrorTimeStamp(state, " Occurrence info:");
    6075              :                     } else {
    6076            0 :                         ShowRecurringWarningErrorAtEnd(state,
    6077              :                                                        "The minimum zone temperature is still above the maximum zone temperature",
    6078            0 :                                                        thisMixing.IndoorTempErrIndex,
    6079              :                                                        MixingTmin,
    6080              :                                                        MixingTmin);
    6081              :                     }
    6082            0 :                     MixingTmin = MixingTmax;
    6083              :                 }
    6084              :             }
    6085       683787 :             if (thisMixing.minIndoorTempSched != nullptr) {
    6086        10303 :                 if (TZN < MixingTmin) {
    6087            0 :                     MixingLimitFlag = true;
    6088              :                 }
    6089              :             }
    6090       683787 :             if (thisMixing.maxIndoorTempSched != nullptr) {
    6091        10303 :                 if (TZN > MixingTmax) {
    6092            0 :                     MixingLimitFlag = true;
    6093              :                 }
    6094              :             }
    6095              :             // Ensure the minimum source temperature <= the maximum source temperature
    6096       683787 :             if (thisMixing.minSourceTempSched != nullptr) {
    6097        10303 :                 MixingTmin = thisMixing.minSourceTempSched->getCurrentVal();
    6098              :             }
    6099       683787 :             if (thisMixing.maxSourceTempSched != nullptr) {
    6100        10303 :                 MixingTmax = thisMixing.maxSourceTempSched->getCurrentVal();
    6101              :             }
    6102       683787 :             if (thisMixing.minSourceTempSched != nullptr && thisMixing.maxSourceTempSched != nullptr) {
    6103        10303 :                 if (MixingTmin > MixingTmax) {
    6104            0 :                     ++thisMixing.SourceTempErrCount;
    6105            0 :                     if (thisMixing.SourceTempErrCount < 2) {
    6106            0 :                         ShowWarningError(
    6107              :                             state,
    6108            0 :                             format("Mixing source temperature control: The minimum source temperature is above the maximum source temperature in {}",
    6109            0 :                                    thisMixing.Name));
    6110            0 :                         ShowContinueError(state, "The minimum source temperature is set to the maximum source temperature. Simulation continues.");
    6111            0 :                         ShowContinueErrorTimeStamp(state, " Occurrence info:");
    6112              :                     } else {
    6113            0 :                         ShowRecurringWarningErrorAtEnd(state,
    6114              :                                                        "The minimum source temperature is still above the maximum source temperature",
    6115            0 :                                                        thisMixing.SourceTempErrIndex,
    6116              :                                                        MixingTmin,
    6117              :                                                        MixingTmin);
    6118              :                     }
    6119            0 :                     MixingTmin = MixingTmax;
    6120              :                 }
    6121              :             }
    6122       683787 :             if (thisMixing.minSourceTempSched != nullptr) {
    6123        10303 :                 if (TZM < MixingTmin) {
    6124            0 :                     MixingLimitFlag = true;
    6125              :                 }
    6126              :             }
    6127       683787 :             if (thisMixing.maxSourceTempSched != nullptr) {
    6128        10303 :                 if (TZM > MixingTmax) {
    6129            0 :                     MixingLimitFlag = true;
    6130              :                 }
    6131              :             }
    6132              :             // Ensure the minimum outdoor temperature <= the maximum outdoor temperature
    6133       683787 :             Real64 TempExt = state.dataHeatBal->Zone(thisZoneNum).OutDryBulbTemp;
    6134       683787 :             if (thisMixing.minOutdoorTempSched != nullptr) {
    6135        10303 :                 MixingTmin = thisMixing.minOutdoorTempSched->getCurrentVal();
    6136              :             }
    6137       683787 :             if (thisMixing.maxOutdoorTempSched != nullptr) {
    6138        10303 :                 MixingTmax = thisMixing.maxOutdoorTempSched->getCurrentVal();
    6139              :             }
    6140       683787 :             if (thisMixing.minOutdoorTempSched != nullptr && thisMixing.maxOutdoorTempSched != nullptr) {
    6141        10303 :                 if (MixingTmin > MixingTmax) {
    6142            0 :                     ++thisMixing.OutdoorTempErrCount;
    6143            0 :                     if (thisMixing.OutdoorTempErrCount < 2) {
    6144            0 :                         ShowWarningError(state,
    6145            0 :                                          format("Mixing outdoor temperature control: The minimum outdoor temperature is above the maximum "
    6146              :                                                 "outdoor temperature in {}",
    6147            0 :                                                 thisMixing.Name));
    6148            0 :                         ShowContinueError(state, "The minimum outdoor temperature is set to the maximum source temperature. Simulation continues.");
    6149            0 :                         ShowContinueErrorTimeStamp(state, " Occurrence info:");
    6150              :                     } else {
    6151            0 :                         ShowRecurringWarningErrorAtEnd(state,
    6152              :                                                        "The minimum outdoor temperature is still above the maximum outdoor temperature",
    6153            0 :                                                        thisMixing.OutdoorTempErrIndex,
    6154              :                                                        MixingTmin,
    6155              :                                                        MixingTmin);
    6156              :                     }
    6157            0 :                     MixingTmin = MixingTmax;
    6158              :                 }
    6159              :             }
    6160       683787 :             if (thisMixing.minOutdoorTempSched != nullptr) {
    6161        10303 :                 if (TempExt < MixingTmin) {
    6162            0 :                     MixingLimitFlag = true;
    6163              :                 }
    6164              :             }
    6165       683787 :             if (thisMixing.maxOutdoorTempSched != nullptr) {
    6166        10303 :                 if (TempExt > MixingTmax) {
    6167            0 :                     MixingLimitFlag = true;
    6168              :                 }
    6169              :             }
    6170              :         }
    6171              : 
    6172       685391 :         if (thisMixing.HybridControlType != DataHeatBalance::HybridCtrlType::Global && MixingLimitFlag) {
    6173            0 :             continue;
    6174              :         }
    6175       685391 :         if (thisMixing.HybridControlType == DataHeatBalance::HybridCtrlType::Global) {
    6176         1604 :             TD = 0.0;
    6177              :         }
    6178              : 
    6179              :         //            Per Jan 17, 2008 conference call, agreed to use average conditions for Rho, Cp and Hfg
    6180       685391 :         Real64 AirDensity = PsyRhoAirFnPbTdbW(
    6181       685391 :             state, state.dataEnvrn->OutBaroPress, (TZN + TZM) / 2.0, (HumRatZN + HumRatZM) / 2.0, RoutineNameMixing); // Density of air (kg/m^3)
    6182       685391 :         Real64 CpAir = PsyCpAirFnW((HumRatZN + HumRatZM) / 2.0);                                                      // Use average conditions
    6183              : 
    6184              :         //  If TD equals zero (default) set coefficients for full mixing otherwise test
    6185              :         //    for mixing conditions if user input delta temp > 0, then from zone temp (TZM)
    6186              :         //    must be td degrees warmer than zone temp (TZN).  If user input delta temp < 0,
    6187              :         //    then from zone temp (TZM) must be TD degrees cooler than zone temp (TZN).
    6188       685391 :         if (TD < 0.0) {
    6189            0 :             if (TZM < TZN + TD) {
    6190              : 
    6191            0 :                 thisMixing.DesiredAirFlowRate = thisMixing.DesiredAirFlowRateSaved;
    6192            0 :                 if (state.dataHeatBalFanSys->ZoneMassBalanceFlag(thisZoneNum) && AdjustZoneMixingFlowFlag) {
    6193            0 :                     if (thisMixing.MixingMassFlowRate > 0.0) {
    6194            0 :                         thisMixing.DesiredAirFlowRate = thisMixing.MixingMassFlowRate / AirDensity;
    6195              :                     }
    6196              :                 }
    6197            0 :                 thisMixing.MixingMassFlowRate = thisMixing.DesiredAirFlowRate * AirDensity;
    6198              : 
    6199            0 :                 thisMCPM = thisMixing.MixingMassFlowRate * CpAir;
    6200            0 :                 thisMCPTM = thisMCPM * TZN;
    6201              : 
    6202              :                 // Now to determine the moisture conditions
    6203            0 :                 thisMixingMassFlow = thisMixing.DesiredAirFlowRate * AirDensity;
    6204            0 :                 thisMixingMassFlowXHumRat = thisMixing.DesiredAirFlowRate * AirDensity * HumRatZM;
    6205            0 :                 if (state.dataContaminantBalance->Contaminant.CO2Simulation) {
    6206            0 :                     state.dataContaminantBalance->MixingMassFlowCO2(thisZoneNum) +=
    6207            0 :                         thisMixing.DesiredAirFlowRate * AirDensity * state.dataContaminantBalance->ZoneAirCO2(fromZoneNum);
    6208              :                 }
    6209            0 :                 if (state.dataContaminantBalance->Contaminant.GenericContamSimulation) {
    6210            0 :                     state.dataContaminantBalance->MixingMassFlowGC(thisZoneNum) +=
    6211            0 :                         thisMixing.DesiredAirFlowRate * AirDensity * state.dataContaminantBalance->ZoneAirGC(fromZoneNum);
    6212              :                 }
    6213            0 :                 thisMixing.ReportFlag = true;
    6214              :             }
    6215       685391 :         } else if (TD > 0.0) {
    6216         7484 :             if (TZM > TZN + TD) {
    6217            0 :                 thisMixing.DesiredAirFlowRate = thisMixing.DesiredAirFlowRateSaved;
    6218            0 :                 if (state.dataHeatBalFanSys->ZoneMassBalanceFlag(thisZoneNum) && AdjustZoneMixingFlowFlag) {
    6219            0 :                     if (thisMixing.MixingMassFlowRate > 0.0) {
    6220            0 :                         thisMixing.DesiredAirFlowRate = thisMixing.MixingMassFlowRate / AirDensity;
    6221              :                     }
    6222              :                 }
    6223            0 :                 thisMixing.MixingMassFlowRate = thisMixing.DesiredAirFlowRate * AirDensity;
    6224              : 
    6225            0 :                 thisMCPM = thisMixing.MixingMassFlowRate * CpAir;
    6226            0 :                 thisMCPTM = thisMCPM * TZM;
    6227              :                 // Now to determine the moisture conditions
    6228            0 :                 thisMixingMassFlow = thisMixing.MixingMassFlowRate;
    6229            0 :                 thisMixingMassFlowXHumRat = thisMixing.MixingMassFlowRate * HumRatZM;
    6230            0 :                 if (state.dataContaminantBalance->Contaminant.CO2Simulation) {
    6231            0 :                     state.dataContaminantBalance->MixingMassFlowCO2(thisZoneNum) +=
    6232            0 :                         thisMixing.MixingMassFlowRate * state.dataContaminantBalance->ZoneAirCO2(fromZoneNum);
    6233              :                 }
    6234            0 :                 if (state.dataContaminantBalance->Contaminant.GenericContamSimulation) {
    6235            0 :                     state.dataContaminantBalance->MixingMassFlowGC(thisZoneNum) +=
    6236            0 :                         thisMixing.MixingMassFlowRate * state.dataContaminantBalance->ZoneAirGC(fromZoneNum);
    6237              :                 }
    6238            0 :                 thisMixing.ReportFlag = true;
    6239              :             }
    6240       677907 :         } else if (TD == 0.0) {
    6241       677907 :             thisMixing.DesiredAirFlowRate = thisMixing.DesiredAirFlowRateSaved;
    6242       677907 :             if (state.dataHeatBalFanSys->ZoneMassBalanceFlag(thisZoneNum) && AdjustZoneMixingFlowFlag) {
    6243        15148 :                 if (thisMixing.MixingMassFlowRate > 0.0) {
    6244        14224 :                     thisMixing.DesiredAirFlowRate = thisMixing.MixingMassFlowRate / AirDensity;
    6245              :                 }
    6246              :             }
    6247       677907 :             thisMixing.MixingMassFlowRate = thisMixing.DesiredAirFlowRate * AirDensity;
    6248              : 
    6249       677907 :             thisMCPM = thisMixing.MixingMassFlowRate * CpAir;
    6250       677907 :             thisMCPTM = thisMCPM * TZM;
    6251              :             // Now to determine the moisture conditions
    6252       677907 :             thisMixingMassFlow = thisMixing.MixingMassFlowRate;
    6253       677907 :             thisMixingMassFlowXHumRat = thisMixing.MixingMassFlowRate * HumRatZM;
    6254       677907 :             if (state.dataContaminantBalance->Contaminant.CO2Simulation) {
    6255            0 :                 state.dataContaminantBalance->MixingMassFlowCO2(thisZoneNum) +=
    6256            0 :                     thisMixing.MixingMassFlowRate * state.dataContaminantBalance->ZoneAirCO2(fromZoneNum);
    6257              :             }
    6258       677907 :             if (state.dataContaminantBalance->Contaminant.GenericContamSimulation) {
    6259            0 :                 state.dataContaminantBalance->MixingMassFlowGC(thisZoneNum) +=
    6260            0 :                     thisMixing.MixingMassFlowRate * state.dataContaminantBalance->ZoneAirGC(fromZoneNum);
    6261              :             }
    6262       677907 :             thisMixing.ReportFlag = true;
    6263              :         }
    6264              :         // Accumulate for zone and space
    6265       685391 :         thisZoneHB.MCPM += thisMCPM;
    6266       685391 :         thisZoneHB.MCPTM += thisMCPTM;
    6267       685391 :         thisZoneHB.MixingMassFlowZone += thisMixingMassFlow;
    6268       685391 :         thisZoneHB.MixingMassFlowXHumRat += thisMixingMassFlowXHumRat;
    6269       685391 :         if (state.dataHeatBal->doSpaceHeatBalance) {
    6270            0 :             auto &thisSpaceHB = state.dataZoneTempPredictorCorrector->spaceHeatBalance(thisMixing.spaceIndex);
    6271            0 :             thisSpaceHB.MCPM += thisMCPM;
    6272            0 :             thisSpaceHB.MCPTM += thisMCPTM;
    6273            0 :             thisSpaceHB.MixingMassFlowZone += thisMixingMassFlow;
    6274            0 :             thisSpaceHB.MixingMassFlowXHumRat += thisMixingMassFlowXHumRat;
    6275              :         }
    6276              :     }
    6277              : 
    6278              :     //                              COMPUTE CROSS ZONE
    6279              :     //                              AIR MIXING
    6280      3801266 :     for (int j = 1; j <= state.dataHeatBal->TotCrossMixing; ++j) {
    6281        43593 :         auto &thisCrossMixing = state.dataHeatBal->CrossMixing(j);
    6282        43593 :         int thisZoneNum = thisCrossMixing.ZonePtr;
    6283        43593 :         thisCrossMixing.ReportFlag = false;
    6284        43593 :         auto &thisZoneHB = state.dataZoneTempPredictorCorrector->zoneHeatBalance(thisZoneNum);
    6285        43593 :         int fromZoneNum = thisCrossMixing.FromZone;
    6286        43593 :         auto &fromZoneHB = state.dataZoneTempPredictorCorrector->zoneHeatBalance(fromZoneNum);
    6287        43593 :         Real64 TD = thisCrossMixing.DeltaTemperature; // Delta Temp limit
    6288              :         // Get scheduled delta temperature
    6289        43593 :         if (thisCrossMixing.deltaTempSched != nullptr) {
    6290            0 :             TD = thisCrossMixing.deltaTempSched->getCurrentVal();
    6291              :         }
    6292        43593 :         Real64 thisMCPxM = 0.0;
    6293        43593 :         Real64 thisMCPTxM = 0.0;
    6294        43593 :         Real64 thisXMixingMassFlow = 0.0;
    6295        43593 :         Real64 thisXMixingMassFlowXHumRat = 0.0;
    6296        43593 :         Real64 fromMCPxM = 0.0;
    6297        43593 :         Real64 fromMCPTxM = 0.0;
    6298        43593 :         Real64 fromXMixingMassFlowXHumRat = 0.0;
    6299              : 
    6300        43593 :         if (TD >= 0.0) {
    6301        43593 :             Real64 TZN = 0.0;      // Temperature of this Zone/Space
    6302        43593 :             Real64 TZM = 0.0;      // Temperature of From Zone/Space
    6303        43593 :             Real64 HumRatZN = 0.0; // HumRat of this Zone/Space
    6304        43593 :             Real64 HumRatZM = 0.0; // HumRat of From Zone/Space
    6305        43593 :             if (state.dataHeatBal->doSpaceHeatBalance) {
    6306            0 :                 auto const &thisSpaceHB = state.dataZoneTempPredictorCorrector->spaceHeatBalance(thisCrossMixing.spaceIndex);
    6307            0 :                 TZN = thisSpaceHB.MixingMAT;         // Temperature of this Space
    6308            0 :                 HumRatZN = thisSpaceHB.MixingHumRat; // HumRat of this Space
    6309            0 :                 if (thisCrossMixing.fromSpaceIndex == 0) {
    6310            0 :                     TZM = fromZoneHB.MixingMAT;         // Temperature of From Zone
    6311            0 :                     HumRatZM = fromZoneHB.MixingHumRat; // HumRat of From Zone
    6312              :                 } else {
    6313            0 :                     auto const &fromSpaceHB = state.dataZoneTempPredictorCorrector->spaceHeatBalance(thisCrossMixing.fromSpaceIndex);
    6314            0 :                     TZM = fromSpaceHB.MixingMAT;         // Temperature of From Space
    6315            0 :                     HumRatZM = fromSpaceHB.MixingHumRat; // HumRat of From Space
    6316              :                 }
    6317              :             } else {
    6318        43593 :                 TZN = thisZoneHB.MixingMAT;         // Temperature of this zone
    6319        43593 :                 TZM = fromZoneHB.MixingMAT;         // Temperature of From Zone
    6320        43593 :                 HumRatZN = thisZoneHB.MixingHumRat; // HumRat of this zone
    6321        43593 :                 HumRatZM = fromZoneHB.MixingHumRat; // HumRat of From Zone
    6322              :             }
    6323              :             // Check temperature limit
    6324        43593 :             bool MixingLimitFlag = false;
    6325              :             // Ensure the minimum indoor temperature <= the maximum indoor temperature
    6326        43593 :             Real64 MixingTmin = 0.0;
    6327        43593 :             Real64 MixingTmax = 0.0;
    6328        43593 :             if (thisCrossMixing.minIndoorTempSched != nullptr) {
    6329         7484 :                 MixingTmin = thisCrossMixing.minIndoorTempSched->getCurrentVal();
    6330              :             }
    6331        43593 :             if (thisCrossMixing.maxIndoorTempSched != nullptr) {
    6332         7484 :                 MixingTmax = thisCrossMixing.maxIndoorTempSched->getCurrentVal();
    6333              :             }
    6334        43593 :             if (thisCrossMixing.minIndoorTempSched != nullptr && thisCrossMixing.maxIndoorTempSched != nullptr) {
    6335         7484 :                 if (MixingTmin > MixingTmax) {
    6336            0 :                     ++thisCrossMixing.IndoorTempErrCount;
    6337            0 :                     if (thisCrossMixing.IndoorTempErrCount < 2) {
    6338            0 :                         ShowWarningError(
    6339              :                             state,
    6340            0 :                             format("CrossMixing zone temperature control: The minimum zone temperature is above the maximum zone temperature in {}",
    6341            0 :                                    thisCrossMixing.Name));
    6342            0 :                         ShowContinueError(state, "The minimum zone temperature is set to the maximum zone temperature. Simulation continues.");
    6343            0 :                         ShowContinueErrorTimeStamp(state, " Occurrence info:");
    6344              :                     } else {
    6345            0 :                         ShowRecurringWarningErrorAtEnd(state,
    6346              :                                                        "The minimum zone temperature is still above the maximum zone temperature",
    6347            0 :                                                        thisCrossMixing.IndoorTempErrIndex,
    6348              :                                                        MixingTmin,
    6349              :                                                        MixingTmin);
    6350              :                     }
    6351            0 :                     MixingTmin = MixingTmax;
    6352              :                 }
    6353              :             }
    6354        43593 :             if (thisCrossMixing.minIndoorTempSched != nullptr) {
    6355         7484 :                 if (TZN < MixingTmin) {
    6356            0 :                     MixingLimitFlag = true;
    6357              :                 }
    6358              :             }
    6359        43593 :             if (thisCrossMixing.maxIndoorTempSched != nullptr) {
    6360         7484 :                 if (TZN > MixingTmax) {
    6361            0 :                     MixingLimitFlag = true;
    6362              :                 }
    6363              :             }
    6364              :             // Ensure the minimum source temperature <= the maximum source temperature
    6365        43593 :             if (thisCrossMixing.minSourceTempSched != nullptr) {
    6366         7484 :                 MixingTmin = thisCrossMixing.minSourceTempSched->getCurrentVal();
    6367              :             }
    6368        43593 :             if (thisCrossMixing.maxSourceTempSched != nullptr) {
    6369         7484 :                 MixingTmax = thisCrossMixing.maxSourceTempSched->getCurrentVal();
    6370              :             }
    6371        43593 :             if (thisCrossMixing.minSourceTempSched != nullptr && thisCrossMixing.maxSourceTempSched != nullptr) {
    6372         7484 :                 if (MixingTmin > MixingTmax) {
    6373            0 :                     ++thisCrossMixing.SourceTempErrCount;
    6374            0 :                     if (thisCrossMixing.SourceTempErrCount < 2) {
    6375            0 :                         ShowWarningError(state,
    6376            0 :                                          format("CrossMixing source temperature control: The minimum source temperature is above the maximum source "
    6377              :                                                 "temperature in {}",
    6378            0 :                                                 thisCrossMixing.Name));
    6379            0 :                         ShowContinueError(state, "The minimum source temperature is set to the maximum source temperature. Simulation continues.");
    6380            0 :                         ShowContinueErrorTimeStamp(state, " Occurrence info:");
    6381              :                     } else {
    6382            0 :                         ShowRecurringWarningErrorAtEnd(state,
    6383              :                                                        "The minimum source temperature is still above the maximum source temperature",
    6384            0 :                                                        thisCrossMixing.SourceTempErrIndex,
    6385              :                                                        MixingTmin,
    6386              :                                                        MixingTmin);
    6387              :                     }
    6388            0 :                     MixingTmin = MixingTmax;
    6389              :                 }
    6390              :             }
    6391        43593 :             if (thisCrossMixing.minSourceTempSched != nullptr) {
    6392         7484 :                 if (TZM < MixingTmin) {
    6393            0 :                     MixingLimitFlag = true;
    6394              :                 }
    6395              :             }
    6396        43593 :             if (thisCrossMixing.maxSourceTempSched != nullptr) {
    6397         7484 :                 if (TZM > MixingTmax) {
    6398            0 :                     MixingLimitFlag = true;
    6399              :                 }
    6400              :             }
    6401              :             // Ensure the minimum outdoor temperature <= the maximum outdoor temperature
    6402        43593 :             Real64 TempExt = state.dataHeatBal->Zone(thisZoneNum).OutDryBulbTemp;
    6403        43593 :             if (thisCrossMixing.minOutdoorTempSched != nullptr) {
    6404         7484 :                 MixingTmin = thisCrossMixing.minOutdoorTempSched->getCurrentVal();
    6405              :             }
    6406        43593 :             if (thisCrossMixing.maxOutdoorTempSched != nullptr) {
    6407         7484 :                 MixingTmax = thisCrossMixing.maxOutdoorTempSched->getCurrentVal();
    6408              :             }
    6409        43593 :             if (thisCrossMixing.minOutdoorTempSched != nullptr && thisCrossMixing.maxOutdoorTempSched != nullptr) {
    6410         7484 :                 if (MixingTmin > MixingTmax) {
    6411            0 :                     ++thisCrossMixing.OutdoorTempErrCount;
    6412            0 :                     if (thisCrossMixing.OutdoorTempErrCount < 2) {
    6413            0 :                         ShowWarningError(state,
    6414            0 :                                          format("CrossMixing outdoor temperature control: The minimum outdoor temperature is above the maximum "
    6415              :                                                 "outdoor temperature in {}",
    6416            0 :                                                 state.dataHeatBal->Mixing(j).Name));
    6417            0 :                         ShowContinueError(state, "The minimum outdoor temperature is set to the maximum source temperature. Simulation continues.");
    6418            0 :                         ShowContinueErrorTimeStamp(state, " Occurrence info:");
    6419              :                     } else {
    6420            0 :                         ShowRecurringWarningErrorAtEnd(state,
    6421              :                                                        "The minimum outdoor temperature is still above the maximum outdoor temperature",
    6422            0 :                                                        thisCrossMixing.OutdoorTempErrIndex,
    6423              :                                                        MixingTmin,
    6424              :                                                        MixingTmin);
    6425              :                     }
    6426            0 :                     MixingTmin = MixingTmax;
    6427              :                 }
    6428              :             }
    6429        43593 :             if (thisCrossMixing.minOutdoorTempSched != nullptr) {
    6430         7484 :                 if (TempExt < MixingTmin) {
    6431            0 :                     MixingLimitFlag = true;
    6432              :                 }
    6433              :             }
    6434        43593 :             if (thisCrossMixing.maxOutdoorTempSched != nullptr) {
    6435         7484 :                 if (TempExt > MixingTmax) {
    6436            0 :                     MixingLimitFlag = true;
    6437              :                 }
    6438              :             }
    6439        43593 :             if (MixingLimitFlag) {
    6440            0 :                 continue;
    6441              :             }
    6442              : 
    6443        43593 :             if ((TD == 0.0 || (TD > 0.0 && (TZM - TZN) >= TD))) {
    6444        31441 :                 thisCrossMixing.ReportFlag = true;
    6445              :             }
    6446              : 
    6447        43593 :             if ((TD <= 0.0) || (TZM - TZN >= TD)) {
    6448              :                 //                                      SET COEFFICIENTS .
    6449        31441 :                 Real64 Tavg = (TZN + TZM) / 2.0;
    6450        31441 :                 Real64 Wavg = (HumRatZN + HumRatZM) / 2.0;
    6451        31441 :                 Real64 AirDensity = PsyRhoAirFnPbTdbW(state, state.dataEnvrn->OutBaroPress, Tavg, Wavg, RoutineNameCrossMixing);
    6452        31441 :                 Real64 CpAir = PsyCpAirFnW(Wavg);
    6453        31441 :                 thisXMixingMassFlow = thisCrossMixing.DesiredAirFlowRate * AirDensity;
    6454        31441 :                 thisMCPxM = thisXMixingMassFlow * CpAir;
    6455              : 
    6456        31441 :                 fromMCPxM = thisMCPxM;
    6457        31441 :                 thisMCPTxM = thisMCPxM * TZM;
    6458        31441 :                 fromMCPTxM = fromMCPxM * TZN;
    6459              : 
    6460              :                 // Now to determine the moisture conditions
    6461        31441 :                 fromXMixingMassFlowXHumRat = thisXMixingMassFlow * HumRatZN;
    6462        31441 :                 thisXMixingMassFlowXHumRat = thisXMixingMassFlow * HumRatZM;
    6463              : 
    6464        31441 :                 if (state.dataContaminantBalance->Contaminant.CO2Simulation) {
    6465            0 :                     state.dataContaminantBalance->MixingMassFlowCO2(fromZoneNum) +=
    6466            0 :                         thisXMixingMassFlow * state.dataContaminantBalance->ZoneAirCO2(thisZoneNum);
    6467            0 :                     state.dataContaminantBalance->MixingMassFlowCO2(thisZoneNum) +=
    6468            0 :                         thisXMixingMassFlow * state.dataContaminantBalance->ZoneAirCO2(fromZoneNum);
    6469              :                 }
    6470        31441 :                 if (state.dataContaminantBalance->Contaminant.GenericContamSimulation) {
    6471            0 :                     state.dataContaminantBalance->MixingMassFlowGC(fromZoneNum) +=
    6472            0 :                         thisXMixingMassFlow * state.dataContaminantBalance->ZoneAirGC(thisZoneNum);
    6473            0 :                     state.dataContaminantBalance->MixingMassFlowGC(thisZoneNum) +=
    6474            0 :                         thisXMixingMassFlow * state.dataContaminantBalance->ZoneAirGC(fromZoneNum);
    6475              :                 }
    6476              :             }
    6477              :         }
    6478              :         // Accumulate for zone and space
    6479        43593 :         thisZoneHB.MCPM += thisMCPxM;
    6480        43593 :         thisZoneHB.MCPTM += thisMCPTxM;
    6481        43593 :         thisZoneHB.MixingMassFlowZone += thisXMixingMassFlow;
    6482        43593 :         thisZoneHB.MixingMassFlowXHumRat += thisXMixingMassFlowXHumRat;
    6483        43593 :         fromZoneHB.MCPM += fromMCPxM;
    6484        43593 :         fromZoneHB.MCPTM += fromMCPTxM;
    6485        43593 :         fromZoneHB.MixingMassFlowZone += thisXMixingMassFlow;
    6486        43593 :         fromZoneHB.MixingMassFlowXHumRat += fromXMixingMassFlowXHumRat;
    6487        43593 :         if (state.dataHeatBal->doSpaceHeatBalance) {
    6488            0 :             auto &thisSpaceHB = state.dataZoneTempPredictorCorrector->spaceHeatBalance(thisCrossMixing.spaceIndex);
    6489            0 :             thisSpaceHB.MCPM += thisMCPxM;
    6490            0 :             thisSpaceHB.MCPTM += thisMCPTxM;
    6491            0 :             thisSpaceHB.MixingMassFlowZone += thisXMixingMassFlow;
    6492            0 :             thisSpaceHB.MixingMassFlowXHumRat += thisXMixingMassFlowXHumRat;
    6493            0 :             if (thisCrossMixing.fromSpaceIndex > 0) {
    6494            0 :                 auto &fromSpaceHB = state.dataZoneTempPredictorCorrector->spaceHeatBalance(thisCrossMixing.fromSpaceIndex);
    6495            0 :                 fromSpaceHB.MCPM += fromMCPxM;
    6496            0 :                 fromSpaceHB.MCPTM += fromMCPTxM;
    6497            0 :                 fromSpaceHB.MixingMassFlowZone += thisXMixingMassFlow;
    6498            0 :                 fromSpaceHB.MixingMassFlowXHumRat += fromXMixingMassFlowXHumRat;
    6499              :             } else {
    6500              :                 // Allocate mixing flows by space volume fraction of zone volume
    6501            0 :                 for (int spaceNum : state.dataHeatBal->Zone(fromZoneNum).spaceIndexes) {
    6502            0 :                     Real64 spaceFrac = state.dataHeatBal->space(spaceNum).fracZoneVolume;
    6503            0 :                     auto &fromSpaceHB = state.dataZoneTempPredictorCorrector->spaceHeatBalance(spaceNum);
    6504            0 :                     fromSpaceHB.MCPM += fromMCPxM * spaceFrac;
    6505            0 :                     fromSpaceHB.MCPTM += fromMCPTxM * spaceFrac;
    6506            0 :                     fromSpaceHB.MixingMassFlowZone += thisXMixingMassFlow * spaceFrac;
    6507            0 :                     fromSpaceHB.MixingMassFlowXHumRat += fromXMixingMassFlowXHumRat * spaceFrac;
    6508            0 :                 }
    6509              :             }
    6510              :         }
    6511              :     }
    6512              : 
    6513              :     //                              COMPUTE REFRIGERATION DOOR
    6514              :     //                              AIR MIXING
    6515      3757673 :     if (state.dataHeatBal->TotRefDoorMixing > 0) {
    6516              :         // Zone loops structured in getinput so only do each pair of zones bounding door once, even if multiple doors in one zone
    6517       249340 :         for (int ZoneA = 1; ZoneA <= (state.dataGlobal->NumOfZones - 1); ++ZoneA) {
    6518       231530 :             if (!state.dataHeatBal->RefDoorMixing(ZoneA).RefDoorMixFlag) {
    6519       142480 :                 continue;
    6520              :             }
    6521        89050 :             auto &thisRefDoorMixing = state.dataHeatBal->RefDoorMixing(ZoneA);
    6522        89050 :             auto &zoneAHB = state.dataZoneTempPredictorCorrector->zoneHeatBalance(ZoneA);
    6523        89050 :             Real64 TZoneA = zoneAHB.MixingMAT;
    6524        89050 :             Real64 HumRatZoneA = zoneAHB.MixingHumRat;
    6525        89050 :             if ((state.dataHeatBal->doSpaceHeatBalance) && (thisRefDoorMixing.spaceIndex > 0)) {
    6526            0 :                 auto const &spaceAHB = state.dataZoneTempPredictorCorrector->spaceHeatBalance(thisRefDoorMixing.spaceIndex);
    6527            0 :                 TZoneA = spaceAHB.MixingMAT;
    6528            0 :                 HumRatZoneA = spaceAHB.MixingHumRat;
    6529              :             }
    6530        89050 :             Real64 AirDensityZoneA = PsyRhoAirFnPbTdbW(state, state.dataEnvrn->OutBaroPress, TZoneA, HumRatZoneA, RoutineNameRefrigerationDoorMixing);
    6531        89050 :             Real64 CpAirZoneA = PsyCpAirFnW(HumRatZoneA);
    6532       142480 :             for (int j = 1; j <= state.dataHeatBal->RefDoorMixing(ZoneA).NumRefDoorConnections; ++j) {
    6533        53430 :                 int ZoneB = state.dataHeatBal->RefDoorMixing(ZoneA).MateZonePtr(j);
    6534        53430 :                 auto &zoneBHB = state.dataZoneTempPredictorCorrector->zoneHeatBalance(ZoneB);
    6535        53430 :                 Real64 TZoneB = zoneBHB.MixingMAT;
    6536        53430 :                 Real64 HumRatZoneB = zoneBHB.MixingHumRat;
    6537        53430 :                 Real64 CpAirZoneB = PsyCpAirFnW(HumRatZoneB);
    6538        53430 :                 if ((state.dataHeatBal->doSpaceHeatBalance) && (thisRefDoorMixing.fromSpaceIndex > 0)) {
    6539            0 :                     auto const &spaceBHB = state.dataZoneTempPredictorCorrector->spaceHeatBalance(thisRefDoorMixing.fromSpaceIndex);
    6540            0 :                     TZoneB = spaceBHB.MixingMAT;
    6541            0 :                     HumRatZoneB = spaceBHB.MixingHumRat;
    6542              :                 }
    6543        53430 :                 Real64 Tavg = (TZoneA + TZoneB) / 2.0;
    6544        53430 :                 Real64 Wavg = (HumRatZoneA + HumRatZoneB) / 2.0;
    6545        53430 :                 Real64 AirDensityAvg = PsyRhoAirFnPbTdbW(state, state.dataEnvrn->OutBaroPress, Tavg, Wavg, RoutineNameRefrigerationDoorMixing);
    6546              :                 // following variables used for refrigeration door mixing and all defined in EngRef
    6547        53430 :                 Real64 MassFlowDryAir = 0.0;
    6548        53430 :                 Real64 FDens = 0.0;
    6549        53430 :                 Real64 Fb = 0.0;
    6550              : 
    6551        53430 :                 if (state.dataHeatBal->RefDoorMixing(ZoneA).EMSRefDoorMixingOn(j)) {
    6552            0 :                     MassFlowDryAir = state.dataHeatBal->RefDoorMixing(ZoneA).VolRefDoorFlowRate(j) * AirDensityAvg;
    6553              :                 } else {
    6554              :                     Real64 AirDensityZoneB =
    6555        53430 :                         PsyRhoAirFnPbTdbW(state, state.dataEnvrn->OutBaroPress, TZoneB, HumRatZoneB, RoutineNameRefrigerationDoorMixing);
    6556        53430 :                     Real64 SchedDoorOpen = state.dataHeatBal->RefDoorMixing(ZoneA).openScheds(j)->getCurrentVal();
    6557        53430 :                     if (SchedDoorOpen == 0.0) {
    6558        24912 :                         continue;
    6559              :                     }
    6560        28518 :                     Real64 DoorHeight = state.dataHeatBal->RefDoorMixing(ZoneA).DoorHeight(j);
    6561        28518 :                     Real64 DoorArea = state.dataHeatBal->RefDoorMixing(ZoneA).DoorArea(j);
    6562        28518 :                     Real64 DoorProt = state.dataHeatBal->RefDoorMixing(ZoneA).Protection(j);
    6563        28518 :                     if (AirDensityZoneA >= AirDensityZoneB) {
    6564              :                         // Mass of dry air flow between zones is equal,
    6565              :                         // but have to calc directionally to avoid sqrt(neg number)
    6566          669 :                         FDens = std::pow(2.0 / (1.0 + std::pow(AirDensityZoneA / AirDensityZoneB, 1.0 / 3.0)), 1.5);
    6567          669 :                         Fb = 0.221 * DoorArea * AirDensityZoneA * FDens *
    6568          669 :                              std::sqrt((1.0 - AirDensityZoneB / AirDensityZoneA) * StdGravity * DoorHeight);
    6569              :                     } else { // ZoneADens < ZoneBDens
    6570        27849 :                         FDens = std::pow(2.0 / (1.0 + std::pow(AirDensityZoneB / AirDensityZoneA, 1.0 / 3.0)), 1.5);
    6571        27849 :                         Fb = 0.221 * DoorArea * AirDensityZoneB * FDens *
    6572        27849 :                              std::sqrt((1.0 - AirDensityZoneA / AirDensityZoneB) * StdGravity * DoorHeight);
    6573              :                     } // ZoneADens .GE. ZoneBDens
    6574              :                     // FFlow = Doorway flow factor, is determined by temperature difference
    6575        28518 :                     Real64 FFlow = 1.1;
    6576        28518 :                     if (std::abs(TZoneA - TZoneB) > 11.0) {
    6577        18097 :                         FFlow = 0.8;
    6578              :                     }
    6579        28518 :                     MassFlowDryAir = Fb * SchedDoorOpen * FFlow * (1.0 - DoorProt);
    6580        28518 :                     state.dataHeatBal->RefDoorMixing(ZoneA).VolRefDoorFlowRate(j) = MassFlowDryAir / AirDensityAvg;
    6581              :                     // Note - VolRefDoorFlowRate is used ONLY for reporting purposes, where it is
    6582              :                     //       used with the avg density to generate a reported mass flow
    6583              :                     //       Considering the small values typical for HumRat, this is not far off.
    6584              :                 } // EMSRefDoorMixingOn
    6585              : 
    6586        28518 :                 Real64 MassFlowToA = MassFlowDryAir * (1.0 + HumRatZoneB);
    6587        28518 :                 Real64 MassFlowToB = MassFlowDryAir * (1.0 + HumRatZoneA);
    6588        28518 :                 Real64 MassFlowXCpToA = MassFlowToA * CpAirZoneB;
    6589        28518 :                 Real64 MassFlowXCpToB = MassFlowToB * CpAirZoneA;
    6590        28518 :                 Real64 MassFlowXCpXTempToA = MassFlowXCpToA * TZoneB;
    6591        28518 :                 Real64 MassFlowXCpXTempToB = MassFlowXCpToB * TZoneA;
    6592        28518 :                 Real64 MassFlowXHumRatToA = MassFlowToA * HumRatZoneB;
    6593        28518 :                 Real64 MassFlowXHumRatToB = MassFlowToB * HumRatZoneA;
    6594              : 
    6595        28518 :                 zoneAHB.MCPM += MassFlowXCpToA;
    6596        28518 :                 zoneBHB.MCPM += MassFlowXCpToB;
    6597        28518 :                 zoneAHB.MCPTM += MassFlowXCpXTempToA;
    6598        28518 :                 zoneBHB.MCPTM += MassFlowXCpXTempToB;
    6599        28518 :                 zoneAHB.MixingMassFlowZone += MassFlowToA;
    6600        28518 :                 zoneBHB.MixingMassFlowZone += MassFlowToB;
    6601        28518 :                 zoneAHB.MixingMassFlowXHumRat += MassFlowXHumRatToA;
    6602        28518 :                 zoneBHB.MixingMassFlowXHumRat += MassFlowXHumRatToB;
    6603        28518 :                 if (state.dataHeatBal->doSpaceHeatBalance) {
    6604            0 :                     if (thisRefDoorMixing.spaceIndex > 0) {
    6605            0 :                         auto &spaceAHB = state.dataZoneTempPredictorCorrector->spaceHeatBalance(thisRefDoorMixing.spaceIndex);
    6606            0 :                         spaceAHB.MCPM += MassFlowXCpToA;
    6607            0 :                         spaceAHB.MCPTM += MassFlowXCpXTempToA;
    6608            0 :                         spaceAHB.MixingMassFlowZone += MassFlowToA;
    6609            0 :                         spaceAHB.MixingMassFlowXHumRat += MassFlowXHumRatToA;
    6610              :                     } else {
    6611              :                         // Allocate mixing flows by space volume fraction of zone volume
    6612            0 :                         for (int spaceNum : state.dataHeatBal->Zone(ZoneA).spaceIndexes) {
    6613            0 :                             Real64 spaceFrac = state.dataHeatBal->space(spaceNum).fracZoneVolume;
    6614            0 :                             auto &spaceAHB = state.dataZoneTempPredictorCorrector->spaceHeatBalance(spaceNum);
    6615            0 :                             spaceAHB.MCPM += MassFlowXCpToA * spaceFrac;
    6616            0 :                             spaceAHB.MCPTM += MassFlowXCpXTempToA * spaceFrac;
    6617            0 :                             spaceAHB.MixingMassFlowZone += MassFlowToA * spaceFrac;
    6618            0 :                             spaceAHB.MixingMassFlowXHumRat += MassFlowXHumRatToA * spaceFrac;
    6619            0 :                         }
    6620              :                     }
    6621            0 :                     if (thisRefDoorMixing.spaceIndex > 0) {
    6622            0 :                         auto &spaceBHB = state.dataZoneTempPredictorCorrector->spaceHeatBalance(thisRefDoorMixing.fromSpaceIndex);
    6623            0 :                         spaceBHB.MCPM += MassFlowXCpToB;
    6624            0 :                         spaceBHB.MCPTM += MassFlowXCpXTempToB;
    6625            0 :                         spaceBHB.MixingMassFlowZone += MassFlowToB;
    6626            0 :                         spaceBHB.MixingMassFlowXHumRat += MassFlowXHumRatToB;
    6627              :                     } else {
    6628              :                         // Allocate mixing flows by space volume fraction of zone volume
    6629            0 :                         for (int spaceNum : state.dataHeatBal->Zone(ZoneB).spaceIndexes) {
    6630            0 :                             Real64 spaceFrac = state.dataHeatBal->space(spaceNum).fracZoneVolume;
    6631            0 :                             auto &spaceBHB = state.dataZoneTempPredictorCorrector->spaceHeatBalance(spaceNum);
    6632            0 :                             spaceBHB.MCPM += MassFlowXCpToB * spaceFrac;
    6633            0 :                             spaceBHB.MCPTM += MassFlowXCpXTempToB * spaceFrac;
    6634            0 :                             spaceBHB.MixingMassFlowZone += MassFlowToB * spaceFrac;
    6635            0 :                             spaceBHB.MixingMassFlowXHumRat += MassFlowXHumRatToB * spaceFrac;
    6636            0 :                         }
    6637              :                     }
    6638              :                 }
    6639              : 
    6640              :                 // Now to determine the CO2 and generic contaminant conditions
    6641        28518 :                 if (state.dataContaminantBalance->Contaminant.CO2Simulation) {
    6642        28518 :                     state.dataContaminantBalance->MixingMassFlowCO2(ZoneA) += MassFlowToA * state.dataContaminantBalance->ZoneAirCO2(ZoneB);
    6643        28518 :                     state.dataContaminantBalance->MixingMassFlowCO2(ZoneB) += MassFlowToB * state.dataContaminantBalance->ZoneAirCO2(ZoneA);
    6644              :                 }
    6645        28518 :                 if (state.dataContaminantBalance->Contaminant.GenericContamSimulation) {
    6646        28518 :                     state.dataContaminantBalance->MixingMassFlowGC(ZoneA) += MassFlowToA * state.dataContaminantBalance->ZoneAirGC(ZoneB);
    6647        28518 :                     state.dataContaminantBalance->MixingMassFlowGC(ZoneB) += MassFlowToB * state.dataContaminantBalance->ZoneAirGC(ZoneA);
    6648              :                 }
    6649              : 
    6650              :             } // J=1,RefDoorMixing(ZoneA)%NumRefDoorConnections
    6651              :         } // ZoneA=1,(NumOfZones - 1)
    6652              :     } //(TotRefrigerationDoorMixing > 0) THEN
    6653              : 
    6654              :     // Process the scheduled Infiltration for air heat balance depending on model type
    6655     26641773 :     for (int j = 1; j <= state.dataHeatBal->TotInfiltration; ++j) {
    6656              : 
    6657     22884100 :         auto &thisInfiltration = state.dataHeatBal->Infiltration(j);
    6658     22884100 :         int NZ = state.dataHeatBal->Infiltration(j).ZonePtr;
    6659     22884100 :         auto &thisZoneHB = state.dataZoneTempPredictorCorrector->zoneHeatBalance(NZ);
    6660     22884100 :         Real64 tempInt = 0.0;
    6661     22884100 :         if (state.dataHeatBal->doSpaceHeatBalance) {
    6662        75761 :             tempInt = state.dataZoneTempPredictorCorrector->spaceHeatBalance(thisInfiltration.spaceIndex).MixingMAT;
    6663              :         } else {
    6664     22808339 :             tempInt = thisZoneHB.MixingMAT;
    6665              :         }
    6666              : 
    6667     22884100 :         Real64 TempExt = state.dataHeatBal->Zone(NZ).OutDryBulbTemp;
    6668     22884100 :         Real64 WindSpeedExt = state.dataHeatBal->Zone(NZ).WindSpeed;
    6669              : 
    6670              :         // Use air node information linked to the zone if defined
    6671     22884100 :         Real64 HumRatExt = 0.0;
    6672     22884100 :         if (state.dataHeatBal->Zone(NZ).LinkedOutAirNode > 0) {
    6673         1834 :             HumRatExt = state.dataLoopNodes->Node(state.dataHeatBal->Zone(NZ).LinkedOutAirNode).HumRat;
    6674              :         } else {
    6675     22882266 :             HumRatExt = state.dataEnvrn->OutHumRat;
    6676              :         }
    6677              : 
    6678     22884100 :         Real64 AirDensity = 0.0; // Density of air for converting from volume flow to mass flow (kg/m^3)
    6679     22884100 :         switch (thisInfiltration.densityBasis) {
    6680            0 :         case DataHeatBalance::InfVentDensityBasis::Standard: {
    6681            0 :             AirDensity = state.dataEnvrn->StdRhoAir;
    6682            0 :         } break;
    6683            0 :         case DataHeatBalance::InfVentDensityBasis::Indoor: {
    6684            0 :             if (state.dataHeatBal->doSpaceHeatBalance) {
    6685            0 :                 auto &thisSpaceHB = state.dataZoneTempPredictorCorrector->spaceHeatBalance(thisInfiltration.spaceIndex);
    6686            0 :                 AirDensity = Psychrometrics::PsyRhoAirFnPbTdbW(
    6687            0 :                     state, state.dataEnvrn->OutBaroPress, tempInt, thisSpaceHB.MixingHumRat, RoutineNameInfiltration);
    6688              :             } else {
    6689            0 :                 AirDensity = Psychrometrics::PsyRhoAirFnPbTdbW(
    6690            0 :                     state, state.dataEnvrn->OutBaroPress, tempInt, thisZoneHB.MixingHumRat, RoutineNameInfiltration);
    6691              :             }
    6692            0 :         } break;
    6693     22884100 :         default:
    6694     22884100 :             AirDensity = PsyRhoAirFnPbTdbW(state, state.dataEnvrn->OutBaroPress, TempExt, HumRatExt, RoutineNameInfiltration);
    6695     22884100 :             break;
    6696              :         }
    6697              : 
    6698     22884100 :         Real64 CpAir = PsyCpAirFnW(HumRatExt);
    6699     22884100 :         Real64 MCpI_temp = 0.0;
    6700     22884100 :         Real64 scheduleFrac = thisInfiltration.sched->getCurrentVal();
    6701     22884100 :         if (scheduleFrac > 0.0) {
    6702              :             // CR7751  should maybe use code below, indoor conditions instead of outdoor conditions
    6703              :             //   AirDensity = PsyRhoAirFnPbTdbW(state, OutBaroPress, MixingMAT(NZ), MixingHumRat(NZ))
    6704              :             //   CpAir = PsyCpAirFnW(MixingHumRat(NZ),MixingMAT(NZ))
    6705     19538060 :             switch (thisInfiltration.ModelType) {
    6706     19505448 :             case DataHeatBalance::InfiltrationModelType::DesignFlowRate: {
    6707     19505448 :                 Real64 IVF = thisInfiltration.DesignLevel * scheduleFrac; // INFILTRATION FLOW RATE (M**3/SEC)
    6708              :                 // CR6845 if calculated < 0.0, don't propagate
    6709     19505448 :                 if (IVF < 0.0) {
    6710            0 :                     IVF = 0.0;
    6711              :                 }
    6712     39010896 :                 MCpI_temp = IVF * AirDensity * CpAir *
    6713     19505448 :                             (thisInfiltration.ConstantTermCoef + std::abs(TempExt - tempInt) * thisInfiltration.TemperatureTermCoef +
    6714     19505448 :                              WindSpeedExt * (thisInfiltration.VelocityTermCoef + WindSpeedExt * thisInfiltration.VelocitySQTermCoef));
    6715              : 
    6716     19505448 :                 if (MCpI_temp < 0.0) {
    6717            0 :                     MCpI_temp = 0.0;
    6718              :                 }
    6719     19505448 :                 thisInfiltration.VolumeFlowRate = MCpI_temp / AirDensity / CpAir;
    6720     19505448 :             } break;
    6721        16306 :             case DataHeatBalance::InfiltrationModelType::ShermanGrimsrud: {
    6722              :                 // Sherman Grimsrud model as formulated in ASHRAE HoF
    6723        16306 :                 WindSpeedExt = state.dataEnvrn->WindSpeed; // formulated to use wind at Meterological Station rather than local
    6724        16306 :                 Real64 IVF = scheduleFrac * thisInfiltration.LeakageArea / 1000.0 *
    6725        16306 :                              std::sqrt(thisInfiltration.BasicStackCoefficient * std::abs(TempExt - tempInt) +
    6726        16306 :                                        thisInfiltration.BasicWindCoefficient * pow_2(WindSpeedExt));
    6727        16306 :                 if (IVF < 0.0) {
    6728            0 :                     IVF = 0.0;
    6729              :                 }
    6730        16306 :                 MCpI_temp = IVF * AirDensity * CpAir;
    6731        16306 :                 if (MCpI_temp < 0.0) {
    6732            0 :                     MCpI_temp = 0.0;
    6733              :                 }
    6734        16306 :                 thisInfiltration.VolumeFlowRate = MCpI_temp / AirDensity / CpAir;
    6735        16306 :             } break;
    6736        16306 :             case DataHeatBalance::InfiltrationModelType::AIM2: {
    6737              :                 // Walker Wilson model as formulated in ASHRAE HoF
    6738              :                 Real64 IVF =
    6739        48918 :                     scheduleFrac * std::sqrt(pow_2(thisInfiltration.FlowCoefficient * thisInfiltration.AIM2StackCoefficient *
    6740        16306 :                                                    std::pow(std::abs(TempExt - tempInt), thisInfiltration.PressureExponent)) +
    6741        16306 :                                              pow_2(thisInfiltration.FlowCoefficient * thisInfiltration.AIM2WindCoefficient *
    6742        16306 :                                                    std::pow(thisInfiltration.ShelterFactor * WindSpeedExt, 2.0 * thisInfiltration.PressureExponent)));
    6743        16306 :                 if (IVF < 0.0) {
    6744            0 :                     IVF = 0.0;
    6745              :                 }
    6746        16306 :                 MCpI_temp = IVF * AirDensity * CpAir;
    6747        16306 :                 if (MCpI_temp < 0.0) {
    6748            0 :                     MCpI_temp = 0.0;
    6749              :                 }
    6750        16306 :                 thisInfiltration.VolumeFlowRate = MCpI_temp / AirDensity / CpAir;
    6751        16306 :             } break;
    6752            0 :             default:
    6753            0 :                 break;
    6754              :             }
    6755              :         } else {
    6756      3346040 :             thisInfiltration.VolumeFlowRate = 0.0;
    6757      3346040 :             MCpI_temp = 0.0;
    6758              :         }
    6759              : 
    6760     22884100 :         if (AdjustZoneInfiltrationFlowFlag && state.dataHeatBalFanSys->ZoneInfiltrationFlag(NZ)) {
    6761        10379 :             if (state.dataHeatBal->ZoneAirMassFlow.InfiltrationTreatment == DataHeatBalance::InfiltrationFlow::Adjust) {
    6762         7600 :                 if (thisInfiltration.MassFlowRate > 0.0 || thisInfiltration.ModelType == DataHeatBalance::InfiltrationModelType::DesignFlowRate) {
    6763              :                     // For DesignFlowRate, allow exfiltraion
    6764         7600 :                     thisInfiltration.VolumeFlowRate = thisInfiltration.MassFlowRate / AirDensity;
    6765         7600 :                     MCpI_temp = thisInfiltration.VolumeFlowRate * AirDensity * CpAir;
    6766              :                 }
    6767              :             }
    6768        10379 :             if (state.dataHeatBal->ZoneAirMassFlow.InfiltrationTreatment == DataHeatBalance::InfiltrationFlow::Add) {
    6769         2779 :                 thisInfiltration.VolumeFlowRate =
    6770         2779 :                     thisInfiltration.VolumeFlowRate + state.dataHeatBal->MassConservation(NZ).InfiltrationMassFlowRate / AirDensity;
    6771         2779 :                 MCpI_temp = thisInfiltration.VolumeFlowRate * AirDensity * CpAir;
    6772              :             }
    6773              :         }
    6774     22884100 :         thisInfiltration.MassFlowRate = thisInfiltration.VolumeFlowRate * AirDensity;
    6775              : 
    6776     22884100 :         if (thisInfiltration.EMSOverrideOn) {
    6777        38660 :             Real64 IVF = thisInfiltration.EMSAirFlowRateValue; // INFILTRATION FLOW RATE (M**3/SEC)
    6778        38660 :             if (IVF < 0.0) {
    6779            0 :                 IVF = 0.0;
    6780              :             }
    6781        38660 :             MCpI_temp = IVF * AirDensity * CpAir;
    6782        38660 :             if (MCpI_temp < 0.0) {
    6783            0 :                 MCpI_temp = 0.0;
    6784              :             }
    6785              :         }
    6786              : 
    6787     22884100 :         if (state.dataHeatBal->Zone(NZ).zoneOAQuadratureSum) {
    6788        14317 :             state.dataHeatBal->ZoneAirBalance(state.dataHeatBal->Zone(NZ).zoneOABalanceIndex).InfMassFlowRate += MCpI_temp / CpAir;
    6789              :         } else {
    6790     22869783 :             thisInfiltration.MCpI_temp = MCpI_temp;
    6791     22869783 :             thisZoneHB.MCPI += MCpI_temp;
    6792     22869783 :             thisZoneHB.OAMFL += MCpI_temp / CpAir;
    6793     22869783 :             thisZoneHB.MCPTI += MCpI_temp * TempExt;
    6794     22869783 :             if (state.dataHeatBal->doSpaceHeatBalance) {
    6795        75761 :                 auto &thisSpaceHB = state.dataZoneTempPredictorCorrector->spaceHeatBalance(thisInfiltration.spaceIndex);
    6796        75761 :                 thisSpaceHB.MCPI += MCpI_temp;
    6797        75761 :                 thisSpaceHB.OAMFL += MCpI_temp / CpAir;
    6798        75761 :                 thisSpaceHB.MCPTI += MCpI_temp * TempExt;
    6799              :             }
    6800              :         }
    6801              :     }
    6802              : 
    6803              :     // Add infiltration rate enhanced by the existence of thermal chimney
    6804     34654398 :     for (auto &thisZoneHB : state.dataZoneTempPredictorCorrector->zoneHeatBalance) {
    6805     30896725 :         thisZoneHB.MCPI += thisZoneHB.MCPThermChim;
    6806     30896725 :         thisZoneHB.OAMFL += thisZoneHB.ThermChimAMFL;
    6807     30896725 :         thisZoneHB.MCPTI += thisZoneHB.MCPTThermChim;
    6808      3757673 :     }
    6809      3757673 :     if (state.dataHeatBal->doSpaceHeatBalance) {
    6810        97027 :         for (auto &thisSpaceHB : state.dataZoneTempPredictorCorrector->spaceHeatBalance) {
    6811        86394 :             thisSpaceHB.MCPI += thisSpaceHB.MCPThermChim;
    6812        86394 :             thisSpaceHB.OAMFL += thisSpaceHB.ThermChimAMFL;
    6813        86394 :             thisSpaceHB.MCPTI += thisSpaceHB.MCPTThermChim;
    6814        10633 :         }
    6815              :     }
    6816              : 
    6817              :     // Calculate combined outdoor air flows
    6818      3771990 :     for (auto &thisZoneAirBalance : state.dataHeatBal->ZoneAirBalance) {
    6819        14317 :         if (thisZoneAirBalance.BalanceMethod == DataHeatBalance::AirBalance::Quadrature) {
    6820        14317 :             if (!thisZoneAirBalance.OneTimeFlag) {
    6821            1 :                 GetStandAloneERVNodes(state, thisZoneAirBalance);
    6822              :             }
    6823        14317 :             if (thisZoneAirBalance.NumOfERVs > 0) {
    6824            0 :                 for (int I = 1; I <= thisZoneAirBalance.NumOfERVs; ++I) {
    6825            0 :                     Real64 MassFlowDiff = state.dataLoopNodes->Node(thisZoneAirBalance.ERVExhaustNode(I)).MassFlowRate -
    6826            0 :                                           state.dataLoopNodes->Node(thisZoneAirBalance.ERVInletNode(I)).MassFlowRate;
    6827            0 :                     if (MassFlowDiff > 0.0) {
    6828            0 :                         thisZoneAirBalance.ERVMassFlowRate += MassFlowDiff;
    6829              :                     }
    6830              :                 }
    6831              :             }
    6832        14317 :             int NZ = thisZoneAirBalance.ZonePtr;
    6833        14317 :             auto &thisZoneHB = state.dataZoneTempPredictorCorrector->zoneHeatBalance(NZ);
    6834              :             // Use air node information linked to the zone if defined
    6835        14317 :             Real64 HumRatExt = 0.0;
    6836        14317 :             if (state.dataHeatBal->Zone(NZ).LinkedOutAirNode > 0) {
    6837            0 :                 HumRatExt = state.dataLoopNodes->Node(state.dataHeatBal->Zone(NZ).LinkedOutAirNode).HumRat;
    6838              :             } else {
    6839        14317 :                 HumRatExt = state.dataEnvrn->OutHumRat;
    6840              :             }
    6841        14317 :             Real64 AirDensity = Psychrometrics::PsyRhoAirFnPbTdbW(
    6842        14317 :                 state, state.dataEnvrn->OutBaroPress, state.dataHeatBal->Zone(NZ).OutDryBulbTemp, HumRatExt, RoutineNameZoneAirBalance);
    6843        14317 :             Real64 CpAir = Psychrometrics::PsyCpAirFnW(HumRatExt);
    6844        14317 :             thisZoneAirBalance.ERVMassFlowRate *= AirDensity;
    6845        14317 :             thisZoneHB.MDotOA =
    6846        14317 :                 std::sqrt(pow_2(thisZoneAirBalance.NatMassFlowRate) + pow_2(thisZoneAirBalance.IntMassFlowRate) +
    6847        14317 :                           pow_2(thisZoneAirBalance.ExhMassFlowRate) + pow_2(thisZoneAirBalance.ERVMassFlowRate) +
    6848        14317 :                           pow_2(thisZoneAirBalance.InfMassFlowRate) +
    6849        14317 :                           pow_2(AirDensity * thisZoneAirBalance.InducedAirRate * thisZoneAirBalance.inducedAirSched->getCurrentVal())) +
    6850        14317 :                 thisZoneAirBalance.BalMassFlowRate;
    6851        14317 :             thisZoneHB.MDotCPOA = thisZoneHB.MDotOA * CpAir;
    6852              :         }
    6853      3757673 :     }
    6854              : }
    6855              : 
    6856            1 : void GetStandAloneERVNodes(EnergyPlusData &state, DataHeatBalance::ZoneAirBalanceData &thisZoneAirBalance)
    6857              : {
    6858              : 
    6859              :     // SUBROUTINE INFORMATION:
    6860              :     //       AUTHOR         Lixing Gu
    6861              :     //       DATE WRITTEN   July 2010
    6862              : 
    6863              :     // PURPOSE OF THIS SUBROUTINE:
    6864              :     // This subroutine gets node numbers of stand alone ERVs to calculate combined outdoor air flows.
    6865              : 
    6866              :     // METHODOLOGY EMPLOYED:
    6867              :     // Uses program data structures ZoneEquipInfo
    6868              : 
    6869            1 :     if (allocated(state.dataZoneEquip->ZoneEquipList)) {
    6870            1 :         int ZoneNum = thisZoneAirBalance.ZonePtr;
    6871            1 :         thisZoneAirBalance.OneTimeFlag = true;
    6872            1 :         if (state.dataZoneEquip->ZoneEquipList(ZoneNum).NumOfEquipTypes > 0) {
    6873            2 :             for (int I = 1; I <= state.dataZoneEquip->ZoneEquipList(ZoneNum).NumOfEquipTypes; ++I) {
    6874            1 :                 if (state.dataZoneEquip->ZoneEquipList(ZoneNum).EquipType(I) == DataZoneEquipment::ZoneEquipType::EnergyRecoveryVentilator) {
    6875            0 :                     ++thisZoneAirBalance.NumOfERVs;
    6876              :                 }
    6877              :             }
    6878            1 :             if (thisZoneAirBalance.NumOfERVs > 0) {
    6879            0 :                 thisZoneAirBalance.ERVInletNode.allocate(thisZoneAirBalance.NumOfERVs);
    6880            0 :                 thisZoneAirBalance.ERVExhaustNode.allocate(thisZoneAirBalance.NumOfERVs);
    6881            0 :                 int j = 1;
    6882            0 :                 for (int I = 1; I <= state.dataZoneEquip->ZoneEquipList(ZoneNum).NumOfEquipTypes; ++I) {
    6883            0 :                     if (state.dataZoneEquip->ZoneEquipList(ZoneNum).EquipType(I) == DataZoneEquipment::ZoneEquipType::EnergyRecoveryVentilator) {
    6884            0 :                         thisZoneAirBalance.ERVInletNode(j) =
    6885            0 :                             HVACStandAloneERV::GetStandAloneERVOutAirNode(state, state.dataZoneEquip->ZoneEquipList(ZoneNum).EquipIndex(I));
    6886            0 :                         thisZoneAirBalance.ERVExhaustNode(j) =
    6887            0 :                             HVACStandAloneERV::GetStandAloneERVReturnAirNode(state, state.dataZoneEquip->ZoneEquipList(ZoneNum).EquipIndex(I));
    6888            0 :                         ++j;
    6889              :                     }
    6890              :                 }
    6891              :             }
    6892              :         }
    6893              :     }
    6894            1 : }
    6895              : 
    6896       597505 : void CalcZoneMixingFlowRateOfReceivingZone(EnergyPlusData &state, int const ZoneNum, Real64 &ZoneMixingMassFlowRate)
    6897              : {
    6898              : 
    6899              :     // SUBROUTINE INFORMATION:
    6900              :     //       AUTHOR         Bereket Nigusse
    6901              :     //       DATE WRITTEN   February 2014
    6902              : 
    6903              :     // PURPOSE OF THIS SUBROUTINE:
    6904              :     // This subroutine updates the receiving zone mixing flow rate to ensures the zone air mass balance.
    6905              : 
    6906       597505 :     auto &massConservation = state.dataHeatBal->MassConservation(ZoneNum);
    6907              : 
    6908       597505 :     Real64 MixingMassFlowRate = 0.0; // current zone mixing mass flow rate, [kg/s]
    6909       597505 :     int NumOfReceivingZoneMixingObjects = massConservation.NumReceivingZonesMixingObject;
    6910       597505 :     if (NumOfReceivingZoneMixingObjects > 0) {
    6911              :         // distribute the total zone mixing flow rate to the source zones
    6912       597505 :         for (int Loop = 1; Loop <= NumOfReceivingZoneMixingObjects; ++Loop) {
    6913       478004 :             int MixingNum = massConservation.ZoneMixingReceivingPtr(Loop);
    6914       478004 :             state.dataHeatBal->Mixing(MixingNum).MixingMassFlowRate = massConservation.ZoneMixingReceivingFr(Loop) * ZoneMixingMassFlowRate;
    6915       478004 :             MixingMassFlowRate += state.dataHeatBal->Mixing(MixingNum).MixingMassFlowRate;
    6916       478004 :             CalcZoneMixingFlowRateOfSourceZone(state, state.dataHeatBal->Mixing(MixingNum).FromZone);
    6917              :         }
    6918              :     }
    6919       597505 :     massConservation.MixingMassFlowRate = MixingMassFlowRate;
    6920       597505 :     ZoneMixingMassFlowRate = MixingMassFlowRate;
    6921       597505 : }
    6922              : 
    6923       478004 : void CalcZoneMixingFlowRateOfSourceZone(EnergyPlusData &state, int const ZoneNum)
    6924              : {
    6925              : 
    6926              :     // SUBROUTINE INFORMATION:
    6927              :     //       AUTHOR         Bereket Nigusse
    6928              :     //       DATE WRITTEN   February 2014
    6929              : 
    6930              :     // PURPOSE OF THIS SUBROUTINE:
    6931              :     // This subroutine calculates the zone mixing flow rate such that it ensures the zone air mass balance.
    6932              : 
    6933       478004 :     auto &massConservation = state.dataHeatBal->MassConservation(ZoneNum);
    6934              : 
    6935       478004 :     Real64 ZoneSourceMassFlowRate = 0.0; // current zone as a source mass flow rate for zone mixing in other zones, [kg/s]
    6936       478004 :     int NumOfSourceZoneMixingObjects = massConservation.NumSourceZonesMixingObject;
    6937       478004 :     if (NumOfSourceZoneMixingObjects > 0) {
    6938       956008 :         for (int ZoneMixingNum = 1; ZoneMixingNum <= NumOfSourceZoneMixingObjects; ++ZoneMixingNum) {
    6939       478004 :             int MixingNum = massConservation.ZoneMixingSourcesPtr(ZoneMixingNum);
    6940      2390020 :             for (int Loop = 1; Loop <= state.dataHeatBal->TotMixing; ++Loop) {
    6941      1912016 :                 if (Loop == MixingNum) {
    6942       478004 :                     ZoneSourceMassFlowRate += state.dataHeatBal->Mixing(Loop).MixingMassFlowRate;
    6943              :                 }
    6944              :             }
    6945              :         }
    6946              :     }
    6947       478004 :     massConservation.MixingSourceMassFlowRate = ZoneSourceMassFlowRate;
    6948       478004 : }
    6949              : 
    6950          428 : void AutoCalcDOASControlStrategy(EnergyPlusData &state)
    6951              : {
    6952              :     // SUBROUTINE INFORMATION:
    6953              :     //       AUTHOR         Fred Buhl
    6954              :     //       DATE WRITTEN   March 2016
    6955              : 
    6956              :     // PURPOSE OF THIS Function:
    6957              :     // This subroutine does the autosizing calculations for the Sizing:Zone DOAS input.
    6958              : 
    6959              :     // REFERENCES:
    6960              :     // See IO Ref for suggested values
    6961              : 
    6962          428 :     bool headerAlreadyPrinted = false;
    6963          428 :     bool ErrorsFound = false;
    6964         4070 :     for (int ZoneSizIndex = 1; ZoneSizIndex <= state.dataSize->NumZoneSizingInput; ++ZoneSizIndex) {
    6965         3642 :         if (state.dataSize->ZoneSizingInput(ZoneSizIndex).AccountForDOAS) {
    6966           72 :             auto &zoneSizingInput = state.dataSize->ZoneSizingInput(ZoneSizIndex);
    6967           72 :             if (zoneSizingInput.DOASControlStrategy == DOASControl::NeutralSup) {
    6968            5 :                 if (zoneSizingInput.DOASLowSetpoint == AutoSize && zoneSizingInput.DOASHighSetpoint == AutoSize) {
    6969            0 :                     zoneSizingInput.DOASLowSetpoint = 21.1;
    6970            0 :                     zoneSizingInput.DOASHighSetpoint = 23.9;
    6971            5 :                 } else if (zoneSizingInput.DOASLowSetpoint == AutoSize && zoneSizingInput.DOASHighSetpoint > 0.0) {
    6972            0 :                     zoneSizingInput.DOASLowSetpoint = zoneSizingInput.DOASHighSetpoint - 2.8;
    6973            5 :                 } else if (zoneSizingInput.DOASLowSetpoint > 0.0 && zoneSizingInput.DOASHighSetpoint == AutoSize) {
    6974            0 :                     zoneSizingInput.DOASHighSetpoint = zoneSizingInput.DOASLowSetpoint + 2.8;
    6975              :                 }
    6976           20 :                 ReportZoneSizingDOASInputs(state,
    6977            5 :                                            zoneSizingInput.ZoneName,
    6978              :                                            "NeutralSupplyAir",
    6979              :                                            zoneSizingInput.DOASLowSetpoint,
    6980              :                                            zoneSizingInput.DOASHighSetpoint,
    6981              :                                            headerAlreadyPrinted);
    6982           67 :             } else if (zoneSizingInput.DOASControlStrategy == DataSizing::DOASControl::NeutralDehumSup) {
    6983            0 :                 if (zoneSizingInput.DOASLowSetpoint == AutoSize && zoneSizingInput.DOASHighSetpoint == AutoSize) {
    6984            0 :                     zoneSizingInput.DOASLowSetpoint = 14.4;
    6985            0 :                     zoneSizingInput.DOASHighSetpoint = 22.2;
    6986            0 :                 } else if (zoneSizingInput.DOASLowSetpoint == AutoSize && zoneSizingInput.DOASHighSetpoint > 0.0) {
    6987            0 :                     zoneSizingInput.DOASLowSetpoint = 14.4;
    6988            0 :                 } else if (zoneSizingInput.DOASLowSetpoint > 0.0 && zoneSizingInput.DOASHighSetpoint == AutoSize) {
    6989            0 :                     zoneSizingInput.DOASHighSetpoint = 22.2;
    6990              :                 }
    6991            0 :                 ReportZoneSizingDOASInputs(state,
    6992            0 :                                            zoneSizingInput.ZoneName,
    6993              :                                            "NeutralDehumidifiedSupplyAir",
    6994              :                                            zoneSizingInput.DOASLowSetpoint,
    6995              :                                            zoneSizingInput.DOASHighSetpoint,
    6996              :                                            headerAlreadyPrinted);
    6997           67 :             } else if (zoneSizingInput.DOASControlStrategy == DOASControl::CoolSup) {
    6998           67 :                 if (zoneSizingInput.DOASLowSetpoint == AutoSize && zoneSizingInput.DOASHighSetpoint == AutoSize) {
    6999            0 :                     zoneSizingInput.DOASLowSetpoint = 12.2;
    7000            0 :                     zoneSizingInput.DOASHighSetpoint = 14.4;
    7001           67 :                 } else if (zoneSizingInput.DOASLowSetpoint == AutoSize && zoneSizingInput.DOASHighSetpoint > 0.0) {
    7002            0 :                     zoneSizingInput.DOASLowSetpoint = zoneSizingInput.DOASHighSetpoint - 2.2;
    7003           67 :                 } else if (zoneSizingInput.DOASLowSetpoint > 0.0 && zoneSizingInput.DOASHighSetpoint == AutoSize) {
    7004            0 :                     zoneSizingInput.DOASHighSetpoint = zoneSizingInput.DOASLowSetpoint + 2.2;
    7005              :                 }
    7006          268 :                 ReportZoneSizingDOASInputs(state,
    7007           67 :                                            zoneSizingInput.ZoneName,
    7008              :                                            "ColdSupplyAir",
    7009              :                                            zoneSizingInput.DOASLowSetpoint,
    7010              :                                            zoneSizingInput.DOASHighSetpoint,
    7011              :                                            headerAlreadyPrinted);
    7012              :             }
    7013           72 :             if (zoneSizingInput.DOASLowSetpoint > zoneSizingInput.DOASHighSetpoint) {
    7014            0 :                 ShowSevereError(state, format("For Sizing:Zone = {}", zoneSizingInput.ZoneName));
    7015            0 :                 ShowContinueError(state, "... Dedicated Outside Air Low Setpoint for Design must be less than the High Setpoint");
    7016            0 :                 ErrorsFound = true;
    7017              :             }
    7018              :         }
    7019              :     }
    7020          428 :     if (ErrorsFound) {
    7021            0 :         ShowFatalError(state, "Errors found in DOAS sizing input. Program terminates.");
    7022              :     }
    7023          428 : }
    7024              : 
    7025           72 : void ReportZoneSizingDOASInputs(EnergyPlusData &state,
    7026              :                                 std::string const &ZoneName,         // the name of the zone
    7027              :                                 std::string const &DOASCtrlStrategy, // DOAS control strategy
    7028              :                                 Real64 const DOASLowTemp,            // DOAS design low setpoint temperature [C]
    7029              :                                 Real64 const DOASHighTemp,           // DOAS design high setpoint temperature [C]
    7030              :                                 bool &headerAlreadyPrinted)
    7031              : {
    7032              : 
    7033              :     // SUBROUTINE INFORMATION:
    7034              :     //       AUTHOR         Fred Buhl
    7035              :     //       DATE WRITTEN   March 2016
    7036              : 
    7037              :     // PURPOSE OF THIS SUBROUTINE:
    7038              :     // This subroutine writes the DOAS Sizing:Zone input for 1 zone to the eio file
    7039              : 
    7040              :     // Formats
    7041              :     static constexpr std::string_view Format_990(
    7042              :         "! <Zone Sizing DOAS Inputs>, Zone Name, DOAS Design Control Strategy, DOAS Design Low Setpoint Temperature "
    7043              :         "{C}, DOAS Design High Setpoint Temperature {C} ");
    7044              : 
    7045           72 :     if (!headerAlreadyPrinted) {
    7046           17 :         print(state.files.eio, "{}\n", Format_990);
    7047           17 :         headerAlreadyPrinted = true;
    7048              :     }
    7049              : 
    7050              :     static constexpr std::string_view Format_991(" Zone Sizing DOAS Inputs, {}, {}, {:.3R}, {:.3R}\n");
    7051           72 :     print(state.files.eio, Format_991, ZoneName, DOASCtrlStrategy, DOASLowTemp, DOASHighTemp);
    7052              : 
    7053              :     // BSLLC Start
    7054              :     // if ( sqlite ) {
    7055              :     //     state.dataSQLiteProcedures->sqlite->addSQLiteZoneSizingRecord( ZoneName, LoadType, CalcDesLoad, UserDesLoad, CalcDesFlow,
    7056              :     //     UserDesFlow, DesDayName, PeakHrMin,
    7057              :     //         PeakTemp, PeakHumRat, MinOAVolFlow, DOASHeatAddRate );
    7058              :     // }
    7059              :     // BSLLC Finish
    7060           72 : }
    7061              : 
    7062              : } // namespace EnergyPlus::ZoneEquipmentManager
        

Generated by: LCOV version 2.0-1