LCOV - code coverage report
Current view: top level - EnergyPlus - ReportCoilSelection.cc (source / functions) Coverage Total Hit
Test: lcov.output.filtered Lines: 87.2 % 1283 1119
Test Date: 2025-06-02 12:03:30 Functions: 97.6 % 41 40

            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 <memory>
      50              : #include <string>
      51              : 
      52              : // EnergyPlus Headers
      53              : #include <EnergyPlus/AirLoopHVACDOAS.hh>
      54              : #include <EnergyPlus/BoilerSteam.hh>
      55              : #include <EnergyPlus/Data/EnergyPlusData.hh>
      56              : #include <EnergyPlus/DataAirLoop.hh>
      57              : #include <EnergyPlus/DataAirSystems.hh>
      58              : #include <EnergyPlus/DataEnvironment.hh>
      59              : #include <EnergyPlus/DataHVACGlobals.hh>
      60              : #include <EnergyPlus/DataHeatBalance.hh>
      61              : #include <EnergyPlus/DataSizing.hh>
      62              : #include <EnergyPlus/DataZoneEquipment.hh>
      63              : #include <EnergyPlus/Fans.hh>
      64              : #include <EnergyPlus/FluidProperties.hh>
      65              : #include <EnergyPlus/MixedAir.hh>
      66              : #include <EnergyPlus/OutputReportPredefined.hh>
      67              : #include <EnergyPlus/Plant/DataPlant.hh>
      68              : #include <EnergyPlus/PlantUtilities.hh>
      69              : #include <EnergyPlus/Psychrometrics.hh>
      70              : #include <EnergyPlus/ReportCoilSelection.hh>
      71              : #include <EnergyPlus/UtilityRoutines.hh>
      72              : #include <EnergyPlus/WeatherManager.hh>
      73              : 
      74              : namespace EnergyPlus {
      75              : 
      76         2188 : void createCoilSelectionReportObj(EnergyPlusData &state)
      77              : {
      78         2188 :     state.dataRptCoilSelection->coilSelectionReportObj = std::make_unique<ReportCoilSelection>();
      79         2188 : }
      80              : 
      81          508 : CoilSelectionData::CoilSelectionData( // constructor
      82          508 :     std::string const &coilName)
      83         1524 :     : isCooling(false), isHeating(false), coilNum(-999), airloopNum(-999), oaControllerNum(-999), zoneEqNum(-999), oASysNum(-999), zoneHVACTypeNum(0),
      84         2032 :       zoneHVACIndex(0), typeof_Coil(-999), coilSizingMethodCapacity(-999), coilSizingMethodAirFlow(-999), isCoilSizingForTotalLoad(false),
      85         2540 :       capIsAutosized(false), volFlowIsAutosized(false), coilWaterFlowUser(-999.0), oaPretreated(false), isSupplementalHeater(false),
      86          508 :       coilTotCapFinal(-999.0), coilSensCapFinal(-999.0), coilRefAirVolFlowFinal(-999.0), coilRefWaterVolFlowFinal(-999.0), coilTotCapAtPeak(-999.0),
      87          508 :       coilSensCapAtPeak(-999.0), coilDesMassFlow(-999.0), coilDesVolFlow(-999.0), coilDesEntTemp(-999.0), coilDesEntWetBulb(-999.0),
      88          508 :       coilDesEntHumRat(-999.0), coilDesEntEnth(-999.0), coilDesLvgTemp(-999.0), coilDesLvgWetBulb(-999.0), coilDesLvgHumRat(-999.0),
      89          508 :       coilDesLvgEnth(-999.0), coilDesWaterMassFlow(-999.0), coilDesWaterEntTemp(-999.0), coilDesWaterLvgTemp(-999.0), coilDesWaterTempDiff(-999.0),
      90         1016 :       pltSizNum(-999), waterLoopNum(-999), oaPeakTemp(-999.00), oaPeakHumRat(-999.0), oaPeakWetBulb(-999.0), oaPeakVolFlow(-999.0),
      91          508 :       oaPeakVolFrac(-999.0), oaDoaTemp(-999.0), oaDoaHumRat(-999.0), raPeakTemp(-999.0), raPeakHumRat(-999.0), rmPeakTemp(-999.0),
      92          508 :       rmPeakHumRat(-999.0), rmPeakRelHum(-999.0), rmSensibleAtPeak(-999.0), rmLatentAtPeak(0.0), coilIdealSizCapOverSimPeakCap(-999.0),
      93          508 :       coilIdealSizCapUnderSimPeakCap(-999.0), reheatLoadMult(-999.0), minRatio(-999.0), maxRatio(-999.0), cpMoistAir(-999.0), cpDryAir(-999.0),
      94          508 :       rhoStandAir(-999.0), rhoFluid(-999.0), cpFluid(-999.0), coilCapFTIdealPeak(1.0), coilRatedTotCap(-999.0), coilRatedSensCap(-999.0),
      95          508 :       ratedAirMassFlow(-999.0), ratedCoilInDb(-999.0), ratedCoilInWb(-999.0), ratedCoilInHumRat(-999.0), ratedCoilInEnth(-999.0),
      96          508 :       ratedCoilOutDb(-999.0), ratedCoilOutWb(-999.0), ratedCoilOutHumRat(-999.0), ratedCoilOutEnth(-999.0), ratedCoilEff(-999.0),
      97          508 :       ratedCoilBpFactor(-999.0), ratedCoilAppDewPt(-999.0), ratedCoilOadbRef(-999.0), ratedCoilOawbRef(-999.0),
      98              : 
      99          508 :       supFanType(HVAC::FanType::Invalid), supFanNum(0), fanSizeMaxAirVolumeFlow(-999.0), fanSizeMaxAirMassFlow(-999.0), fanHeatGainIdealPeak(-999.0),
     100          508 :       coilAndFanNetTotalCapacityIdealPeak(-999.0), plantDesMaxMassFlowRate(-999.0), plantDesRetTemp(-999.0), plantDesSupTemp(-999.0),
     101          508 :       plantDesDeltaTemp(-999.0), plantDesCapacity(-999.0), coilCapPrcntPlantCap(-999.0), coilFlowPrcntPlantFlow(-999.0), coilUA(-999.0)
     102              : {
     103          508 :     coilName_ = coilName;
     104          508 :     coilLocation = "unknown";
     105          508 :     desDayNameAtSensPeak = "unknown";
     106          508 :     coilSensePeakHrMin = "unknown";
     107          508 :     desDayNameAtTotalPeak = "unknown";
     108          508 :     coilTotalPeakHrMin = "unknown";
     109          508 :     desDayNameAtAirFlowPeak = "unknown";
     110          508 :     airPeakHrMin = "unknown";
     111          508 :     typeHVACname = "unknown";
     112          508 :     userNameforHVACsystem = "unknown";
     113          508 :     coilSizingMethodConcurrenceName = "N/A";
     114          508 :     coilSizingMethodCapacityName = "N/A";
     115          508 :     coilSizingMethodAirFlowName = "N/A";
     116          508 :     coilPeakLoadTypeToSizeOnName = "N/A";
     117          508 :     coilCapAutoMsg = "unknown";
     118          508 :     coilVolFlowAutoMsg = "unknown";
     119          508 :     coilWaterFlowAutoMsg = "unknown";
     120          508 :     coilOAPretreatMsg = "unknown";
     121          508 :     plantLoopName = "unknown";
     122          508 :     fanAssociatedWithCoilName = "unknown";
     123          508 :     fanTypeName = "unknown";
     124          508 : }
     125              : 
     126           46 : void ReportCoilSelection::finishCoilSummaryReportTable(EnergyPlusData &state)
     127              : {
     128           46 :     doFinalProcessingOfCoilData(state);
     129           46 :     writeCoilSelectionOutput(state);
     130           46 :     writeCoilSelectionOutput2(state);
     131           46 : }
     132              : 
     133           46 : void ReportCoilSelection::writeCoilSelectionOutput(EnergyPlusData &state)
     134              : {
     135              : 
     136              :     // make calls to fill out predefined tabular report entries for each coil selection report object
     137           66 :     for (auto &c : coilSelectionDataObjs) {
     138              : 
     139           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilType, c->coilName_, c->coilObjName);
     140           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilLocation, c->coilName_, c->coilLocation);
     141           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilHVACType, c->coilName_, c->typeHVACname);
     142           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilHVACName, c->coilName_, c->userNameforHVACsystem);
     143              : 
     144              :         // begin std 229 existing heating coil table adding new variables
     145           20 :         if (c->isHeating) {
     146           33 :             OutputReportPredefined::PreDefTableEntry(
     147           33 :                 state, state.dataOutRptPredefined->pdchHeatCoilUsedAsSupHeat, c->coilName_, c->isSupplementalHeater ? "Yes" : "No");
     148           33 :             OutputReportPredefined::PreDefTableEntry(state,
     149           11 :                                                      state.dataOutRptPredefined->pdchHeatCoilAirloopName,
     150           11 :                                                      c->coilName_,
     151            4 :                                                      c->airloopNum > 0 && c->airloopNum <= state.dataHVACGlobal->NumPrimaryAirSys
     152           33 :                                                          ? state.dataAirSystemsData->PrimaryAirSystems(c->airloopNum).Name
     153              :                                                          : "N/A");
     154           33 :             OutputReportPredefined::PreDefTableEntry(state,
     155           11 :                                                      state.dataOutRptPredefined->pdchHeatCoilPlantloopName,
     156           11 :                                                      c->coilName_,
     157           42 :                                                      c->waterLoopNum > 0 ? state.dataPlnt->PlantLoop(c->waterLoopNum).Name : "N/A");
     158              :         }
     159              :         // end std 229 existing heating coil table adding new variables
     160              : 
     161              :         // begin std 229 New coil connections table entries
     162           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilName_CCs, c->coilName_, c->coilName_);
     163           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilType_CCs, c->coilName_, c->coilObjName);
     164           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilLoc_CCs, c->coilName_, c->coilLocation);
     165           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilHVACType_CCs, c->coilName_, c->typeHVACname);
     166           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilHVACName_CCs, c->coilName_, c->userNameforHVACsystem);
     167              :         // end of std 229 New coil connections table entries
     168              : 
     169           20 :         if (c->zoneName.size() == 1) {
     170           11 :             OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilZoneName, c->coilName_, c->zoneName[0]);
     171              :             // begin std 229 New coil connections table entries
     172           11 :             OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilZoneNames_CCs, c->coilName_, c->zoneName[0]);
     173              :             // end of std 229 New coil connections table entries
     174            9 :         } else if (c->zoneName.size() > 1) {
     175              :             // make list of zone names
     176            4 :             std::string tmpZoneList;
     177           12 :             for (std::size_t vecLoop = 0; vecLoop < c->zoneName.size(); ++vecLoop) {
     178            8 :                 tmpZoneList += c->zoneName[vecLoop] + "; ";
     179              :             }
     180            4 :             OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilZoneName, c->coilName_, tmpZoneList);
     181              :             // begin std 229 New coil connections table entries
     182            4 :             OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilZoneNames_CCs, c->coilName_, tmpZoneList);
     183              :             // end of std 229 New coil connections table entries
     184            4 :         } else {
     185            5 :             OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilZoneName, c->coilName_, "N/A");
     186              :             // begin std 229 New coil connections table entries
     187            5 :             OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilZoneNames_CCs, c->coilName_, "N/A");
     188              :             // end of std 229 New coil connections table entries
     189              :         }
     190              : 
     191           60 :         OutputReportPredefined::PreDefTableEntry(
     192           60 :             state, state.dataOutRptPredefined->pdchSysSizingMethCoinc, c->coilName_, c->coilSizingMethodConcurrenceName);
     193           60 :         OutputReportPredefined::PreDefTableEntry(
     194           60 :             state, state.dataOutRptPredefined->pdchSysSizingMethCap, c->coilName_, c->coilSizingMethodCapacityName);
     195           60 :         OutputReportPredefined::PreDefTableEntry(
     196           60 :             state, state.dataOutRptPredefined->pdchSysSizingMethAir, c->coilName_, c->coilSizingMethodAirFlowName);
     197           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilIsCapAutosized, c->coilName_, c->coilCapAutoMsg);
     198           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilIsAirFlowAutosized, c->coilName_, c->coilVolFlowAutoMsg);
     199           60 :         OutputReportPredefined::PreDefTableEntry(
     200           60 :             state, state.dataOutRptPredefined->pdchCoilIsWaterFlowAutosized, c->coilName_, c->coilWaterFlowAutoMsg);
     201           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilIsOATreated, c->coilName_, c->coilOAPretreatMsg);
     202           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilFinalTotalCap, c->coilName_, c->coilTotCapFinal, 3);
     203           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilFinalSensCap, c->coilName_, c->coilSensCapFinal, 3);
     204           20 :         if (c->coilRefAirVolFlowFinal == -999.0 || c->coilRefAirVolFlowFinal == -99999.0) {
     205           26 :             OutputReportPredefined::PreDefTableEntry(
     206           39 :                 state, state.dataOutRptPredefined->pdchCoilFinalAirVolFlowRate, c->coilName_, c->coilRefAirVolFlowFinal, 1);
     207              :         } else {
     208           14 :             OutputReportPredefined::PreDefTableEntry(
     209           21 :                 state, state.dataOutRptPredefined->pdchCoilFinalAirVolFlowRate, c->coilName_, c->coilRefAirVolFlowFinal, 6);
     210              :         }
     211              : 
     212           20 :         if (c->coilRefWaterVolFlowFinal == -999.0 || c->coilRefWaterVolFlowFinal == -99999.0) {
     213           36 :             OutputReportPredefined::PreDefTableEntry(
     214           54 :                 state, state.dataOutRptPredefined->pdchCoilFinalPlantVolFlowRate, c->coilName_, c->coilRefWaterVolFlowFinal, 1);
     215              :         } else {
     216            4 :             OutputReportPredefined::PreDefTableEntry(
     217            6 :                 state, state.dataOutRptPredefined->pdchCoilFinalPlantVolFlowRate, c->coilName_, c->coilRefWaterVolFlowFinal, 8);
     218              :         }
     219              : 
     220           60 :         OutputReportPredefined::PreDefTableEntry(
     221           60 :             state, state.dataOutRptPredefined->pdchFanAssociatedWithCoilName, c->coilName_, c->fanAssociatedWithCoilName);
     222              :         // begin std 229 New coil connections table entries
     223           60 :         OutputReportPredefined::PreDefTableEntry(
     224           60 :             state, state.dataOutRptPredefined->pdchCoilSupFanName_CCs, c->coilName_, c->fanAssociatedWithCoilName);
     225              :         // end of std 229 New coil connections table entries
     226              : 
     227           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchFanAssociatedWithCoilType, c->coilName_, c->fanTypeName);
     228              :         // begin std 229 New coil connections table entries
     229           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilSupFanType_CCs, c->coilName_, c->fanTypeName);
     230              :         // end of std 229 New coil connections table entries
     231              : 
     232           20 :         if (c->fanSizeMaxAirVolumeFlow == -999.0 || c->fanSizeMaxAirVolumeFlow == -99999.0) {
     233           24 :             OutputReportPredefined::PreDefTableEntry(
     234           36 :                 state, state.dataOutRptPredefined->pdchFanAssociatedVdotSize, c->coilName_, c->fanSizeMaxAirVolumeFlow, 1);
     235              :         } else {
     236           16 :             OutputReportPredefined::PreDefTableEntry(
     237           24 :                 state, state.dataOutRptPredefined->pdchFanAssociatedVdotSize, c->coilName_, c->fanSizeMaxAirVolumeFlow, 6);
     238              :         }
     239           20 :         if (c->fanSizeMaxAirMassFlow == -999.0 || c->fanSizeMaxAirMassFlow == -99999.0) {
     240           24 :             OutputReportPredefined::PreDefTableEntry(
     241           36 :                 state, state.dataOutRptPredefined->pdchFanAssociatedMdotSize, c->coilName_, c->fanSizeMaxAirMassFlow, 1);
     242              :         } else {
     243           16 :             OutputReportPredefined::PreDefTableEntry(
     244           24 :                 state, state.dataOutRptPredefined->pdchFanAssociatedMdotSize, c->coilName_, c->fanSizeMaxAirMassFlow, 8);
     245              :         }
     246              : 
     247              :         // begin std 229 New coil connections table entries
     248           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilPlantName_CCs, c->coilName_, c->plantLoopName);
     249           60 :         OutputReportPredefined::PreDefTableEntry(state,
     250           20 :                                                  state.dataOutRptPredefined->pdchCoilAirloopName_CCs,
     251           20 :                                                  c->coilName_,
     252            8 :                                                  c->airloopNum > 0 && c->airloopNum <= state.dataHVACGlobal->NumPrimaryAirSys
     253           60 :                                                      ? state.dataAirSystemsData->PrimaryAirSystems(c->airloopNum).Name
     254              :                                                      : "N/A");
     255           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilPlantloopName_CCs, c->coilName_, c->plantLoopName);
     256              :         // end of std 229 New coil connections table entries
     257              : 
     258           60 :         OutputReportPredefined::PreDefTableEntry(
     259           60 :             state, state.dataOutRptPredefined->pdchCoilDDnameSensIdealPeak, c->coilName_, c->desDayNameAtSensPeak);
     260           60 :         OutputReportPredefined::PreDefTableEntry(
     261           60 :             state, state.dataOutRptPredefined->pdchCoilDateTimeSensIdealPeak, c->coilName_, c->coilSensePeakHrMin);
     262           60 :         OutputReportPredefined::PreDefTableEntry(
     263           60 :             state, state.dataOutRptPredefined->pdchCoilDDnameTotIdealPeak, c->coilName_, c->desDayNameAtTotalPeak);
     264           60 :         OutputReportPredefined::PreDefTableEntry(
     265           60 :             state, state.dataOutRptPredefined->pdchCoilDateTimeTotIdealPeak, c->coilName_, c->coilTotalPeakHrMin);
     266           60 :         OutputReportPredefined::PreDefTableEntry(
     267           60 :             state, state.dataOutRptPredefined->pdchCoilDDnameAirFlowIdealPeak, c->coilName_, c->desDayNameAtAirFlowPeak);
     268           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilDateTimeAirFlowIdealPeak, c->coilName_, c->airPeakHrMin);
     269              : 
     270           60 :         OutputReportPredefined::PreDefTableEntry(
     271           60 :             state, state.dataOutRptPredefined->pdchCoilPeakLoadTypeToSizeOn, c->coilName_, c->coilPeakLoadTypeToSizeOnName);
     272              : 
     273           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilTotalCapIdealPeak, c->coilName_, c->coilTotCapAtPeak, 2);
     274           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilSensCapIdealPeak, c->coilName_, c->coilSensCapAtPeak, 2);
     275           20 :         if (c->coilDesMassFlow == -999.0 || c->coilDesMassFlow == -99999.0) {
     276           18 :             OutputReportPredefined::PreDefTableEntry(
     277           27 :                 state, state.dataOutRptPredefined->pdchCoilAirMassFlowIdealPeak, c->coilName_, c->coilDesMassFlow, 1);
     278              :         } else {
     279           22 :             OutputReportPredefined::PreDefTableEntry(
     280           33 :                 state, state.dataOutRptPredefined->pdchCoilAirMassFlowIdealPeak, c->coilName_, c->coilDesMassFlow, 8);
     281              :         }
     282           20 :         if (c->coilDesVolFlow == -999.0 || c->coilDesVolFlow == -99999.0) {
     283           18 :             OutputReportPredefined::PreDefTableEntry(
     284           27 :                 state, state.dataOutRptPredefined->pdchCoilAirVolumeFlowIdealPeak, c->coilName_, c->coilDesVolFlow, 1);
     285              :         } else {
     286           22 :             OutputReportPredefined::PreDefTableEntry(
     287           33 :                 state, state.dataOutRptPredefined->pdchCoilAirVolumeFlowIdealPeak, c->coilName_, c->coilDesVolFlow, 6);
     288              :         }
     289           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilEntDryBulbIdealPeak, c->coilName_, c->coilDesEntTemp, 2);
     290           40 :         OutputReportPredefined::PreDefTableEntry(
     291           40 :             state, state.dataOutRptPredefined->pdchCoilEntWetBulbIdealPeak, c->coilName_, c->coilDesEntWetBulb, 2);
     292           20 :         if (c->coilDesEntHumRat == -999.0 || c->coilDesEntHumRat == -99999.0) {
     293           20 :             OutputReportPredefined::PreDefTableEntry(
     294           30 :                 state, state.dataOutRptPredefined->pdchCoilEntHumRatIdealPeak, c->coilName_, c->coilDesEntHumRat, 1);
     295              :         } else {
     296           20 :             OutputReportPredefined::PreDefTableEntry(
     297           30 :                 state, state.dataOutRptPredefined->pdchCoilEntHumRatIdealPeak, c->coilName_, c->coilDesEntHumRat, 8);
     298              :         }
     299           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilEntEnthalpyIdealPeak, c->coilName_, c->coilDesEntEnth, 1);
     300           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilLvgDryBulbIdealPeak, c->coilName_, c->coilDesLvgTemp, 2);
     301           40 :         OutputReportPredefined::PreDefTableEntry(
     302           40 :             state, state.dataOutRptPredefined->pdchCoilLvgWetBulbIdealPeak, c->coilName_, c->coilDesLvgWetBulb, 2);
     303           20 :         if (c->coilDesLvgHumRat == -999.0 || c->coilDesLvgHumRat == -99999.0) {
     304           20 :             OutputReportPredefined::PreDefTableEntry(
     305           30 :                 state, state.dataOutRptPredefined->pdchCoilLvgHumRatIdealPeak, c->coilName_, c->coilDesLvgHumRat, 1);
     306              :         } else {
     307           20 :             OutputReportPredefined::PreDefTableEntry(
     308           30 :                 state, state.dataOutRptPredefined->pdchCoilLvgHumRatIdealPeak, c->coilName_, c->coilDesLvgHumRat, 8);
     309              :         }
     310           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilLvgEnthalpyIdealPeak, c->coilName_, c->coilDesLvgEnth, 1);
     311           20 :         if (c->coilDesWaterMassFlow == -999.0 || c->coilDesWaterMassFlow == -99999.0) {
     312           36 :             OutputReportPredefined::PreDefTableEntry(
     313           54 :                 state, state.dataOutRptPredefined->pdchCoilWaterMassFlowIdealPeak, c->coilName_, c->coilDesWaterMassFlow, 1);
     314              :         } else {
     315            4 :             OutputReportPredefined::PreDefTableEntry(
     316            6 :                 state, state.dataOutRptPredefined->pdchCoilWaterMassFlowIdealPeak, c->coilName_, c->coilDesWaterMassFlow, 8);
     317              :         }
     318              : 
     319           40 :         OutputReportPredefined::PreDefTableEntry(
     320           40 :             state, state.dataOutRptPredefined->pdchCoilEntWaterTempIdealPeak, c->coilName_, c->coilDesWaterEntTemp, 2);
     321           40 :         OutputReportPredefined::PreDefTableEntry(
     322           40 :             state, state.dataOutRptPredefined->pdchCoilLvgWaterTempIdealPeak, c->coilName_, c->coilDesWaterLvgTemp, 2);
     323           40 :         OutputReportPredefined::PreDefTableEntry(
     324           40 :             state, state.dataOutRptPredefined->pdchCoilWaterDeltaTempIdealPeak, c->coilName_, c->coilDesWaterTempDiff, 2);
     325           40 :         OutputReportPredefined::PreDefTableEntry(
     326           40 :             state, state.dataOutRptPredefined->pdchFanHeatGainIdealPeak, c->coilName_, c->fanHeatGainIdealPeak, 3);
     327           40 :         OutputReportPredefined::PreDefTableEntry(
     328           40 :             state, state.dataOutRptPredefined->pdchCoilNetTotalCapacityIdealPeak, c->coilName_, c->coilAndFanNetTotalCapacityIdealPeak, 2);
     329              : 
     330           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilRatedTotalCap, c->coilName_, c->coilRatedTotCap, 2);
     331           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilRatedSensCap, c->coilName_, c->coilRatedSensCap, 2);
     332           40 :         OutputReportPredefined::PreDefTableEntry(
     333           40 :             state, state.dataOutRptPredefined->pdchCoilOffRatingCapacityModifierIdealPeak, c->coilName_, c->coilCapFTIdealPeak, 4);
     334           20 :         if (c->ratedAirMassFlow == -999.0 || c->ratedAirMassFlow == -99999.0) {
     335           13 :             OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilRatedAirMass, c->coilName_, c->ratedAirMassFlow, 1);
     336              :         } else {
     337            7 :             OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilRatedAirMass, c->coilName_, c->ratedAirMassFlow, 8);
     338              :         }
     339              : 
     340           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilRatedEntDryBulb, c->coilName_, c->ratedCoilInDb, 2);
     341           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilRatedEntWetBulb, c->coilName_, c->ratedCoilInWb, 2);
     342           20 :         if (c->ratedCoilInHumRat == -999.0 || c->ratedCoilInHumRat == -99999.0) {
     343           26 :             OutputReportPredefined::PreDefTableEntry(
     344           39 :                 state, state.dataOutRptPredefined->pdchCoilRatedEntHumRat, c->coilName_, c->ratedCoilInHumRat, 1);
     345              :         } else {
     346           14 :             OutputReportPredefined::PreDefTableEntry(
     347           21 :                 state, state.dataOutRptPredefined->pdchCoilRatedEntHumRat, c->coilName_, c->ratedCoilInHumRat, 8);
     348              :         }
     349              : 
     350           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilRatedEntEnthalpy, c->coilName_, c->ratedCoilInEnth, 1);
     351           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilRatedLvgDryBulb, c->coilName_, c->ratedCoilOutDb, 2);
     352           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilRatedLvgWetBulb, c->coilName_, c->ratedCoilOutWb, 2);
     353           20 :         if (c->ratedCoilOutHumRat == -999.0 || c->ratedCoilOutHumRat == -99999.0) {
     354           26 :             OutputReportPredefined::PreDefTableEntry(
     355           39 :                 state, state.dataOutRptPredefined->pdchCoilRatedLvgHumRat, c->coilName_, c->ratedCoilOutHumRat, 1);
     356              :         } else {
     357           14 :             OutputReportPredefined::PreDefTableEntry(
     358           21 :                 state, state.dataOutRptPredefined->pdchCoilRatedLvgHumRat, c->coilName_, c->ratedCoilOutHumRat, 8);
     359              :         }
     360              : 
     361           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilRatedLvgEnthalpy, c->coilName_, c->ratedCoilOutEnth, 1);
     362              : 
     363           20 :         if (c->plantDesMaxMassFlowRate == -999.0 || c->plantDesMaxMassFlowRate == -99999.0) {
     364           36 :             OutputReportPredefined::PreDefTableEntry(
     365           54 :                 state, state.dataOutRptPredefined->pdchPlantMassFlowMaximum, c->coilName_, c->plantDesMaxMassFlowRate, 1);
     366              :         } else {
     367            4 :             OutputReportPredefined::PreDefTableEntry(
     368            6 :                 state, state.dataOutRptPredefined->pdchPlantMassFlowMaximum, c->coilName_, c->plantDesMaxMassFlowRate, 8);
     369              :         }
     370           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchPlantRetTempDesign, c->coilName_, c->plantDesRetTemp, 2);
     371           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchPlantSupTempDesign, c->coilName_, c->plantDesSupTemp, 2);
     372           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchPlantDeltaTempDesign, c->coilName_, c->plantDesDeltaTemp, 2);
     373           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchPlantCapacity, c->coilName_, c->plantDesCapacity, 2);
     374           40 :         OutputReportPredefined::PreDefTableEntry(
     375           40 :             state, state.dataOutRptPredefined->pdchCoilCapPrcntPlantCapacity, c->coilName_, c->coilCapPrcntPlantCap, 4);
     376           20 :         if (c->coilFlowPrcntPlantFlow == -999.0 || c->coilFlowPrcntPlantFlow == -99999.0) {
     377           36 :             OutputReportPredefined::PreDefTableEntry(
     378           54 :                 state, state.dataOutRptPredefined->pdchCoilFlowPrcntPlantFlow, c->coilName_, c->coilFlowPrcntPlantFlow, 1);
     379              :         } else {
     380            4 :             OutputReportPredefined::PreDefTableEntry(
     381            6 :                 state, state.dataOutRptPredefined->pdchCoilFlowPrcntPlantFlow, c->coilName_, c->coilFlowPrcntPlantFlow, 6);
     382              :         }
     383              : 
     384           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchOADryBulbIdealPeak, c->coilName_, c->oaPeakTemp, 2);
     385           20 :         if (c->oaPeakHumRat == -999.0 || c->oaPeakHumRat == -99999.0) {
     386           12 :             OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchOAHumRatIdealPeak, c->coilName_, c->oaPeakHumRat, 1);
     387              :         } else {
     388            8 :             OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchOAHumRatIdealPeak, c->coilName_, c->oaPeakHumRat, 8);
     389              :         }
     390              : 
     391           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchOAWetBulbatIdealPeak, c->coilName_, c->oaPeakWetBulb, 2);
     392           20 :         if (c->oaPeakVolFlow == -999.0 || c->oaPeakVolFlow == -99999.0) {
     393           12 :             OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchOAVolFlowIdealPeak, c->coilName_, c->oaPeakVolFlow, 1);
     394              :         } else {
     395            8 :             OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchOAVolFlowIdealPeak, c->coilName_, c->oaPeakVolFlow, 8);
     396              :         }
     397              : 
     398           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchOAFlowPrcntIdealPeak, c->coilName_, c->oaPeakVolFrac, 4);
     399           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchAirSysRADryBulbIdealPeak, c->coilName_, c->raPeakTemp, 2);
     400           20 :         if (c->raPeakHumRat == -999.0 || c->raPeakHumRat == -99999.0) {
     401           24 :             OutputReportPredefined::PreDefTableEntry(
     402           36 :                 state, state.dataOutRptPredefined->pdchAirSysRAHumRatIdealPeak, c->coilName_, c->raPeakHumRat, 1);
     403              :         } else {
     404           16 :             OutputReportPredefined::PreDefTableEntry(
     405           24 :                 state, state.dataOutRptPredefined->pdchAirSysRAHumRatIdealPeak, c->coilName_, c->raPeakHumRat, 8);
     406              :         }
     407              : 
     408           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchZoneAirDryBulbIdealPeak, c->coilName_, c->rmPeakTemp, 2);
     409           20 :         if (c->rmPeakHumRat == -999.0 || c->rmPeakHumRat == -99999.0) {
     410           13 :             OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchZoneAirHumRatIdealPeak, c->coilName_, c->rmPeakHumRat, 1);
     411              :         } else {
     412            7 :             OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchZoneAirHumRatIdealPeak, c->coilName_, c->rmPeakHumRat, 8);
     413              :         }
     414              : 
     415           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchZoneAirRelHumIdealPeak, c->coilName_, c->rmPeakRelHum, 4);
     416           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilUA, c->coilName_, c->coilUA, 3);
     417           40 :         OutputReportPredefined::PreDefTableEntry(
     418           40 :             state, state.dataOutRptPredefined->pdchZoneSensibleLoadIdealPeak, c->coilName_, c->rmSensibleAtPeak, 2);
     419           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchZoneLatentLoadIdealPeak, c->coilName_, c->rmLatentAtPeak);
     420           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchReheatCoilMultiplier, c->coilName_, c->reheatLoadMult, 4);
     421           40 :         OutputReportPredefined::PreDefTableEntry(
     422           40 :             state, state.dataOutRptPredefined->pdchFlowCapRatioLowCapIncreaseRatio, c->coilName_, c->maxRatio, 5);
     423           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchFlowCapRatioHiCapDecreaseRatio, c->coilName_, c->minRatio, 5);
     424           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchPlantFluidSpecificHeat, c->coilName_, c->cpFluid, 4);
     425           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchPlantFluidDensity, c->coilName_, c->rhoFluid, 4);
     426           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchMoistAirSpecificHeat, c->coilName_, c->cpMoistAir, 4);
     427           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchDryAirSpecificHeat, c->coilName_, c->cpDryAir, 4);
     428           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchStandRhoAir, c->coilName_, c->rhoStandAir, 4);
     429           46 :     }
     430           46 : }
     431              : 
     432           46 : void ReportCoilSelection::writeCoilSelectionOutput2(EnergyPlusData &state)
     433              : {
     434              : 
     435              :     // make calls to fill out predefined tabular report entries for each coil selection report object
     436           66 :     for (auto &c : coilSelectionDataObjs) {
     437           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdch2CoilType, c->coilName_, c->coilObjName);
     438           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdch2CoilHVACType, c->coilName_, c->typeHVACname);
     439           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdch2CoilHVACName, c->coilName_, c->userNameforHVACsystem);
     440              : 
     441           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdch2CoilFinalTotalCap, c->coilName_, c->coilTotCapFinal, 3);
     442           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdch2CoilFinalSensCap, c->coilName_, c->coilSensCapFinal, 3);
     443           20 :         if (c->coilRefAirVolFlowFinal == -999.0 || c->coilRefAirVolFlowFinal == -99999.0) {
     444           26 :             OutputReportPredefined::PreDefTableEntry(
     445           39 :                 state, state.dataOutRptPredefined->pdch2CoilFinalAirVolFlowRate, c->coilName_, c->coilRefAirVolFlowFinal, 1);
     446              :         } else {
     447           14 :             OutputReportPredefined::PreDefTableEntry(
     448           21 :                 state, state.dataOutRptPredefined->pdch2CoilFinalAirVolFlowRate, c->coilName_, c->coilRefAirVolFlowFinal, 6);
     449              :         }
     450              : 
     451           20 :         if (c->coilRefWaterVolFlowFinal == -999.0 || c->coilRefWaterVolFlowFinal == -99999.0) {
     452           36 :             OutputReportPredefined::PreDefTableEntry(
     453           54 :                 state, state.dataOutRptPredefined->pdch2CoilFinalPlantVolFlowRate, c->coilName_, c->coilRefWaterVolFlowFinal, 1);
     454              :         } else {
     455            4 :             OutputReportPredefined::PreDefTableEntry(
     456            6 :                 state, state.dataOutRptPredefined->pdch2CoilFinalPlantVolFlowRate, c->coilName_, c->coilRefWaterVolFlowFinal, 8);
     457              :         }
     458              : 
     459           60 :         OutputReportPredefined::PreDefTableEntry(
     460           60 :             state, state.dataOutRptPredefined->pdch2CoilDDnameSensIdealPeak, c->coilName_, c->desDayNameAtSensPeak);
     461           60 :         OutputReportPredefined::PreDefTableEntry(
     462           60 :             state, state.dataOutRptPredefined->pdch2CoilDateTimeSensIdealPeak, c->coilName_, c->coilSensePeakHrMin);
     463           60 :         OutputReportPredefined::PreDefTableEntry(
     464           60 :             state, state.dataOutRptPredefined->pdch2CoilDDnameAirFlowIdealPeak, c->coilName_, c->desDayNameAtAirFlowPeak);
     465           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdch2CoilDateTimeAirFlowIdealPeak, c->coilName_, c->airPeakHrMin);
     466           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdch2CoilTotalCapIdealPeak, c->coilName_, c->coilTotCapAtPeak, 2);
     467           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdch2CoilSensCapIdealPeak, c->coilName_, c->coilSensCapAtPeak, 2);
     468           20 :         if (c->coilDesVolFlow == -999.0 || c->coilDesVolFlow == -99999.0) {
     469           18 :             OutputReportPredefined::PreDefTableEntry(
     470           27 :                 state, state.dataOutRptPredefined->pdch2CoilAirVolumeFlowIdealPeak, c->coilName_, c->coilDesVolFlow, 1);
     471              :         } else {
     472           22 :             OutputReportPredefined::PreDefTableEntry(
     473           33 :                 state, state.dataOutRptPredefined->pdch2CoilAirVolumeFlowIdealPeak, c->coilName_, c->coilDesVolFlow, 6);
     474              :         }
     475           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdch2CoilEntDryBulbIdealPeak, c->coilName_, c->coilDesEntTemp, 2);
     476           40 :         OutputReportPredefined::PreDefTableEntry(
     477           40 :             state, state.dataOutRptPredefined->pdch2CoilEntWetBulbIdealPeak, c->coilName_, c->coilDesEntWetBulb, 2);
     478           20 :         if (c->coilDesEntHumRat == -999.0 || c->coilDesEntHumRat == -99999.0) {
     479           20 :             OutputReportPredefined::PreDefTableEntry(
     480           30 :                 state, state.dataOutRptPredefined->pdch2CoilEntHumRatIdealPeak, c->coilName_, c->coilDesEntHumRat, 1);
     481              :         } else {
     482           20 :             OutputReportPredefined::PreDefTableEntry(
     483           30 :                 state, state.dataOutRptPredefined->pdch2CoilEntHumRatIdealPeak, c->coilName_, c->coilDesEntHumRat, 8);
     484              :         }
     485           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdch2CoilLvgDryBulbIdealPeak, c->coilName_, c->coilDesLvgTemp, 2);
     486           40 :         OutputReportPredefined::PreDefTableEntry(
     487           40 :             state, state.dataOutRptPredefined->pdch2CoilLvgWetBulbIdealPeak, c->coilName_, c->coilDesLvgWetBulb, 2);
     488           20 :         if (c->coilDesLvgHumRat == -999.0 || c->coilDesLvgHumRat == -99999.0) {
     489           20 :             OutputReportPredefined::PreDefTableEntry(
     490           30 :                 state, state.dataOutRptPredefined->pdch2CoilLvgHumRatIdealPeak, c->coilName_, c->coilDesLvgHumRat, 1);
     491              :         } else {
     492           20 :             OutputReportPredefined::PreDefTableEntry(
     493           30 :                 state, state.dataOutRptPredefined->pdch2CoilLvgHumRatIdealPeak, c->coilName_, c->coilDesLvgHumRat, 8);
     494              :         }
     495              : 
     496           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdch2CoilRatedTotalCap, c->coilName_, c->coilRatedTotCap, 2);
     497           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdch2CoilRatedSensCap, c->coilName_, c->coilRatedSensCap, 2);
     498              : 
     499           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdch2OADryBulbIdealPeak, c->coilName_, c->oaPeakTemp, 2);
     500           20 :         if (c->oaPeakHumRat == -999.0 || c->oaPeakHumRat == -99999.0) {
     501           12 :             OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdch2OAHumRatIdealPeak, c->coilName_, c->oaPeakHumRat, 1);
     502              :         } else {
     503            8 :             OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdch2OAHumRatIdealPeak, c->coilName_, c->oaPeakHumRat, 8);
     504              :         }
     505              : 
     506           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdch2OAWetBulbatIdealPeak, c->coilName_, c->oaPeakWetBulb, 2);
     507           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdch2OAFlowPrcntIdealPeak, c->coilName_, c->oaPeakVolFrac, 4);
     508              : 
     509           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdch2ZoneAirDryBulbIdealPeak, c->coilName_, c->rmPeakTemp, 2);
     510           20 :         if (c->rmPeakHumRat == -999.0 || c->rmPeakHumRat == -99999.0) {
     511           26 :             OutputReportPredefined::PreDefTableEntry(
     512           39 :                 state, state.dataOutRptPredefined->pdch2ZoneAirHumRatIdealPeak, c->coilName_, c->rmPeakHumRat, 1);
     513              :         } else {
     514           14 :             OutputReportPredefined::PreDefTableEntry(
     515           21 :                 state, state.dataOutRptPredefined->pdch2ZoneAirHumRatIdealPeak, c->coilName_, c->rmPeakHumRat, 8);
     516              :         }
     517              : 
     518           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdch2ZoneAirRelHumIdealPeak, c->coilName_, c->rmPeakRelHum, 4);
     519           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdch2CoilUA, c->coilName_, c->coilUA, 3);
     520           40 :         OutputReportPredefined::PreDefTableEntry(
     521           40 :             state, state.dataOutRptPredefined->pdch2ZoneSensibleLoadIdealPeak, c->coilName_, c->rmSensibleAtPeak, 2);
     522           20 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdch2ZoneLatentLoadIdealPeak, c->coilName_, c->rmLatentAtPeak);
     523           46 :     }
     524           46 : }
     525              : 
     526          291 : void ReportCoilSelection::setCoilFinalSizes(EnergyPlusData &state,
     527              :                                             std::string const &coilName,    // user-defined name of the coil
     528              :                                             std::string const &coilObjName, //  coil object name, e.g., Coil:Cooling:Water
     529              :                                             Real64 const totGrossCap,       // total capacity [W]
     530              :                                             Real64 const sensGrossCap,      // sensible capacity [W]
     531              :                                             Real64 const airFlowRate,       // design or reference or rated air flow rate [m3/s]
     532              :                                             Real64 const waterFlowRate      // design or reference or rated water flow rate [m3/s]
     533              : )
     534              : {
     535          291 :     int index = getIndexForOrCreateDataObjFromCoilName(state, coilName, coilObjName);
     536          291 :     auto &c(coilSelectionDataObjs[index]);
     537          291 :     if (c != nullptr) {
     538          291 :         c->coilTotCapFinal = totGrossCap;
     539          291 :         c->coilSensCapFinal = sensGrossCap;
     540          291 :         c->coilRefAirVolFlowFinal = airFlowRate;
     541          291 :         c->coilRefWaterVolFlowFinal = waterFlowRate;
     542              :     }
     543          291 : }
     544              : 
     545          794 : void ReportCoilSelection::doAirLoopSetup(EnergyPlusData &state, int const coilVecIndex)
     546              : {
     547              :     // this routine sets up some things for central air systems, needs to follow setting of an airloop num
     548          794 :     auto &c(coilSelectionDataObjs[coilVecIndex]);
     549          794 :     if (c->airloopNum > 0 && c->airloopNum <= int(state.dataAirSystemsData->PrimaryAirSystems.size())) {
     550              :         // see if there is an OA controller
     551          322 :         if (state.dataAirSystemsData->PrimaryAirSystems(c->airloopNum).OASysExists) {
     552              :             // loop over OA controllers and match node num ?
     553          220 :             for (int loop = 1; loop <= state.dataMixedAir->NumOAControllers; ++loop) {
     554           98 :                 if (state.dataAirSystemsData->PrimaryAirSystems(c->airloopNum).OASysInletNodeNum == state.dataMixedAir->OAController(loop).RetNode) {
     555           98 :                     c->oaControllerNum = loop;
     556              :                 }
     557              :             }
     558              :         }
     559              :         // fill list of zones connected to this air loop
     560              :         // this could be reworked to use different structure which is available now since std 62.1 changes
     561          322 :         if (allocated(state.dataAirLoop->AirToZoneNodeInfo)) {
     562          126 :             if (state.dataAirLoop->AirToZoneNodeInfo(c->airloopNum).NumZonesCooled > 0) {
     563          118 :                 int zoneCount = state.dataAirLoop->AirToZoneNodeInfo(c->airloopNum).NumZonesCooled;
     564          118 :                 c->zoneNum.resize(zoneCount);
     565          118 :                 c->zoneName.resize(zoneCount);
     566          317 :                 for (int loopZone = 1; loopZone <= state.dataAirLoop->AirToZoneNodeInfo(c->airloopNum).NumZonesCooled; ++loopZone) {
     567          199 :                     c->zoneNum[loopZone - 1] = state.dataAirLoop->AirToZoneNodeInfo(c->airloopNum).CoolCtrlZoneNums(loopZone);
     568          199 :                     c->zoneName[loopZone - 1] = state.dataHeatBal->Zone(c->zoneNum[loopZone - 1]).Name;
     569              :                 }
     570              :             }
     571              : 
     572          126 :             if (state.dataAirLoop->AirToZoneNodeInfo(c->airloopNum).NumZonesHeated > 0) {
     573            2 :                 int zoneCount = state.dataAirLoop->AirToZoneNodeInfo(c->airloopNum).NumZonesHeated;
     574            6 :                 for (int loopZone = 1; loopZone <= zoneCount; ++loopZone) {
     575            4 :                     int zoneIndex = state.dataAirLoop->AirToZoneNodeInfo(c->airloopNum).HeatCtrlZoneNums(loopZone);
     576              :                     // see if this zone is new or already in list
     577            4 :                     bool found = false;
     578            6 :                     for (auto const &z : c->zoneNum) {
     579            2 :                         if (z == zoneIndex) {
     580            0 :                             found = true;
     581            0 :                             break;
     582              :                         }
     583            4 :                     }
     584            4 :                     if (!found) { // add it
     585            4 :                         c->zoneNum.emplace_back(zoneIndex);
     586            4 :                         c->zoneName.emplace_back(state.dataHeatBal->Zone(zoneIndex).Name);
     587              :                     }
     588              :                 }
     589              :             }
     590              :         }
     591              :     }
     592          794 : }
     593              : 
     594            0 : void ReportCoilSelection::doZoneEqSetup(EnergyPlusData &state, int const coilVecIndex)
     595              : {
     596            0 :     auto &c(coilSelectionDataObjs[coilVecIndex]);
     597            0 :     c->coilLocation = "Zone";
     598            0 :     c->zoneNum.resize(1);
     599            0 :     c->zoneNum[0] = c->zoneEqNum;
     600            0 :     c->zoneName.resize(1);
     601            0 :     c->zoneName[0] = state.dataHeatBal->Zone(c->zoneNum[0]).Name;
     602            0 :     c->typeHVACname = "Zone Equipment"; // init
     603              : 
     604              :     // find the system and get   c->oaControllerNum
     605              : 
     606              :     // need to rework for new multiple air handler in zone
     607              : 
     608              :     // going to need the zone inlet node index for this now... how to find it??
     609              : 
     610              :     // maybe not needed, would be set in other calls   c->airloopNum = DataZoneEquipment::ZoneEquipConfig( c->zoneEqNum  ).AirLoopNum;
     611              : 
     612            0 :     if (c->airloopNum > 0) {
     613            0 :         if (state.dataAirSystemsData->PrimaryAirSystems(c->airloopNum).OASysExists) {
     614              :             // loop over OA controllers and match node num ?
     615            0 :             for (int loop = 1; loop <= state.dataMixedAir->NumOAControllers; ++loop) {
     616            0 :                 if (state.dataAirSystemsData->PrimaryAirSystems(c->airloopNum).OASysInletNodeNum == state.dataMixedAir->OAController(loop).RetNode) {
     617            0 :                     c->oaControllerNum = loop;
     618              :                 }
     619              :             }
     620              :         }
     621              :         // fill out supply fan info
     622            0 :         auto *fan = state.dataFans->fans(state.dataAirSystemsData->PrimaryAirSystems(c->airloopNum).supFanNum);
     623            0 :         state.dataRptCoilSelection->coilSelectionReportObj->setCoilSupplyFanInfo(
     624            0 :             state, c->coilName_, c->coilObjName, fan->Name, fan->type, state.dataAirSystemsData->PrimaryAirSystems(c->airloopNum).supFanNum);
     625              :     }
     626              : 
     627            0 :     if (c->zoneEqNum > 0) {
     628            0 :         associateZoneCoilWithParent(state, c);
     629              :     }
     630            0 : }
     631              : 
     632           46 : void ReportCoilSelection::doFinalProcessingOfCoilData(EnergyPlusData &state)
     633              : {
     634              :     // this routine does some final processing in preparation for writing out results
     635           66 :     for (auto &c : coilSelectionDataObjs) {
     636              : 
     637              :         // mine final/hard values from coil models
     638              : 
     639           20 :         if (c->zoneEqNum > 0) {
     640            9 :             associateZoneCoilWithParent(state, c);
     641              :         }
     642              : 
     643           20 :         if (c->airloopNum > state.dataHVACGlobal->NumPrimaryAirSys && c->oASysNum > 0) {
     644            0 :             c->coilLocation = "DOAS AirLoop";
     645            0 :             c->typeHVACname = "AirLoopHVAC:DedicatedOutdoorAirSystem";
     646            0 :             int DOASSysNum = state.dataAirLoop->OutsideAirSys(c->oASysNum).AirLoopDOASNum;
     647            0 :             c->userNameforHVACsystem = state.dataAirLoopHVACDOAS->airloopDOAS[DOASSysNum].Name;
     648           20 :         } else if (c->airloopNum > 0 && c->zoneEqNum == 0) {
     649            8 :             c->coilLocation = "AirLoop";
     650            8 :             c->typeHVACname = "AirLoopHVAC";
     651            8 :             c->userNameforHVACsystem = state.dataAirSystemsData->PrimaryAirSystems(c->airloopNum).Name;
     652           12 :         } else if (c->zoneEqNum > 0 && c->airloopNum > 0) { // e.g. reheat coil, has a system and is zone equipment
     653            0 :             c->userNameforHVACsystem += " on air system named " + state.dataAirSystemsData->PrimaryAirSystems(c->airloopNum).Name;
     654            0 :             c->coilLocation = "Zone Equipment";
     655              :         }
     656              : 
     657           20 :         if (c->coilDesVolFlow > 0) {
     658           11 :             c->oaPeakVolFrac = (c->oaPeakVolFlow / c->coilDesVolFlow) * 100.0; // make into percentage
     659              :         } else {
     660            9 :             c->oaPeakVolFrac = -999.0;
     661              :         }
     662              : 
     663           20 :         c->coilSizingMethodConcurrenceName = DataSizing::CoilSizingConcurrenceNames[(int)c->coilSizingMethodConcurrence];
     664              : 
     665           20 :         if (c->coilSizingMethodCapacity == DataSizing::CoolingDesignCapacity) {
     666            3 :             c->coilSizingMethodCapacityName = "CoolingDesignCapacity";
     667           17 :         } else if (c->coilSizingMethodCapacity == DataSizing::HeatingDesignCapacity) {
     668            3 :             c->coilSizingMethodCapacityName = "HeatingDesignCapacity";
     669           14 :         } else if (c->coilSizingMethodCapacity == DataSizing::CapacityPerFloorArea) {
     670            0 :             c->coilSizingMethodCapacityName = "CapacityPerFloorArea";
     671           14 :         } else if (c->coilSizingMethodCapacity == DataSizing::FractionOfAutosizedCoolingCapacity) {
     672            0 :             c->coilSizingMethodCapacityName = "FractionOfAutosizedCoolingCapacity";
     673           14 :         } else if (c->coilSizingMethodCapacity == DataSizing::FractionOfAutosizedHeatingCapacity) {
     674            0 :             c->coilSizingMethodCapacityName = "FractionOfAutosizedHeatingCapacity";
     675              :         }
     676              : 
     677           20 :         if (c->coilSizingMethodAirFlow == DataSizing::SupplyAirFlowRate) {
     678            0 :             c->coilSizingMethodAirFlowName = "SupplyAirFlowRate";
     679           20 :         } else if (c->coilSizingMethodAirFlow == DataSizing::FlowPerFloorArea) {
     680            0 :             c->coilSizingMethodAirFlowName = "FlowPerFloorArea";
     681           20 :         } else if (c->coilSizingMethodAirFlow == DataSizing::FractionOfAutosizedCoolingAirflow) {
     682            0 :             c->coilSizingMethodAirFlowName = "FractionOfAutosizedCoolingAirflow";
     683           20 :         } else if (c->coilSizingMethodAirFlow == DataSizing::FractionOfAutosizedHeatingAirflow) {
     684            0 :             c->coilSizingMethodAirFlowName = "FractionOfAutosizedHeatingAirflow";
     685              :         }
     686              : 
     687           20 :         if (c->isCoilSizingForTotalLoad) {
     688            1 :             c->coilPeakLoadTypeToSizeOnName = "Total";
     689              :         } else {
     690           19 :             c->coilPeakLoadTypeToSizeOnName = "Sensible";
     691              :         }
     692              : 
     693           20 :         if (c->capIsAutosized) {
     694            9 :             c->coilCapAutoMsg = "Yes";
     695              :         } else {
     696           11 :             c->coilCapAutoMsg = "No";
     697              :         }
     698              : 
     699           20 :         if (c->volFlowIsAutosized) {
     700            8 :             c->coilVolFlowAutoMsg = "Yes";
     701              :         } else {
     702           12 :             c->coilVolFlowAutoMsg = "No";
     703              :         }
     704              : 
     705           20 :         if (c->oaPretreated) {
     706            0 :             c->coilOAPretreatMsg = "Yes";
     707              :         } else {
     708           20 :             c->coilOAPretreatMsg = "No";
     709              :         }
     710              : 
     711              :         // call psych routine to flush out moist air metrics from those available
     712           20 :         if (c->coilDesEntTemp != -999.0 && c->coilDesEntHumRat != -999.0) {
     713           20 :             c->coilDesEntWetBulb = Psychrometrics::PsyTwbFnTdbWPb(
     714           10 :                 state, c->coilDesEntTemp, c->coilDesEntHumRat, state.dataEnvrn->StdBaroPress, "ReportCoilSelection::doFinalProcessingOfCoilData");
     715           10 :             if (c->coilDesEntHumRat != -999.0) {
     716           10 :                 c->coilDesEntEnth = Psychrometrics::PsyHFnTdbW(c->coilDesEntTemp, c->coilDesEntHumRat);
     717              :             }
     718              :         }
     719           20 :         if (c->oaPeakTemp != -999.0 && c->oaPeakHumRat != -999.0) {
     720           16 :             c->oaPeakWetBulb = Psychrometrics::PsyTwbFnTdbWPb(
     721            8 :                 state, c->oaPeakTemp, c->oaPeakHumRat, state.dataEnvrn->StdBaroPress, "ReportCoilSelection::doFinalProcessingOfCoilData");
     722              :         }
     723              : 
     724           20 :         if (c->waterLoopNum > 0 && c->pltSizNum > 0) {
     725              : 
     726            2 :             c->plantLoopName = state.dataPlnt->PlantLoop(c->waterLoopNum).Name;
     727            2 :             if (state.dataSize->PlantSizData(c->pltSizNum).LoopType != DataSizing::TypeOfPlantLoop::Steam) {
     728            1 :                 c->rhoFluid = state.dataPlnt->PlantLoop(c->waterLoopNum)
     729            1 :                                   .glycol->getDensity(state, Constant::InitConvTemp, "ReportCoilSelection::doFinalProcessingOfCoilData");
     730              : 
     731            1 :                 c->cpFluid = state.dataPlnt->PlantLoop(c->waterLoopNum)
     732            1 :                                  .glycol->getSpecificHeat(state, Constant::InitConvTemp, "ReportCoilSelection::doFinalProcessingOfCoilData");
     733              :             } else { // steam loop
     734            1 :                 c->rhoFluid = state.dataPlnt->PlantLoop(c->waterLoopNum)
     735            1 :                                   .steam->getSatDensity(state, 100.0, 1.0, "ReportCoilSelection::doFinalProcessingOfCoilData");
     736            1 :                 c->cpFluid = state.dataPlnt->PlantLoop(c->waterLoopNum)
     737            1 :                                  .steam->getSatSpecificHeat(state, 100.0, 0.0, "ReportCoilSelection::doFinalProcessingOfCoilData");
     738              :             }
     739            2 :             c->plantDesMaxMassFlowRate = state.dataPlnt->PlantLoop(c->waterLoopNum).MaxMassFlowRate;
     740            2 :             if (c->plantDesMaxMassFlowRate > 0.0 && c->coilDesWaterMassFlow > 0.0) {
     741            2 :                 c->coilFlowPrcntPlantFlow = (c->coilDesWaterMassFlow / c->plantDesMaxMassFlowRate) * 100.0; // convert to percentage.
     742              :             }
     743              :         }
     744              :         // fill out some fan information
     745           20 :         HVAC::FanType locFanType = HVAC::FanType::Invalid;
     746           20 :         if (c->supFanNum == 0) {
     747           12 :             c->supFanNum = Fans::GetFanIndex(state, c->fanAssociatedWithCoilName);
     748              :         }
     749              : 
     750           20 :         if (c->supFanNum != 0) {
     751            8 :             auto *fan = state.dataFans->fans(c->supFanNum);
     752            8 :             locFanType = fan->type;
     753            8 :             c->fanTypeName = HVAC::fanTypeNames[(int)locFanType];
     754            8 :             c->fanSizeMaxAirVolumeFlow = fan->maxAirFlowRate;
     755            8 :             c->fanSizeMaxAirMassFlow = fan->maxAirMassFlowRate;
     756              :         }
     757              : 
     758           20 :         c->coilAndFanNetTotalCapacityIdealPeak = c->coilTotCapAtPeak - c->fanHeatGainIdealPeak;
     759              : 
     760              :         // fill out some plant design info
     761           20 :         if (c->pltSizNum > 0) {
     762            2 :             c->plantDesSupTemp = state.dataSize->PlantSizData(c->pltSizNum).ExitTemp;
     763            2 :             c->plantDesDeltaTemp = state.dataSize->PlantSizData(c->pltSizNum).DeltaT;
     764            2 :             if (state.dataSize->PlantSizData(c->pltSizNum).LoopType == DataSizing::TypeOfPlantLoop::Heating) {
     765            0 :                 c->plantDesRetTemp = c->plantDesSupTemp - c->plantDesDeltaTemp;
     766            4 :             } else if (state.dataSize->PlantSizData(c->pltSizNum).LoopType == DataSizing::TypeOfPlantLoop::Cooling ||
     767            2 :                        state.dataSize->PlantSizData(c->pltSizNum).LoopType == DataSizing::TypeOfPlantLoop::Condenser) {
     768            0 :                 c->plantDesRetTemp = c->plantDesSupTemp + c->plantDesDeltaTemp;
     769              :             }
     770              : 
     771            2 :             if (state.dataSize->PlantSizData(c->pltSizNum).LoopType != DataSizing::TypeOfPlantLoop::Steam) {
     772            2 :                 c->plantDesCapacity = c->cpFluid * c->rhoFluid * state.dataSize->PlantSizData(c->pltSizNum).DeltaT *
     773            1 :                                       state.dataSize->PlantSizData(c->pltSizNum).DesVolFlowRate;
     774              :             } else {
     775              :                 // find boiler on this plant loop and get capacity from it
     776            1 :                 if (allocated(state.dataBoilerSteam->Boiler)) {
     777            0 :                     for (int boilerIndex = 1; boilerIndex <= (int)state.dataBoilerSteam->Boiler.size(); ++boilerIndex) {
     778            0 :                         if (state.dataBoilerSteam->Boiler(boilerIndex).plantLoc.loopNum == c->waterLoopNum) { // steam boiler on this loop
     779            0 :                             c->plantDesSupTemp = state.dataBoilerSteam->Boiler(boilerIndex).TempUpLimitBoilerOut;
     780            0 :                             c->plantDesRetTemp = state.dataBoilerSteam->Boiler(boilerIndex).TempUpLimitBoilerOut - c->plantDesDeltaTemp;
     781            0 :                             c->plantDesCapacity = state.dataBoilerSteam->Boiler(boilerIndex).NomCap;
     782              :                         }
     783              :                     }
     784              :                 }
     785              :             }
     786              : 
     787            2 :             if (c->plantDesCapacity > 0.0) {
     788            0 :                 c->coilCapPrcntPlantCap = (c->coilTotCapAtPeak / c->plantDesCapacity) * 100.0; // convert to percentage.
     789              :             }
     790              :         }
     791              : 
     792           20 :         if (c->pltSizNum == 0 && c->waterLoopNum == 0) {
     793            0 :             c->rhoFluid = -999.0;
     794            0 :             c->cpFluid = -999.0;
     795            0 :             c->plantDesMaxMassFlowRate = -999.0;
     796            0 :             c->coilFlowPrcntPlantFlow = -999.0;
     797            0 :             c->plantDesSupTemp = -999.0;
     798            0 :             c->plantDesDeltaTemp = -999.0;
     799            0 :             c->plantDesRetTemp = -999.0;
     800            0 :             c->coilDesWaterMassFlow = -999.0;
     801            0 :             c->coilDesWaterEntTemp = -999.0;
     802            0 :             c->coilDesWaterLvgTemp = -999.0;
     803            0 :             c->coilDesWaterTempDiff = -999.0;
     804            0 :             c->plantDesCapacity = -999.0;
     805            0 :             c->coilCapPrcntPlantCap = -999.0;
     806              :         }
     807              : 
     808           20 :         c->cpDryAir = Psychrometrics::PsyCpAirFnW(0.0);
     809           20 :         c->rhoStandAir = state.dataEnvrn->StdRhoAir;
     810              : 
     811              :         // apply ADP method to find an SHR for Ideal loads peak, calculate sensible capacity for cooling coils
     812           20 :         if (c->coilDesEntTemp > c->coilDesLvgTemp) { // cooling coil
     813              :             Real64 CoilADPTemp =
     814            7 :                 Psychrometrics::PsyTdpFnWPb(state, c->coilDesLvgHumRat, state.dataEnvrn->StdBaroPress); // apparatus dewpoint temperature
     815              :             Real64 CoilADPHumRat =
     816            7 :                 Psychrometrics::PsyWFnTdpPb(state, CoilADPTemp, state.dataEnvrn->StdBaroPress); // humidity ratio at apparatus dewpoint temperaure
     817            7 :             Real64 CoilTinwADPEnthalpy = Psychrometrics::PsyHFnTdbW(
     818            7 :                 c->coilDesEntTemp, CoilADPHumRat); // Enthalpy at inlet drybulb and humidity ratio at apparatus dewpoint temperature
     819              :             Real64 CoilADPEnthalpy =
     820            7 :                 Psychrometrics::PsyHFnTdbW(CoilADPTemp, CoilADPHumRat); // Enthalpy at apparatus dewpoint, with Tdb set at apparatus dewpoint
     821            7 :             Real64 SHRatIdealPeak(1.0);
     822            7 :             if ((c->coilDesEntEnth - CoilADPEnthalpy) > 1.e-10) {
     823            7 :                 SHRatIdealPeak = min((CoilTinwADPEnthalpy - CoilADPEnthalpy) / (c->coilDesEntEnth - CoilADPEnthalpy), 1.0); // calculate SHR
     824              :             } else {
     825            0 :                 SHRatIdealPeak = 1.0;
     826              :             }
     827            7 :             c->coilSensCapAtPeak = SHRatIdealPeak * c->coilTotCapAtPeak;
     828              :         }
     829           46 :     } // end for loop over each coil
     830           46 : }
     831              : 
     832         3752 : int ReportCoilSelection::getIndexForOrCreateDataObjFromCoilName(EnergyPlusData &state,
     833              :                                                                 std::string const &coilName, // user-defined name of the coil
     834              :                                                                 std::string const &coilType  // idf input object class name of coil
     835              : )
     836              : {
     837         3752 :     int index(-1);
     838         7439 :     for (int i = 0; i < numCoilsReported_; i++) {
     839         6931 :         if (coilSelectionDataObjs[i] != nullptr) {
     840         6931 :             if (Util::SameString(coilSelectionDataObjs[i]->coilName_, coilName)) {
     841         3284 :                 if (Util::SameString(coilSelectionDataObjs[i]->coilObjName, coilType)) {
     842         3244 :                     return index = i;
     843              :                 } else {
     844              :                     // throw error  coil type does not match coil name, check for unique names across coil types
     845           80 :                     ShowWarningError(state,
     846           80 :                                      format("check for unique coil names across different coil types: {} occurs in both {} and {}",
     847              :                                             coilName,
     848              :                                             coilType,
     849           40 :                                             coilSelectionDataObjs[i]->coilObjName));
     850              :                 }
     851              :             }
     852              :         }
     853              :     }
     854              : 
     855          508 :     if (index == -1) { // then did not find it
     856              :         // check if really a coil type
     857          508 :         bool found(false);
     858          508 :         bool locIsCooling(false);
     859          508 :         bool locIsHeating(false);
     860         7959 :         for (int loop = 1; loop <= HVAC::NumAllCoilTypes; ++loop) {
     861         7959 :             if (Util::SameString(coilType, HVAC::cAllCoilTypes(loop))) {
     862          508 :                 found = true;
     863          508 :                 locIsCooling = Util::SameString(coilType, HVAC::cCoolingCoilTypes(loop));
     864          508 :                 locIsHeating = Util::SameString(coilType, HVAC::cHeatingCoilTypes(loop));
     865          508 :                 break;
     866              :             }
     867              :         }
     868          508 :         if (found) {
     869          508 :             coilSelectionDataObjs.emplace_back(new CoilSelectionData(coilName));
     870          508 :             index = coilSelectionDataObjs.size() - 1;
     871          508 :             coilSelectionDataObjs[index]->coilObjName = coilType;
     872          508 :             ++numCoilsReported_;
     873          508 :             coilSelectionDataObjs[index]->isCooling = locIsCooling;
     874          508 :             coilSelectionDataObjs[index]->isHeating = locIsHeating;
     875              :         }
     876              :     }
     877              : 
     878          508 :     if (index == -1) {
     879            0 :         ShowFatalError(state, format("getIndexForOrCreateDataObjFromCoilName: Developer error - not a coil: {} = {}", coilType, coilName));
     880              :     }
     881          508 :     return index;
     882              : }
     883              : 
     884            9 : void ReportCoilSelection::associateZoneCoilWithParent(EnergyPlusData &state, std::unique_ptr<CoilSelectionData> &c)
     885              : {
     886            9 :     c->coilLocation = "Unknown";
     887            9 :     c->typeHVACname = "Unknown";
     888            9 :     c->userNameforHVACsystem = "Unknown";
     889              :     // now search equipment
     890            9 :     auto const &zoneEquipList = state.dataZoneEquip->ZoneEquipList(c->zoneEqNum);
     891            9 :     bool coilFound = false;
     892            9 :     std::string fanType;
     893            9 :     std::string fanName;
     894           14 :     auto thisSubCoilLambda = [&c](const DataZoneEquipment::SubEquipmentData &myCoil) { return myCoil.Name == c->coilName_; };
     895           15 :     auto thisSubFanLambda = [](const DataZoneEquipment::SubEquipmentData &myFan) { return myFan.TypeOf.rfind("FAN:", 0) == 0; };
     896            3 :     auto thisSubSubCoilLambda = [&c](const DataZoneEquipment::SubSubEquipmentData &myCoil) { return myCoil.Name == c->coilName_; };
     897            3 :     auto thisSubSubFanLambda = [](const DataZoneEquipment::SubSubEquipmentData &myFan) { return myFan.TypeOf.rfind("FAN:", 0) == 0; };
     898              : 
     899           15 :     for (int equipLoop = 1; equipLoop <= zoneEquipList.NumOfEquipTypes; ++equipLoop) {
     900              :         // coil should be found only once, fan could be found multiple times, reset here
     901              :         // for each type of equipment (equipLoop) only one coil and fan could be found as a pair
     902           13 :         bool fanFound = false;
     903           13 :         auto &thisSubEq = zoneEquipList.EquipData(equipLoop).SubEquipData;
     904              : 
     905              :         // search for coil and fan SubEquipData and return parent type/name and fan type/name for coil reports.
     906           13 :         if (std::find_if(thisSubEq.begin(), thisSubEq.end(), thisSubCoilLambda) != thisSubEq.end()) {
     907            5 :             c->typeHVACname = zoneEquipList.EquipTypeName(equipLoop);
     908            5 :             c->userNameforHVACsystem = zoneEquipList.EquipName(equipLoop);
     909            5 :             c->coilLocation = "Zone Equipment";
     910            5 :             int zoneEqListIndex = Util::FindItemInList(zoneEquipList.Name, state.dataZoneEquip->ZoneEquipList);
     911            5 :             if (c->zoneNum.empty()) {
     912            2 :                 c->zoneNum.resize(1);
     913              :             }
     914            5 :             c->zoneNum[0] = zoneEqListIndex;
     915            5 :             if (c->zoneName.empty()) {
     916            2 :                 c->zoneName.resize(1);
     917              :             }
     918            5 :             c->zoneName[0] = state.dataHeatBal->Zone(zoneEqListIndex).Name;
     919            5 :             coilFound = true;
     920              :         }
     921           13 :         auto const &fanIterator = std::find_if(thisSubEq.begin(), thisSubEq.end(), thisSubFanLambda);
     922           13 :         if (fanIterator != thisSubEq.end()) {
     923            6 :             unsigned int fanIndex = fanIterator - thisSubEq.begin();
     924              :             // notice the brackets on the Array1D for [fanIndex]
     925            6 :             fanType = thisSubEq[fanIndex].TypeOf;
     926            6 :             fanName = thisSubEq[fanIndex].Name;
     927            6 :             fanFound = true;
     928              :         }
     929              :         // if coil not found in SubEquipData then maybe it's HXAssisted and in SubSubEquipData. Fan is usually already found if exists.
     930           13 :         if (!coilFound || !fanFound) {
     931           13 :             for (int subEq = 1; subEq <= zoneEquipList.EquipData(equipLoop).NumSubEquip; ++subEq) {
     932            5 :                 auto &thisSubSubEq = zoneEquipList.EquipData(equipLoop).SubEquipData(subEq).SubSubEquipData;
     933            5 :                 if (!coilFound) {
     934            5 :                     auto const &coilIterator2 = std::find_if(thisSubSubEq.begin(), thisSubSubEq.end(), thisSubSubCoilLambda);
     935            5 :                     if (coilIterator2 != thisSubSubEq.end()) {
     936            2 :                         c->typeHVACname = zoneEquipList.EquipTypeName(equipLoop);
     937            2 :                         c->userNameforHVACsystem = zoneEquipList.EquipName(equipLoop);
     938            2 :                         c->coilLocation = "Zone Equipment";
     939            2 :                         int zoneEqListIndex = Util::FindItemInList(zoneEquipList.Name, state.dataZoneEquip->ZoneEquipList);
     940            2 :                         if (c->zoneNum.empty()) {
     941            2 :                             c->zoneNum.resize(1);
     942              :                         }
     943            2 :                         c->zoneNum[0] = zoneEqListIndex;
     944            2 :                         if (c->zoneName.empty()) {
     945            2 :                             c->zoneName.resize(1);
     946              :                         }
     947            2 :                         c->zoneName[0] = state.dataHeatBal->Zone(zoneEqListIndex).Name;
     948            2 :                         coilFound = true;
     949              :                     }
     950              :                 }
     951            5 :                 if (!fanFound) {
     952            3 :                     auto const &fanIterator2 = std::find_if(thisSubSubEq.begin(), thisSubSubEq.end(), thisSubSubFanLambda);
     953            3 :                     if (fanIterator2 != thisSubSubEq.end()) {
     954            0 :                         unsigned int fanIndex = fanIterator2 - thisSubSubEq.begin();
     955              :                         // notice the brackets on the Array1D for [fanIndex]
     956            0 :                         fanType = thisSubSubEq[fanIndex].TypeOf;
     957            0 :                         fanName = thisSubSubEq[fanIndex].Name;
     958            0 :                         fanFound = true;
     959              :                     }
     960              :                 }
     961            5 :                 if (coilFound && fanFound) {
     962            0 :                     break;
     963              :                 }
     964              :             }
     965              :         }
     966           13 :         if (coilFound) {
     967            7 :             if (fanFound) {
     968            5 :                 c->fanTypeName = fanType;
     969            5 :                 c->fanAssociatedWithCoilName = fanName;
     970              :             }
     971            7 :             break;
     972              :         }
     973              : 
     974              :     } // for (equipLoop)
     975              : 
     976            9 :     if (c->typeHVACname == "Unknown") {
     977            2 :         ShowWarningError(state, format("Parent object not found for zone coil = {}", c->coilName_));
     978              :     }
     979            9 : }
     980              : 
     981          134 : void ReportCoilSelection::setRatedCoilConditions(EnergyPlusData &state,
     982              :                                                  std::string const &coilName,     // ! user-defined name of the coil
     983              :                                                  std::string const &coilObjName,  //  coil object name, e.g., Coil:Cooling:Water
     984              :                                                  Real64 const RatedCoilTotCap,    // ! rated coil total capacity [W]
     985              :                                                  Real64 const RatedCoilSensCap,   // rated coil sensible capacity [W]
     986              :                                                  Real64 const RatedAirMassFlow,   // rated coil design air mass flow rate [m3/s]
     987              :                                                  Real64 const RatedCoilInDb,      // rated coil inlet air dry bulb at time of peak [C]
     988              :                                                  Real64 const RatedCoilInHumRat,  // rated coil inlet air humidity ratio [kgWater/kgDryAir]
     989              :                                                  Real64 const RatedCoilInWb,      // rated coil inlet air wet bulb [C]
     990              :                                                  Real64 const RatedCoilOutDb,     // rated coil outlet air dry bulb [C]
     991              :                                                  Real64 const RatedCoilOutHumRat, // rated coil outlet air humidity ratio, [kgWater/kgDryAir]
     992              :                                                  Real64 const RatedCoilOutWb,     // rated coil outlet air wet bulb [C]
     993              :                                                  Real64 const RatedCoilOadbRef,   // rated DX coil outside air dry bulb reference [C]
     994              :                                                  Real64 const RatedCoilOawbRef,   // rated DX coil outside air wet bulb reference [C]
     995              :                                                  Real64 const RatedCoilBpFactor,  // rated coil bypass factor
     996              :                                                  Real64 const RatedCoilEff        // rated coil effectiveness
     997              : )
     998              : {
     999          134 :     int index = getIndexForOrCreateDataObjFromCoilName(state, coilName, coilObjName);
    1000          134 :     auto &c(coilSelectionDataObjs[index]);
    1001          134 :     c->coilRatedTotCap = RatedCoilTotCap;
    1002          134 :     c->coilRatedSensCap = RatedCoilSensCap;
    1003          134 :     c->ratedAirMassFlow = RatedAirMassFlow;
    1004          134 :     c->ratedCoilInDb = RatedCoilInDb;
    1005          134 :     c->ratedCoilInWb = RatedCoilInWb;
    1006          134 :     c->ratedCoilInHumRat = RatedCoilInHumRat;
    1007          134 :     if ((RatedCoilInDb == -999.0) || (RatedCoilInHumRat == -999.0)) {
    1008            3 :         c->ratedCoilInEnth = -999.0;
    1009              :     } else {
    1010          131 :         c->ratedCoilInEnth = Psychrometrics::PsyHFnTdbW(RatedCoilInDb, RatedCoilInHumRat);
    1011              :     }
    1012              : 
    1013          134 :     c->ratedCoilOutDb = RatedCoilOutDb;
    1014          134 :     c->ratedCoilOutWb = RatedCoilOutWb;
    1015          134 :     c->ratedCoilOutHumRat = RatedCoilOutHumRat;
    1016          134 :     if ((RatedCoilOutDb == -999.0) || (RatedCoilOutHumRat == -999.0)) {
    1017            3 :         c->ratedCoilOutEnth = -999.0;
    1018              :     } else {
    1019          131 :         c->ratedCoilOutEnth = Psychrometrics::PsyHFnTdbW(RatedCoilOutDb, RatedCoilOutHumRat);
    1020              :     }
    1021              : 
    1022          134 :     c->ratedCoilEff = RatedCoilEff;
    1023          134 :     c->ratedCoilBpFactor = RatedCoilBpFactor;
    1024              :     // TODO    //c->ratedCoilAppDewPt =
    1025          134 :     c->ratedCoilOadbRef = RatedCoilOadbRef;
    1026          134 :     c->ratedCoilOawbRef = RatedCoilOawbRef;
    1027          134 : }
    1028              : 
    1029          633 : void ReportCoilSelection::setCoilAirFlow(EnergyPlusData &state,
    1030              :                                          std::string const &coilName, // user-defined name of the coil
    1031              :                                          std::string const &coilType, // idf input object class name of coil
    1032              :                                          Real64 const airVdot,        // air flow rate in m3/s
    1033              :                                          bool const isAutoSized       // true if air flow was autosized
    1034              : )
    1035              : {
    1036          633 :     int index = getIndexForOrCreateDataObjFromCoilName(state, coilName, coilType);
    1037          633 :     auto &c(coilSelectionDataObjs[index]);
    1038          633 :     c->coilDesVolFlow = airVdot;
    1039          633 :     c->volFlowIsAutosized = isAutoSized;
    1040              : 
    1041          633 :     c->coilDesMassFlow = airVdot * state.dataEnvrn->StdRhoAir;
    1042          633 : }
    1043              : 
    1044            8 : void ReportCoilSelection::setCoilWaterFlowNodeNums(EnergyPlusData &state,
    1045              :                                                    std::string const &coilName, // user-defined name of the coil
    1046              :                                                    std::string const &coilType, // idf input object class name of coil
    1047              :                                                    Real64 const waterVdot,      // plant fluid flow rate in m3/s
    1048              :                                                    bool const isAutoSized,      // true if water flow was autosized
    1049              :                                                    int const inletNodeNum,      // coil chw inlet node num
    1050              :                                                    int const outletNodeNum,     // coil chw outlet node num
    1051              :                                                    int const plantLoopNum       // plant loop structure index
    1052              : )
    1053              : {
    1054            8 :     int plantSizNum = -999;
    1055            8 :     if ((state.dataSize->NumPltSizInput > 0) && (inletNodeNum > 0) && (outletNodeNum > 0)) {
    1056            6 :         bool errorsfound = false;
    1057            6 :         plantSizNum = PlantUtilities::MyPlantSizingIndex(state, "water coil", coilName, inletNodeNum, outletNodeNum, errorsfound);
    1058              :     }
    1059            8 :     state.dataRptCoilSelection->coilSelectionReportObj->setCoilWaterFlowPltSizNum(
    1060              :         state, coilName, coilType, waterVdot, isAutoSized, plantSizNum, plantLoopNum);
    1061            8 : }
    1062              : 
    1063          168 : void ReportCoilSelection::setCoilWaterFlowPltSizNum(EnergyPlusData &state,
    1064              :                                                     std::string const &coilName, // user-defined name of the coil
    1065              :                                                     std::string const &coilType, // idf input object class name of coil
    1066              :                                                     Real64 const waterVdot,      // plant fluid flow rate in m3/s
    1067              :                                                     bool const isAutoSized,      // true if water flow was autosized
    1068              :                                                     int const plantSizNum,       // plant sizing structure index
    1069              :                                                     int const plantLoopNum       // plant loop structure index
    1070              : )
    1071              : {
    1072          168 :     int index = getIndexForOrCreateDataObjFromCoilName(state, coilName, coilType);
    1073          168 :     auto &c(coilSelectionDataObjs[index]);
    1074          168 :     c->pltSizNum = plantSizNum;
    1075          168 :     c->waterLoopNum = plantLoopNum;
    1076          168 :     if (c->waterLoopNum > 0) {
    1077          145 :         c->plantLoopName = state.dataPlnt->PlantLoop(c->waterLoopNum).Name;
    1078              :     }
    1079              : 
    1080          168 :     if (c->waterLoopNum > 0 && c->pltSizNum > 0) {
    1081          124 :         if (state.dataSize->PlantSizData(c->pltSizNum).LoopType != DataSizing::TypeOfPlantLoop::Steam) {
    1082          244 :             c->rhoFluid =
    1083          122 :                 state.dataPlnt->PlantLoop(c->waterLoopNum).glycol->getDensity(state, Constant::InitConvTemp, "ReportCoilSelection::setCoilWaterFlow");
    1084              : 
    1085          122 :             c->cpFluid = state.dataPlnt->PlantLoop(c->waterLoopNum)
    1086          122 :                              .glycol->getSpecificHeat(state, Constant::InitConvTemp, "ReportCoilSelection::setCoilWaterFlow");
    1087              :         } else { // steam loop
    1088            2 :             c->rhoFluid = state.dataPlnt->PlantLoop(c->waterLoopNum).steam->getSatDensity(state, 100.0, 1.0, "ReportCoilSelection::setCoilWaterFlow");
    1089            4 :             c->cpFluid =
    1090            2 :                 state.dataPlnt->PlantLoop(c->waterLoopNum).steam->getSatSpecificHeat(state, 100.0, 0.0, "ReportCoilSelection::setCoilWaterFlow");
    1091              :         }
    1092              :     }
    1093          168 :     if (c->rhoFluid > 0.0) {
    1094          124 :         c->coilDesWaterMassFlow = waterVdot * c->rhoFluid;
    1095              :     }
    1096          168 :     if (isAutoSized) {
    1097          147 :         c->coilWaterFlowAutoMsg = "Yes";
    1098              :     } else {
    1099           21 :         c->coilWaterFlowAutoMsg = "No";
    1100              :     }
    1101          168 : }
    1102              : 
    1103          290 : void ReportCoilSelection::setCoilEntAirTemp(EnergyPlusData &state,
    1104              :                                             std::string const &coilName,    // user-defined name of the coil
    1105              :                                             std::string const &coilType,    // idf input object class name of coil
    1106              :                                             Real64 const entAirDryBulbTemp, // degree C air entering coil
    1107              :                                             int const curSysNum,            // airloop system number index, if non zero
    1108              :                                             int const curZoneEqNum          // zone equipment list index, if non-zero
    1109              : )
    1110              : {
    1111          290 :     int index = getIndexForOrCreateDataObjFromCoilName(state, coilName, coilType);
    1112          290 :     auto &c(coilSelectionDataObjs[index]);
    1113          290 :     c->coilDesEntTemp = entAirDryBulbTemp;
    1114          290 :     c->airloopNum = curSysNum;
    1115          290 :     doAirLoopSetup(state, index);
    1116          290 :     c->zoneEqNum = curZoneEqNum;
    1117          290 : }
    1118              : 
    1119          320 : void ReportCoilSelection::setCoilEntAirHumRat(EnergyPlusData &state,
    1120              :                                               std::string const &coilName, // user-defined name of the coil
    1121              :                                               std::string const &coilType, // idf input object class name of coil
    1122              :                                               Real64 const entAirHumrat    //
    1123              : )
    1124              : {
    1125          320 :     int index = getIndexForOrCreateDataObjFromCoilName(state, coilName, coilType);
    1126          320 :     auto &c(coilSelectionDataObjs[index]);
    1127          320 :     c->coilDesEntHumRat = entAirHumrat;
    1128          320 : }
    1129              : 
    1130          163 : void ReportCoilSelection::setCoilEntWaterTemp(EnergyPlusData &state,
    1131              :                                               std::string const &coilName, // user-defined name of the coil
    1132              :                                               std::string const &coilType, // idf input object class name of coil
    1133              :                                               Real64 const entWaterTemp    //
    1134              : )
    1135              : {
    1136          163 :     int index = getIndexForOrCreateDataObjFromCoilName(state, coilName, coilType);
    1137          163 :     auto &c(coilSelectionDataObjs[index]);
    1138          163 :     c->coilDesWaterEntTemp = entWaterTemp;
    1139          163 : }
    1140              : 
    1141          102 : void ReportCoilSelection::setCoilLvgWaterTemp(EnergyPlusData &state,
    1142              :                                               std::string const &coilName, // user-defined name of the coil
    1143              :                                               std::string const &coilType, // idf input object class name of coil
    1144              :                                               Real64 const lvgWaterTemp    //
    1145              : )
    1146              : {
    1147          102 :     int index = getIndexForOrCreateDataObjFromCoilName(state, coilName, coilType);
    1148          102 :     auto &c(coilSelectionDataObjs[index]);
    1149          102 :     c->coilDesWaterLvgTemp = lvgWaterTemp;
    1150          102 : }
    1151              : 
    1152          102 : void ReportCoilSelection::setCoilWaterDeltaT(EnergyPlusData &state,
    1153              :                                              std::string const &coilName, // user-defined name of the coil
    1154              :                                              std::string const &coilType, // idf input object class name of coil
    1155              :                                              Real64 const CoilWaterDeltaT // degree C temperature difference used to size coil
    1156              : )
    1157              : {
    1158          102 :     int index = getIndexForOrCreateDataObjFromCoilName(state, coilName, coilType);
    1159          102 :     auto &c(coilSelectionDataObjs[index]);
    1160          102 :     c->coilDesWaterTempDiff = CoilWaterDeltaT;
    1161          102 : }
    1162              : 
    1163          249 : void ReportCoilSelection::setCoilLvgAirTemp(EnergyPlusData &state,
    1164              :                                             std::string const &coilName,   // user-defined name of the coil
    1165              :                                             std::string const &coilType,   // idf input object class name of coil
    1166              :                                             Real64 const lvgAirDryBulbTemp //
    1167              : )
    1168              : {
    1169          249 :     int index = getIndexForOrCreateDataObjFromCoilName(state, coilName, coilType);
    1170          249 :     auto &c(coilSelectionDataObjs[index]);
    1171          249 :     c->coilDesLvgTemp = lvgAirDryBulbTemp;
    1172          249 : }
    1173              : 
    1174          236 : void ReportCoilSelection::setCoilLvgAirHumRat(EnergyPlusData &state,
    1175              :                                               std::string const &coilName, // user-defined name of the coil
    1176              :                                               std::string const &coilType, // idf input object class name of coil
    1177              :                                               Real64 const lvgAirHumRat    //
    1178              : )
    1179              : {
    1180          236 :     int index = getIndexForOrCreateDataObjFromCoilName(state, coilName, coilType);
    1181          236 :     auto &c(coilSelectionDataObjs[index]);
    1182          236 :     c->coilDesLvgHumRat = lvgAirHumRat;
    1183          236 : }
    1184              : 
    1185          222 : std::string PeakHrMinString(EnergyPlusData &state, const int designDay, const int timeStepAtPeak)
    1186              : {
    1187              :     return fmt::format("{}/{} {}",
    1188          222 :                        state.dataWeather->DesDayInput(designDay).Month,
    1189          222 :                        state.dataWeather->DesDayInput(designDay).DayOfMonth,
    1190          444 :                        ReportCoilSelection::getTimeText(state, timeStepAtPeak));
    1191              : }
    1192              : 
    1193          199 : void ReportCoilSelection::setCoilCoolingCapacity(
    1194              :     EnergyPlusData &state,
    1195              :     std::string const &coilName,       // user-defined name of the coil
    1196              :     std::string const &coilType,       // idf input object class name of coil
    1197              :     Real64 const TotalCoolingCap,      // {W} coil cooling capacity, sizing result
    1198              :     bool const isAutoSize,             // true if value was autosized
    1199              :     int const curSysNum,               // airloop system number index, if non zero
    1200              :     int const curZoneEqNum,            // zone equipment list index, if non-zero
    1201              :     int const curOASysNum,             // OA system equipment list index, if non-zero
    1202              :     Real64 const fanCoolLoad,          // {W} fan load used in ideal loads coil sizing
    1203              :     Real64 const coilCapFunTempFac,    // {W} curve result for modification factor for capacity as a function of temperature
    1204              :     Real64 const DXFlowPerCapMinRatio, // non dimensional ratio, capacity adjustment ratio min
    1205              :     Real64 const DXFlowPerCapMaxRatio  // non dimensional ratio, capacity adjustment ratio max
    1206              : )
    1207              : {
    1208          199 :     auto &ZoneEqSizing(state.dataSize->ZoneEqSizing);
    1209          199 :     auto &SysSizPeakDDNum(state.dataSize->SysSizPeakDDNum);
    1210              : 
    1211          199 :     int index = getIndexForOrCreateDataObjFromCoilName(state, coilName, coilType);
    1212          199 :     auto &c(coilSelectionDataObjs[index]);
    1213              :     // no this is adjusted back to ratings    c->coilTotCapAtPeak = TotalCoolingCap;
    1214          199 :     c->coilCapFTIdealPeak = coilCapFunTempFac;
    1215          199 :     c->coilTotCapAtPeak = TotalCoolingCap * c->coilCapFTIdealPeak;
    1216          199 :     c->capIsAutosized = isAutoSize;
    1217          199 :     c->minRatio = DXFlowPerCapMinRatio;
    1218          199 :     c->maxRatio = DXFlowPerCapMaxRatio;
    1219              : 
    1220          199 :     c->fanHeatGainIdealPeak = fanCoolLoad;
    1221          199 :     c->airloopNum = curSysNum;
    1222          199 :     doAirLoopSetup(state, index);
    1223          199 :     c->zoneEqNum = curZoneEqNum;
    1224              :     //    if ( c->zoneEqNum > 0 ) doZoneEqSetup( index );
    1225          199 :     c->oASysNum = curOASysNum;
    1226              : 
    1227          230 :     if (curSysNum > 0 && c->zoneEqNum == 0 && allocated(state.dataSize->FinalSysSizing) && allocated(SysSizPeakDDNum) &&
    1228           31 :         curSysNum <= state.dataHVACGlobal->NumPrimaryAirSys) {
    1229              : 
    1230              :         // These next blocks does not always work with SizingPeriod:WeatherFileDays or SizingPeriod:WeatherFileConditionType, protect against hard
    1231              :         // crash
    1232           31 :         if (SysSizPeakDDNum(curSysNum).SensCoolPeakDD > 0 && SysSizPeakDDNum(curSysNum).SensCoolPeakDD <= state.dataEnvrn->TotDesDays) {
    1233           20 :             c->desDayNameAtSensPeak = state.dataWeather->DesDayInput(SysSizPeakDDNum(curSysNum).SensCoolPeakDD).Title;
    1234           40 :             c->coilSensePeakHrMin = PeakHrMinString(state,
    1235           20 :                                                     SysSizPeakDDNum(curSysNum).SensCoolPeakDD,
    1236           40 :                                                     SysSizPeakDDNum(curSysNum).TimeStepAtSensCoolPk(SysSizPeakDDNum(curSysNum).SensCoolPeakDD));
    1237              :         }
    1238           31 :         if (SysSizPeakDDNum(curSysNum).TotCoolPeakDD > 0 && SysSizPeakDDNum(curSysNum).TotCoolPeakDD <= state.dataEnvrn->TotDesDays) {
    1239           20 :             c->desDayNameAtTotalPeak = state.dataWeather->DesDayInput(SysSizPeakDDNum(curSysNum).TotCoolPeakDD).Title;
    1240           40 :             c->coilTotalPeakHrMin = PeakHrMinString(state,
    1241           20 :                                                     SysSizPeakDDNum(curSysNum).TotCoolPeakDD,
    1242           40 :                                                     SysSizPeakDDNum(curSysNum).TimeStepAtTotCoolPk(SysSizPeakDDNum(curSysNum).TotCoolPeakDD));
    1243              :         }
    1244              : 
    1245           31 :         if (SysSizPeakDDNum(curSysNum).CoolFlowPeakDD > 0 && SysSizPeakDDNum(curSysNum).CoolFlowPeakDD <= state.dataEnvrn->TotDesDays) {
    1246           20 :             c->desDayNameAtAirFlowPeak = state.dataWeather->DesDayInput(SysSizPeakDDNum(curSysNum).CoolFlowPeakDD).Title;
    1247           40 :             c->airPeakHrMin = PeakHrMinString(state,
    1248           20 :                                               SysSizPeakDDNum(curSysNum).CoolFlowPeakDD,
    1249           40 :                                               SysSizPeakDDNum(curSysNum).TimeStepAtCoolFlowPk(SysSizPeakDDNum(curSysNum).CoolFlowPeakDD));
    1250              :         }
    1251              : 
    1252           31 :         auto const &finalSysSizing = state.dataSize->FinalSysSizing(curSysNum);
    1253           31 :         c->isCoilSizingForTotalLoad = (finalSysSizing.coolingPeakLoad == DataSizing::PeakLoad::TotalCooling);
    1254           31 :         c->oaPeakTemp = finalSysSizing.OutTempAtCoolPeak;
    1255           31 :         c->oaPeakVolFlow = finalSysSizing.DesOutAirVolFlow;
    1256           31 :         c->oaPeakHumRat = finalSysSizing.OutHumRatAtCoolPeak;
    1257           31 :         c->raPeakTemp = finalSysSizing.RetTempAtCoolPeak;
    1258           31 :         c->raPeakHumRat = finalSysSizing.RetHumRatAtCoolPeak;
    1259           31 :         c->coilSizingMethodConcurrence = static_cast<DataSizing::CoilSizingConcurrence>(finalSysSizing.SizingOption);
    1260           31 :         c->coilSizingMethodCapacity = finalSysSizing.CoolingCapMethod;
    1261           31 :         c->coilSizingMethodAirFlow = finalSysSizing.ScaleCoolSAFMethod;
    1262              :         // DesOutAirVolFlow
    1263              : 
    1264              :         // loop over cooled zones attached to this airloop to find average Room condition
    1265              :         // change weighting to use supply air flow rate rather than zone air volume for all the zones on this coil's air system
    1266           31 :         Real64 sumT_Vdot(0.0);   // numerator for average zone temperature, zone temperature values times zone supply air volume flow rate
    1267           31 :         Real64 sumW_Vdot(0.0);   // numerator average zone humidity ratio, zone hum rat value times zone supply air volume flow rate
    1268           31 :         Real64 sumSensLoad(0.0); // straight total for zone design loads
    1269           31 :         Real64 sumVdot(0.0);     // denominator for supply air flow rate weighted averages
    1270              : 
    1271              :         // Decide what day and time to use for zone/room averages
    1272           31 :         int SysPeakDDnum(0);
    1273           31 :         int SysPeakTimeStepInDay(0);
    1274           31 :         if (finalSysSizing.coolingPeakLoad == DataSizing::PeakLoad::TotalCooling) {
    1275            1 :             SysPeakDDnum = SysSizPeakDDNum(curSysNum).TotCoolPeakDD;
    1276            1 :             if (SysPeakDDnum > 0) {
    1277            1 :                 SysPeakTimeStepInDay = SysSizPeakDDNum(curSysNum).TimeStepAtTotCoolPk(SysSizPeakDDNum(curSysNum).TotCoolPeakDD);
    1278              :             }
    1279           30 :         } else if (finalSysSizing.coolingPeakLoad == DataSizing::PeakLoad::SensibleCooling) {
    1280           20 :             SysPeakDDnum = SysSizPeakDDNum(curSysNum).SensCoolPeakDD;
    1281           20 :             if (SysPeakDDnum > 0) {
    1282           19 :                 SysPeakTimeStepInDay = SysSizPeakDDNum(curSysNum).TimeStepAtSensCoolPk(SysSizPeakDDNum(curSysNum).SensCoolPeakDD);
    1283              :             }
    1284              :         }
    1285              : 
    1286           31 :         if (SysPeakDDnum > 0 && SysPeakTimeStepInDay > 0) {
    1287           56 :             for (auto &z : c->zoneNum) {
    1288           36 :                 auto const &thisCalcZoneSizing = state.dataSize->CalcZoneSizing(SysPeakDDnum, z);
    1289           36 :                 auto const &thisFinalZoneSizing = state.dataSize->FinalZoneSizing(z);
    1290           36 :                 Real64 mult = state.dataHeatBal->Zone(z).Multiplier * state.dataHeatBal->Zone(z).ListMultiplier;
    1291           36 :                 Real64 Tz = thisCalcZoneSizing.CoolZoneTempSeq(SysPeakTimeStepInDay);
    1292           36 :                 Real64 Vdot_z = thisCalcZoneSizing.CoolFlowSeq(SysPeakTimeStepInDay);
    1293           36 :                 if (Vdot_z == 0.0) { // take value from final zone sizing
    1294            0 :                     Vdot_z = thisFinalZoneSizing.CoolMassFlow;
    1295            0 :                     if (Vdot_z == 0.0) {
    1296            0 :                         Vdot_z = finalSysSizing.DesCoolVolFlow * state.dataEnvrn->StdRhoAir / c->zoneNum.size();
    1297              :                     }
    1298              :                 }
    1299           36 :                 Real64 Wz = thisCalcZoneSizing.CoolZoneHumRatSeq(SysPeakTimeStepInDay);
    1300           36 :                 sumT_Vdot += Tz * Vdot_z * mult;
    1301           36 :                 sumW_Vdot += Wz * Vdot_z * mult;
    1302           36 :                 sumVdot += Vdot_z * mult;
    1303           36 :                 Real64 Qdot_z = thisCalcZoneSizing.CoolLoadSeq(SysPeakTimeStepInDay);
    1304           36 :                 if (Qdot_z > 0.0) {
    1305           36 :                     sumSensLoad += Qdot_z * mult;
    1306              :                 } else {
    1307            0 :                     sumSensLoad += thisFinalZoneSizing.DesCoolLoad * mult;
    1308              :                 }
    1309           20 :             }
    1310              :         }
    1311           31 :         if (c->zoneNum.size() > 0 && sumVdot > 0.0) {
    1312           20 :             c->rmPeakTemp = (sumT_Vdot / sumVdot);
    1313           20 :             c->rmPeakHumRat = (sumW_Vdot / sumVdot);
    1314           40 :             c->rmPeakRelHum =
    1315           20 :                 Psychrometrics::PsyRhFnTdbWPb(state, c->rmPeakTemp, c->rmPeakHumRat, state.dataEnvrn->StdBaroPress) * 100.0; // convert to percentage
    1316              :         } else {
    1317           11 :             c->rmPeakTemp = -999.0;
    1318           11 :             c->rmPeakHumRat = -999.0;
    1319           11 :             c->rmPeakRelHum = -999.0;
    1320              :         }
    1321              : 
    1322           31 :         if (c->coilSizingMethodConcurrence == DataSizing::CoilSizingConcurrence::Coincident) {
    1323            0 :             c->rmSensibleAtPeak = finalSysSizing.SysCoolCoinSpaceSens;
    1324           31 :         } else if (c->coilSizingMethodConcurrence == DataSizing::CoilSizingConcurrence::NonCoincident) {
    1325           31 :             c->rmSensibleAtPeak = sumSensLoad;
    1326              :         } else { // DataSizing::Combination or other
    1327            0 :             c->rmSensibleAtPeak = sumSensLoad;
    1328              :         }
    1329              : 
    1330              :         // now set Coil Ent And Lvg Conditions
    1331           31 :         if (curOASysNum > 0) {                 // then this system coil is part of OA system
    1332            0 :             if (c->coilDesEntTemp == -999.0) { // don't overwrite if already set directly
    1333            0 :                 c->coilDesEntTemp = finalSysSizing.OutTempAtCoolPeak;
    1334              :             }
    1335            0 :             if (c->coilDesEntHumRat == -999.0) { // don't overwrite if already set directly
    1336            0 :                 c->coilDesEntHumRat = finalSysSizing.OutHumRatAtCoolPeak;
    1337              :             }
    1338            0 :             c->coilDesEntWetBulb = Psychrometrics::PsyTwbFnTdbWPb(
    1339            0 :                 state, c->coilDesEntTemp, c->coilDesEntHumRat, state.dataEnvrn->StdBaroPress, "ReportCoilSelection::setCoilCoolingCapacity");
    1340            0 :             c->coilDesEntEnth = Psychrometrics::PsyHFnTdbW(c->coilDesEntTemp, c->coilDesEntHumRat);
    1341            0 :             if (c->coilDesLvgTemp == -999.0) { // don't overwrite if already set directly
    1342            0 :                 c->coilDesLvgTemp = finalSysSizing.PrecoolTemp;
    1343              :             }
    1344            0 :             if (c->coilDesLvgHumRat == -999.0) { // don't overwrite if already set directly
    1345            0 :                 c->coilDesLvgHumRat = finalSysSizing.PrecoolHumRat;
    1346              :             }
    1347            0 :             c->coilDesLvgWetBulb = Psychrometrics::PsyTwbFnTdbWPb(
    1348            0 :                 state, c->coilDesLvgTemp, c->coilDesLvgHumRat, state.dataEnvrn->StdBaroPress, "ReportCoilSelection::setCoilCoolingCapacity");
    1349            0 :             c->coilDesLvgEnth = Psychrometrics::PsyHFnTdbW(c->coilDesLvgTemp, c->coilDesLvgHumRat);
    1350              : 
    1351              :         } else {                               // part of main air loop
    1352           31 :             if (c->coilDesEntTemp == -999.0) { // don't overwrite if already set directly
    1353            0 :                 c->coilDesEntTemp = finalSysSizing.MixTempAtCoolPeak;
    1354              :             }
    1355           31 :             if (c->coilDesEntHumRat == -999.0) { // don't overwrite if already set directly
    1356            0 :                 c->coilDesEntHumRat = finalSysSizing.MixHumRatAtCoolPeak;
    1357              :             }
    1358           62 :             c->coilDesEntWetBulb = Psychrometrics::PsyTwbFnTdbWPb(
    1359           31 :                 state, c->coilDesEntTemp, c->coilDesEntHumRat, state.dataEnvrn->StdBaroPress, "ReportCoilSelection::setCoilCoolingCapacity");
    1360           31 :             c->coilDesEntEnth = Psychrometrics::PsyHFnTdbW(c->coilDesEntTemp, c->coilDesEntHumRat);
    1361           31 :             if (c->coilDesLvgTemp == -999.0) {
    1362            0 :                 c->coilDesLvgTemp = finalSysSizing.CoolSupTemp;
    1363              :             }
    1364           31 :             if (c->coilDesLvgHumRat == -999.0) { // don't overwrite if already set directly
    1365            0 :                 c->coilDesLvgHumRat = finalSysSizing.CoolSupHumRat;
    1366              :             }
    1367           62 :             c->coilDesLvgWetBulb = Psychrometrics::PsyTwbFnTdbWPb(
    1368           31 :                 state, c->coilDesLvgTemp, c->coilDesLvgHumRat, state.dataEnvrn->StdBaroPress, "ReportCoilSelection::setCoilCoolingCapacity");
    1369           31 :             c->coilDesLvgEnth = Psychrometrics::PsyHFnTdbW(c->coilDesLvgTemp, c->coilDesLvgHumRat);
    1370           31 :             if (state.dataAirSystemsData->PrimaryAirSystems(curSysNum).NumOACoolCoils > 0) { // there is precooling of the OA stream
    1371            0 :                 c->oaPretreated = true;
    1372              :             }
    1373              :         }
    1374              : 
    1375          168 :     } else if (curZoneEqNum > 0 && allocated(state.dataSize->FinalZoneSizing)) {
    1376           94 :         c->zoneNum.resize(1);
    1377           94 :         c->zoneName.resize(1);
    1378           94 :         c->zoneNum[0] = curZoneEqNum;
    1379           94 :         if (allocated(state.dataZoneEquip->ZoneEquipConfig)) {
    1380           79 :             c->zoneName[0] = state.dataZoneEquip->ZoneEquipConfig(curZoneEqNum).ZoneName;
    1381              :         }
    1382           94 :         auto const &thisFinalZoneSizing = state.dataSize->FinalZoneSizing(curZoneEqNum);
    1383           94 :         c->desDayNameAtSensPeak = thisFinalZoneSizing.CoolDesDay;
    1384           94 :         c->oaPeakTemp = thisFinalZoneSizing.OutTempAtCoolPeak;
    1385           94 :         c->oaPeakHumRat = thisFinalZoneSizing.OutHumRatAtCoolPeak;
    1386           94 :         c->raPeakTemp = thisFinalZoneSizing.ZoneTempAtCoolPeak;
    1387           94 :         c->raPeakHumRat = thisFinalZoneSizing.ZoneHumRatAtCoolPeak;
    1388           94 :         c->rmPeakTemp = thisFinalZoneSizing.ZoneTempAtCoolPeak;
    1389           94 :         c->rmPeakHumRat = thisFinalZoneSizing.ZoneHumRatAtCoolPeak;
    1390          188 :         c->rmPeakRelHum =
    1391           94 :             Psychrometrics::PsyRhFnTdbWPb(state, c->rmPeakTemp, c->rmPeakHumRat, state.dataEnvrn->StdBaroPress) * 100.0; // convert to percentage
    1392           94 :         if (thisFinalZoneSizing.CoolDDNum > 0 && thisFinalZoneSizing.CoolDDNum <= state.dataEnvrn->TotDesDays) {
    1393           25 :             c->coilSensePeakHrMin = PeakHrMinString(state, thisFinalZoneSizing.CoolDDNum, thisFinalZoneSizing.TimeStepNumAtCoolMax);
    1394           25 :             c->airPeakHrMin = PeakHrMinString(state, thisFinalZoneSizing.CoolDDNum, thisFinalZoneSizing.TimeStepNumAtCoolMax);
    1395              :         }
    1396              : 
    1397           94 :         c->rmSensibleAtPeak = thisFinalZoneSizing.DesCoolLoad;
    1398              : 
    1399           94 :         if (ZoneEqSizing(curZoneEqNum).OAVolFlow > 0.0) {
    1400           11 :             c->oaPeakVolFlow = ZoneEqSizing(curZoneEqNum).OAVolFlow;
    1401              :         } else {
    1402           83 :             c->oaPeakVolFlow = 0.0;
    1403              :         }
    1404              :         // coil entering conditions depend on the type of zone equipment involved
    1405              :         // set typeof_Coil integer
    1406           94 :         if (state.dataSize->TermUnitIU) { // an unpowered induction terminal unit
    1407              :             // should be picked up by CoolingWaterDesAirInletHumRatSizing and CoolingWaterDesWaterInletTempSizing
    1408              :             // c->coilDesEntTemp = DataSizing::FinalZoneSizing( curZoneEqNum ).ZoneTempAtCoolPeak;
    1409              :             // c->coilDesEntHumRat = DataSizing::FinalZoneSizing( curZoneEqNum ).ZoneHumRatAtCoolPeak;
    1410           89 :         } else if (state.dataSize->ZoneEqFanCoil) {
    1411              :             // should be picked up by CoolingWaterDesAirInletHumRatSizing and CoolingWaterDesWaterInletTempSizing
    1412              :             // if ( DataSizing::FinalZoneSizing( curZoneEqNum ).DesCoolMassFlow > 0.0 ) {
    1413              :             //    c->oaPeakVolFrac = min( (DataEnvironment::StdRhoAir * c->oaPeakVolFlow)/DataSizing::FinalZoneSizing( curZoneEqNum
    1414              :             //).DesCoolMassFlow, 1.0 ); } else {     c->oaPeakVolFrac = 0.0;
    1415              :             //}
    1416              :             // c->coilDesEntTemp = c->oaPeakVolFrac * DataSizing::FinalZoneSizing( curZoneEqNum ).OutTempAtCoolPeak + ( 1.0 - c->oaPeakVolFrac ) *
    1417              :             // DataSizing::FinalZoneSizing( curZoneEqNum ).ZoneTempAtCoolPeak;  c->coilDesEntHumRat =  c->oaPeakVolFrac *
    1418              :             // DataSizing::FinalZoneSizing( curZoneEqNum ).OutHumRatAtCoolPeak + ( 1.0 - c->oaPeakVolFrac ) * DataSizing::FinalZoneSizing(
    1419              :             // curZoneEqNum ).ZoneHumRatAtCoolPeak;
    1420           71 :         } else if (state.dataSize->ZoneEqDXCoil) {
    1421           19 :             if (ZoneEqSizing(curZoneEqNum).OAVolFlow > 0.0) {
    1422            5 :                 if (c->coilDesEntTemp == -999.0) { // don't overwrite if already set directly by setCoilEntAirTemp
    1423            0 :                     c->coilDesEntTemp = thisFinalZoneSizing.DesCoolCoilInTemp;
    1424              :                 }
    1425            5 :                 if (c->coilDesEntHumRat == -999.0) { // don't overwrite if already set directly by setCoilEntAirHumRat
    1426            0 :                     c->coilDesEntHumRat = thisFinalZoneSizing.DesCoolCoilInHumRat;
    1427              :                 }
    1428              :             } else {
    1429           14 :                 if (c->coilDesEntTemp == -999.0) { // don't overwrite if already set directly by setCoilEntAirTemp
    1430            1 :                     c->coilDesEntTemp = thisFinalZoneSizing.ZoneTempAtCoolPeak;
    1431              :                 }
    1432           14 :                 if (c->coilDesEntHumRat == -999.0) { // don't overwrite if already set directly by setCoilEntAirHumRat
    1433            1 :                     c->coilDesEntHumRat = thisFinalZoneSizing.ZoneHumRatAtCoolPeak;
    1434              :                 }
    1435              :             }
    1436              :         } else {
    1437           52 :             if (c->coilDesEntTemp == -999.0) { // don't overwrite if already set directly by setCoilEntAirTemp
    1438            9 :                 c->coilDesEntTemp = thisFinalZoneSizing.DesCoolCoilInTemp;
    1439              :             }
    1440           52 :             if (c->coilDesEntHumRat == -999.0) { // don't overwrite if already set directly by setCoilEntAirHumRat
    1441            9 :                 c->coilDesEntHumRat = thisFinalZoneSizing.DesCoolCoilInHumRat;
    1442              :             }
    1443              :         }
    1444              : 
    1445           94 :         if (c->coilDesLvgTemp == -999.0) { // don't overwrite if already set directly by setCoilLvgAirTemp
    1446           18 :             c->coilDesLvgTemp = thisFinalZoneSizing.CoolDesTemp;
    1447              :         }
    1448           94 :         if (c->coilDesLvgHumRat == -999.0) { // don't overwrite if already set directly by setCoilLvgAirHumRat
    1449           18 :             c->coilDesLvgHumRat = thisFinalZoneSizing.CoolDesHumRat;
    1450              :         }
    1451          188 :         c->coilDesLvgWetBulb = Psychrometrics::PsyTwbFnTdbWPb(
    1452           94 :             state, c->coilDesLvgTemp, c->coilDesLvgHumRat, state.dataEnvrn->StdBaroPress, "ReportCoilSelection::setCoilCoolingCapacity");
    1453           94 :         c->coilDesLvgEnth = Psychrometrics::PsyHFnTdbW(c->coilDesLvgTemp, c->coilDesLvgHumRat);
    1454           74 :     } else if (curOASysNum > 0 && c->airloopNum > state.dataHVACGlobal->NumPrimaryAirSys) {
    1455            0 :         if (!state.dataAirLoopHVACDOAS->airloopDOAS.empty()) {
    1456            0 :             int DOASSysNum = state.dataAirLoop->OutsideAirSys(curOASysNum).AirLoopDOASNum;
    1457            0 :             c->coilDesEntTemp = state.dataAirLoopHVACDOAS->airloopDOAS[DOASSysNum].SizingCoolOATemp;
    1458            0 :             c->coilDesEntHumRat = state.dataAirLoopHVACDOAS->airloopDOAS[DOASSysNum].SizingCoolOAHumRat;
    1459            0 :             if (c->coilDesEntTemp > -999.0 && c->coilDesEntHumRat > -999.0) {
    1460            0 :                 c->coilDesEntWetBulb = Psychrometrics::PsyTwbFnTdbWPb(
    1461            0 :                     state, c->coilDesEntTemp, c->coilDesEntHumRat, state.dataEnvrn->StdBaroPress, "ReportCoilSelection::setCoilCoolingCapacity");
    1462            0 :                 c->coilDesEntEnth = Psychrometrics::PsyHFnTdbW(c->coilDesEntTemp, c->coilDesEntHumRat);
    1463              :             }
    1464            0 :             c->coilDesLvgTemp = state.dataAirLoopHVACDOAS->airloopDOAS[DOASSysNum].PrecoolTemp;
    1465            0 :             c->coilDesLvgHumRat = state.dataAirLoopHVACDOAS->airloopDOAS[DOASSysNum].PrecoolHumRat;
    1466            0 :             if (c->coilDesLvgTemp > -999.0 && c->coilDesLvgHumRat > -999.0) {
    1467            0 :                 c->coilDesLvgWetBulb = Psychrometrics::PsyTwbFnTdbWPb(
    1468            0 :                     state, c->coilDesLvgTemp, c->coilDesLvgHumRat, state.dataEnvrn->StdBaroPress, "ReportCoilSelection::setCoilCoolingCapacity");
    1469            0 :                 c->coilDesLvgEnth = Psychrometrics::PsyHFnTdbW(c->coilDesLvgTemp, c->coilDesLvgHumRat);
    1470              :             }
    1471            0 :             DataSizing::SizingConcurrence sizMethod = DataSizing::SizingConcurrence::Invalid;
    1472            0 :             bool sizMethodsAreTheSame = true;
    1473            0 :             for (int airLoopNum = 0; airLoopNum < state.dataAirLoopHVACDOAS->airloopDOAS[DOASSysNum].NumOfAirLoops; ++airLoopNum) {
    1474            0 :                 int actualAirLoopNum = state.dataAirLoopHVACDOAS->airloopDOAS[DOASSysNum].m_AirLoopNum[airLoopNum];
    1475            0 :                 if (airLoopNum == 0) {
    1476            0 :                     sizMethod = state.dataSize->FinalSysSizing(actualAirLoopNum).SizingOption;
    1477              :                 } else {
    1478            0 :                     if (sizMethod != state.dataSize->FinalSysSizing(actualAirLoopNum).SizingOption) {
    1479            0 :                         sizMethodsAreTheSame = false;
    1480              :                     }
    1481              :                 }
    1482              :             }
    1483            0 :             if (sizMethodsAreTheSame) {
    1484            0 :                 c->coilSizingMethodConcurrence = static_cast<DataSizing::CoilSizingConcurrence>(sizMethod);
    1485              :             } else {
    1486            0 :                 c->coilSizingMethodConcurrence = DataSizing::CoilSizingConcurrence::Combination;
    1487              :             }
    1488              :         }
    1489              :     } else {
    1490              :         // do nothing
    1491              :     }
    1492              : 
    1493              :     // calc sensible capacity from inlet outlet
    1494          199 :     c->cpMoistAir = Psychrometrics::PsyCpAirFnW(c->coilDesEntHumRat);
    1495          199 : }
    1496              : 
    1497          264 : void ReportCoilSelection::setCoilHeatingCapacity(
    1498              :     EnergyPlusData &state,
    1499              :     std::string const &coilName,       // user-defined name of the coil
    1500              :     std::string const &coilType,       // idf input object class name of coil
    1501              :     Real64 const totalHeatingCap,      // {W} coil Heating capacity
    1502              :     bool const isAutoSize,             // true if value was autosized
    1503              :     int const curSysNum,               // airloop system number index, if non zero
    1504              :     int const curZoneEqNum,            // zone equipment list index, if non-zero
    1505              :     int const curOASysNum,             // OA system equipment list index, if non-zero
    1506              :     Real64 const fanHeatGain,          // {W} fan load used in ideal loads coil sizing
    1507              :     Real64 const coilCapFunTempFac,    // {W} curve result for modification factor for capacity as a function of temperature
    1508              :     Real64 const DXFlowPerCapMinRatio, // non dimensional ratio, capacity adjustment ratio min
    1509              :     Real64 const DXFlowPerCapMaxRatio  // non dimensional ratio, capacity adjustment ratio max
    1510              : )
    1511              : {
    1512          264 :     int index = getIndexForOrCreateDataObjFromCoilName(state, coilName, coilType);
    1513          264 :     auto &c(coilSelectionDataObjs[index]);
    1514          264 :     c->capIsAutosized = isAutoSize;
    1515          264 :     c->coilCapFTIdealPeak = coilCapFunTempFac;
    1516          264 :     c->coilTotCapAtPeak = totalHeatingCap * c->coilCapFTIdealPeak;
    1517          264 :     c->minRatio = DXFlowPerCapMinRatio;
    1518          264 :     c->maxRatio = DXFlowPerCapMaxRatio;
    1519              : 
    1520          264 :     c->fanHeatGainIdealPeak = fanHeatGain;
    1521          264 :     c->airloopNum = curSysNum;
    1522          264 :     doAirLoopSetup(state, index);
    1523          264 :     c->zoneEqNum = curZoneEqNum;
    1524              :     //    if ( c->zoneEqNum > 0 ) doZoneEqSetup( index );
    1525          264 :     if (curSysNum > 0 && c->zoneEqNum == 0 && curSysNum <= int(state.dataSize->FinalSysSizing.size())) {
    1526           99 :         auto &finalSysSizing = state.dataSize->FinalSysSizing(curSysNum);
    1527           99 :         c->desDayNameAtSensPeak = finalSysSizing.HeatDesDay;
    1528              : 
    1529           99 :         c->oaPeakTemp = finalSysSizing.HeatOutTemp;
    1530           99 :         c->oaPeakHumRat = finalSysSizing.HeatOutHumRat;
    1531           99 :         c->oaPeakVolFlow = finalSysSizing.DesOutAirVolFlow;
    1532           99 :         c->raPeakTemp = finalSysSizing.HeatRetTemp;
    1533           99 :         c->raPeakHumRat = finalSysSizing.HeatRetHumRat;
    1534           99 :         c->coilSizingMethodConcurrence = static_cast<DataSizing::CoilSizingConcurrence>(finalSysSizing.SizingOption);
    1535           99 :         c->coilSizingMethodCapacity = finalSysSizing.HeatingCapMethod;
    1536           99 :         c->coilSizingMethodAirFlow = finalSysSizing.ScaleHeatSAFMethod;
    1537              : 
    1538              :         // Central Heating Coils are always sized at the conditions at the peak Sensible Heating Load
    1539           99 :         c->isCoilSizingForTotalLoad = false;
    1540              : 
    1541              :         // DesOutAirVolFlow
    1542              : 
    1543              :         // loop over heated zones attached to this airloop to find average Room condition, if none heated use cooled zones
    1544              :         // weighted average by zone supply air volume flow rate for all the zones on this coil's air system
    1545           99 :         Real64 sumT_Vdot(0.0); // numerator for average zone temperature, zone temperature values times zone air volume
    1546           99 :         Real64 sumW_Vdot(0.0); // numerator average zone humidity ratio, zone hum rat value times zone air volume
    1547           99 :         Real64 sumLoad(0.0);   // straight total for zone design loads
    1548           99 :         Real64 sumVdot(0.0);   // denominator for zone-volume weighted averages
    1549              : 
    1550           99 :         int SysPeakDDnum = finalSysSizing.HeatDDNum;
    1551           99 :         int SysPeakTimeStepInDay = finalSysSizing.SysHeatCoilTimeStepPk;
    1552           99 :         if (SysPeakDDnum > 0 && SysPeakTimeStepInDay > 0) { // may be zero if no peak found because of zero system load
    1553           70 :             for (auto &z : c->zoneNum) {
    1554           44 :                 auto const &thisCalcZoneSizing = state.dataSize->CalcZoneSizing(SysPeakDDnum, z);
    1555           44 :                 auto const &thisFinalZoneSizing = state.dataSize->FinalZoneSizing(z);
    1556           44 :                 Real64 mult = state.dataHeatBal->Zone(z).Multiplier * state.dataHeatBal->Zone(z).ListMultiplier;
    1557           44 :                 Real64 Tz = thisCalcZoneSizing.HeatZoneTempSeq(SysPeakTimeStepInDay);
    1558           44 :                 Real64 Vdot_z = thisCalcZoneSizing.HeatFlowSeq(SysPeakTimeStepInDay);
    1559           44 :                 if (Vdot_z == 0.0) { // take value from final zone sizing
    1560            1 :                     Vdot_z = thisFinalZoneSizing.HeatMassFlow;
    1561            1 :                     if (Vdot_z == 0.0) {
    1562            1 :                         Vdot_z = finalSysSizing.DesHeatVolFlow * state.dataEnvrn->StdRhoAir / c->zoneNum.size();
    1563              :                     }
    1564              :                 }
    1565           44 :                 Real64 Wz = thisCalcZoneSizing.HeatZoneHumRatSeq(SysPeakTimeStepInDay);
    1566           44 :                 sumT_Vdot += Tz * Vdot_z * mult;
    1567           44 :                 sumW_Vdot += Wz * Vdot_z * mult;
    1568           44 :                 sumVdot += Vdot_z * mult;
    1569           44 :                 Real64 Qdot_z = thisCalcZoneSizing.HeatLoadSeq(SysPeakTimeStepInDay);
    1570           44 :                 if (Qdot_z > 0.0) {
    1571           43 :                     sumLoad += Qdot_z * mult;
    1572              :                 } else {
    1573            1 :                     sumLoad += thisFinalZoneSizing.DesHeatLoad * mult;
    1574              :                 }
    1575           26 :             }
    1576              :         }
    1577              : 
    1578           99 :         if (c->zoneNum.size() > 0 && sumVdot > 0.0) {
    1579           26 :             c->rmPeakTemp = (sumT_Vdot / sumVdot);
    1580           26 :             c->rmPeakHumRat = (sumW_Vdot / sumVdot);
    1581           52 :             c->rmPeakRelHum =
    1582           26 :                 Psychrometrics::PsyRhFnTdbWPb(state, c->rmPeakTemp, c->rmPeakHumRat, state.dataEnvrn->StdBaroPress) * 100.0; // convert to percentage
    1583              :         } else {
    1584           73 :             c->rmPeakTemp = -999.0;
    1585           73 :             c->rmPeakHumRat = -999.0;
    1586           73 :             c->rmPeakRelHum = -999.0;
    1587              :         }
    1588              : 
    1589           99 :         if (c->coilSizingMethodConcurrence == DataSizing::CoilSizingConcurrence::Coincident) {
    1590            0 :             c->rmSensibleAtPeak = finalSysSizing.SysHeatCoinSpaceSens;
    1591           99 :         } else if (c->coilSizingMethodConcurrence == DataSizing::CoilSizingConcurrence::NonCoincident) {
    1592           99 :             c->rmSensibleAtPeak = sumLoad;
    1593              :         }
    1594              : 
    1595           99 :         if (finalSysSizing.HeatDDNum > 0 && finalSysSizing.HeatDDNum <= state.dataEnvrn->TotDesDays) {
    1596           26 :             c->coilSensePeakHrMin = PeakHrMinString(state, finalSysSizing.HeatDDNum, finalSysSizing.SysHeatCoilTimeStepPk);
    1597              : 
    1598           26 :             c->airPeakHrMin = PeakHrMinString(state, finalSysSizing.HeatDDNum, finalSysSizing.SysHeatAirTimeStepPk);
    1599              : 
    1600           26 :             c->desDayNameAtAirFlowPeak = state.dataWeather->DesDayInput(finalSysSizing.HeatDDNum).Title;
    1601              :         }
    1602              : 
    1603              :         // now set Coil Ent And Lvg Conditions
    1604              : 
    1605           99 :         if (curOASysNum > 0) { // then this system coil is part of OA system
    1606           15 :             if (c->coilDesEntTemp == -999.0) {
    1607            0 :                 c->coilDesEntTemp = finalSysSizing.HeatOutTemp;
    1608              :             }
    1609           15 :             if (c->coilDesEntHumRat == -999.0) {
    1610            2 :                 c->coilDesEntHumRat = finalSysSizing.HeatOutHumRat;
    1611              :             }
    1612           30 :             c->coilDesEntWetBulb = Psychrometrics::PsyTwbFnTdbWPb(
    1613           15 :                 state, c->coilDesEntTemp, c->coilDesEntHumRat, state.dataEnvrn->StdBaroPress, "ReportCoilSelection::setCoilHeatingCapacity");
    1614           15 :             c->coilDesEntEnth = Psychrometrics::PsyHFnTdbW(c->coilDesEntTemp, c->coilDesEntHumRat);
    1615           15 :             if (c->coilDesLvgTemp == -999.0) {
    1616            0 :                 c->coilDesLvgTemp = finalSysSizing.PreheatTemp;
    1617              :             }
    1618           15 :             if (c->coilDesLvgHumRat == -999.0) {
    1619            4 :                 c->coilDesLvgHumRat = finalSysSizing.PreheatHumRat;
    1620              :             }
    1621           30 :             c->coilDesLvgWetBulb = Psychrometrics::PsyTwbFnTdbWPb(
    1622           15 :                 state, c->coilDesLvgTemp, c->coilDesLvgHumRat, state.dataEnvrn->StdBaroPress, "ReportCoilSelection::setCoilHeatingCapacity");
    1623           15 :             c->coilDesLvgEnth = Psychrometrics::PsyHFnTdbW(c->coilDesLvgTemp, c->coilDesLvgHumRat);
    1624              : 
    1625              :         } else { // part of main air loop
    1626           84 :             if (c->coilDesEntTemp == -999.0) {
    1627            0 :                 c->coilDesEntTemp = finalSysSizing.HeatMixTemp;
    1628              :             }
    1629           84 :             if (c->coilDesEntHumRat == -999.0) {
    1630            0 :                 c->coilDesEntHumRat = finalSysSizing.HeatMixHumRat;
    1631              :             }
    1632          168 :             c->coilDesEntWetBulb = Psychrometrics::PsyTwbFnTdbWPb(
    1633           84 :                 state, c->coilDesEntTemp, c->coilDesEntHumRat, state.dataEnvrn->StdBaroPress, "ReportCoilSelection::setCoilHeatingCapacity");
    1634           84 :             c->coilDesEntEnth = Psychrometrics::PsyHFnTdbW(c->coilDesEntTemp, c->coilDesEntHumRat);
    1635           84 :             if (c->coilDesLvgTemp == -999.0) {
    1636            0 :                 c->coilDesLvgTemp = finalSysSizing.HeatSupTemp;
    1637              :             }
    1638           84 :             if (c->coilDesLvgHumRat == -999.0) {
    1639            4 :                 c->coilDesLvgHumRat = finalSysSizing.HeatSupHumRat;
    1640              :             }
    1641          168 :             c->coilDesLvgWetBulb = Psychrometrics::PsyTwbFnTdbWPb(
    1642           84 :                 state, c->coilDesLvgTemp, c->coilDesLvgHumRat, state.dataEnvrn->StdBaroPress, "ReportCoilSelection::setCoilHeatingCapacity");
    1643           84 :             c->coilDesLvgEnth = Psychrometrics::PsyHFnTdbW(c->coilDesLvgTemp, c->coilDesLvgHumRat);
    1644           84 :             if (state.dataAirSystemsData->PrimaryAirSystems(curSysNum).NumOAHeatCoils > 0) { // there is preHeating of the OA stream
    1645           19 :                 c->oaPretreated = true;
    1646              :             }
    1647              :         }
    1648              : 
    1649          165 :     } else if (curZoneEqNum > 0 && allocated(state.dataSize->FinalZoneSizing)) {
    1650          107 :         auto const &finalZoneSizing = state.dataSize->FinalZoneSizing(curZoneEqNum);
    1651          107 :         c->zoneNum.resize(1);
    1652          107 :         c->zoneName.resize(1);
    1653          107 :         c->zoneNum[0] = curZoneEqNum;
    1654          107 :         if (allocated(state.dataZoneEquip->ZoneEquipConfig)) {
    1655           78 :             c->zoneName[0] = state.dataZoneEquip->ZoneEquipConfig(curZoneEqNum).ZoneName;
    1656              :         }
    1657          107 :         c->desDayNameAtSensPeak = finalZoneSizing.HeatDesDay;
    1658          107 :         c->oaPeakTemp = finalZoneSizing.OutTempAtHeatPeak;
    1659          107 :         c->oaPeakHumRat = finalZoneSizing.OutHumRatAtHeatPeak;
    1660          107 :         c->raPeakTemp = finalZoneSizing.ZoneRetTempAtHeatPeak;
    1661          107 :         c->raPeakHumRat = finalZoneSizing.ZoneHumRatAtHeatPeak;
    1662          107 :         c->rmPeakTemp = finalZoneSizing.ZoneTempAtHeatPeak;
    1663          107 :         c->rmPeakHumRat = finalZoneSizing.ZoneHumRatAtHeatPeak;
    1664          214 :         c->rmPeakRelHum =
    1665          107 :             Psychrometrics::PsyRhFnTdbWPb(state, c->rmPeakTemp, c->rmPeakHumRat, state.dataEnvrn->StdBaroPress) * 100.0; // convert to percentage
    1666          107 :         if (finalZoneSizing.HeatDDNum > 0 && finalZoneSizing.HeatDDNum <= state.dataEnvrn->TotDesDays) {
    1667           30 :             c->coilSensePeakHrMin = PeakHrMinString(state, finalZoneSizing.HeatDDNum, finalZoneSizing.TimeStepNumAtHeatMax);
    1668           30 :             c->airPeakHrMin = PeakHrMinString(state, finalZoneSizing.HeatDDNum, finalZoneSizing.TimeStepNumAtHeatMax);
    1669              :         }
    1670          107 :         c->desDayNameAtAirFlowPeak = finalZoneSizing.HeatDesDay;
    1671              : 
    1672          107 :         c->rmSensibleAtPeak = finalZoneSizing.DesHeatLoad;
    1673              : 
    1674          107 :         auto const &zoneEqSizing = state.dataSize->ZoneEqSizing(curZoneEqNum);
    1675          107 :         if (zoneEqSizing.OAVolFlow > 0.0) {
    1676           14 :             c->oaPeakVolFlow = zoneEqSizing.OAVolFlow;
    1677           93 :         } else if (zoneEqSizing.ATMixerVolFlow > 0.0) {
    1678            4 :             c->oaPeakVolFlow = zoneEqSizing.ATMixerVolFlow;
    1679              :         } else {
    1680           89 :             c->oaPeakVolFlow = 0.0;
    1681              :         }
    1682              :         // coil entering conditions depend on the type of zone equipment involved
    1683              :         // set typeof_Coil integer
    1684          107 :         if (state.dataSize->TermUnitIU) {      // an unpowered induction terminal unit
    1685            2 :             if (c->coilDesEntTemp == -999.0) { // don't overwrite if already set directly by setCoilEntAirTemp
    1686            0 :                 auto const &thisTermUnitFinalZoneSizing = state.dataSize->TermUnitFinalZoneSizing(state.dataSize->CurTermUnitSizingNum);
    1687            0 :                 c->coilDesEntTemp = thisTermUnitFinalZoneSizing.DesHeatCoilInTempTU;
    1688            0 :                 c->coilDesEntHumRat = thisTermUnitFinalZoneSizing.DesHeatCoilInHumRatTU;
    1689              :             }
    1690          105 :         } else if (state.dataSize->TermUnitSingDuct) {
    1691           14 :             if (c->coilDesEntTemp == -999.0) { // don't overwrite if already set directly by setCoilEntAirTemp
    1692            3 :                 auto const &thisTermUnitFinalZoneSizing = state.dataSize->TermUnitFinalZoneSizing(state.dataSize->CurTermUnitSizingNum);
    1693            3 :                 c->coilDesEntTemp = thisTermUnitFinalZoneSizing.DesHeatCoilInTempTU;
    1694            3 :                 c->coilDesEntHumRat = thisTermUnitFinalZoneSizing.DesHeatCoilInHumRatTU;
    1695              :             }
    1696           91 :         } else if (state.dataSize->TermUnitPIU) {
    1697           13 :             auto const &thisTermUnitSizing = state.dataSize->TermUnitSizing(state.dataSize->CurTermUnitSizingNum);
    1698           13 :             Real64 MinPriFlowFrac = thisTermUnitSizing.MinPriFlowFrac;
    1699           13 :             if (thisTermUnitSizing.InducesPlenumAir) {
    1700            6 :                 if (c->coilDesEntTemp == -999.0) { // don't overwrite if already set directly by setCoilEntAirTemp
    1701            0 :                     auto const &termUnitFinalZoneSizing = state.dataSize->TermUnitFinalZoneSizing(state.dataSize->CurTermUnitSizingNum);
    1702            0 :                     c->coilDesEntTemp = (termUnitFinalZoneSizing.DesHeatCoilInTempTU * MinPriFlowFrac) +
    1703            0 :                                         (termUnitFinalZoneSizing.ZoneRetTempAtHeatPeak * (1.0 - MinPriFlowFrac));
    1704            0 :                     c->coilDesEntHumRat = (termUnitFinalZoneSizing.DesHeatCoilInHumRatTU * MinPriFlowFrac) +
    1705            0 :                                           (termUnitFinalZoneSizing.ZoneHumRatAtHeatPeak * (1.0 - MinPriFlowFrac));
    1706              :                 }
    1707              :             } else {
    1708            7 :                 if (c->coilDesEntTemp == -999.0) { // don't overwrite if already set directly by setCoilEntAirTemp
    1709            0 :                     auto const &thisTermUnitFinalZoneSizing = state.dataSize->TermUnitFinalZoneSizing(state.dataSize->CurTermUnitSizingNum);
    1710            0 :                     c->coilDesEntTemp = (thisTermUnitFinalZoneSizing.DesHeatCoilInTempTU * MinPriFlowFrac) +
    1711            0 :                                         (thisTermUnitFinalZoneSizing.ZoneTempAtHeatPeak * (1.0 - MinPriFlowFrac));
    1712            0 :                     c->coilDesEntHumRat = (thisTermUnitFinalZoneSizing.DesHeatCoilInHumRatTU * MinPriFlowFrac) +
    1713            0 :                                           (thisTermUnitFinalZoneSizing.ZoneHumRatAtHeatPeak * (1.0 - MinPriFlowFrac));
    1714              :                 }
    1715              :             }
    1716           78 :         } else if (state.dataSize->ZoneEqFanCoil) {
    1717           11 :             if (c->coilDesEntTemp == -999.0) { // don't overwrite if already set directly by setCoilEntAirTemp
    1718            1 :                 Real64 desOAFlowFrac = 0.0;
    1719            1 :                 if (zoneEqSizing.OAVolFlow > 0.0 && finalZoneSizing.DesHeatMassFlow > 0.0) {
    1720            1 :                     desOAFlowFrac = std::min(state.dataEnvrn->StdRhoAir * zoneEqSizing.OAVolFlow / finalZoneSizing.DesHeatMassFlow, 1.0);
    1721              :                 } else {
    1722            0 :                     desOAFlowFrac = finalZoneSizing.DesHeatOAFlowFrac;
    1723              :                 }
    1724            1 :                 c->coilDesEntTemp = desOAFlowFrac * finalZoneSizing.OutTempAtHeatPeak + (1.0 - desOAFlowFrac) * finalZoneSizing.ZoneTempAtHeatPeak;
    1725            1 :                 c->coilDesEntHumRat =
    1726            1 :                     desOAFlowFrac * finalZoneSizing.OutHumRatAtHeatPeak + (1.0 - desOAFlowFrac) * finalZoneSizing.ZoneHumRatAtHeatPeak;
    1727              :             }
    1728           67 :         } else if (state.dataSize->ZoneEqDXCoil) {
    1729           24 :             if (zoneEqSizing.OAVolFlow > 0.0) {
    1730            5 :                 if (c->coilDesEntTemp == -999.0) { // don't overwrite if already set directly by setCoilEntAirTemp
    1731            3 :                     c->coilDesEntTemp = finalZoneSizing.DesHeatCoilInTemp;
    1732              :                 }
    1733            5 :                 if (c->coilDesEntHumRat == -999.0) { // don't overwrite if already set directly by setCoilEntAirHumRat
    1734            3 :                     c->coilDesEntHumRat = finalZoneSizing.DesHeatCoilInHumRat;
    1735              :                 }
    1736              :             } else {
    1737           19 :                 if (c->coilDesEntTemp == -999.0) { // don't overwrite if already set directly by setCoilEntAirTemp
    1738           18 :                     c->coilDesEntTemp = finalZoneSizing.ZoneTempAtHeatPeak;
    1739              :                 }
    1740           19 :                 if (c->coilDesEntHumRat == -999.0) { // don't overwrite if already set directly by setCoilEntAirHumRat
    1741           18 :                     c->coilDesEntHumRat = finalZoneSizing.ZoneHumRatAtHeatPeak;
    1742              :                 }
    1743              :             }
    1744              :         } else {
    1745           43 :             if (c->coilDesEntTemp == -999.0) { // don't overwrite if already set directly by setCoilEntAirTemp
    1746           22 :                 c->coilDesEntTemp = finalZoneSizing.DesHeatCoilInTemp;
    1747              :             }
    1748           43 :             if (c->coilDesEntHumRat == -999.0) { // don't overwrite if already set directly by setCoilEntAirHumRat
    1749           22 :                 c->coilDesEntHumRat = finalZoneSizing.DesHeatCoilInHumRat;
    1750              :             }
    1751              :         }
    1752              : 
    1753          107 :         if (c->coilDesEntTemp > -999.0 && c->coilDesEntHumRat > -999.0) {
    1754          188 :             c->coilDesEntWetBulb = Psychrometrics::PsyTwbFnTdbWPb(
    1755           94 :                 state, c->coilDesEntTemp, c->coilDesEntHumRat, state.dataEnvrn->StdBaroPress, "ReportCoilSelection::setCoilHeatingCapacity");
    1756           94 :             c->coilDesEntEnth = Psychrometrics::PsyHFnTdbW(c->coilDesEntTemp, c->coilDesEntHumRat);
    1757              :         }
    1758              : 
    1759          107 :         if (c->coilDesLvgTemp == -999.0) { // don't overwrite if already set directly by setCoilLvgAirTemp
    1760           62 :             c->coilDesLvgTemp = finalZoneSizing.HeatDesTemp;
    1761              :         }
    1762          107 :         if (c->coilDesLvgHumRat == -999.0) { // don't overwrite if already set directly by setCoilLvgAirHumRat
    1763           62 :             c->coilDesLvgHumRat = finalZoneSizing.HeatDesHumRat;
    1764              :         }
    1765          214 :         c->coilDesLvgWetBulb = Psychrometrics::PsyTwbFnTdbWPb(
    1766          107 :             state, c->coilDesLvgTemp, c->coilDesLvgHumRat, state.dataEnvrn->StdBaroPress, "ReportCoilSelection::setCoilHeatingCapacity");
    1767          107 :         c->coilDesLvgEnth = Psychrometrics::PsyHFnTdbW(c->coilDesLvgTemp, c->coilDesLvgHumRat);
    1768           58 :     } else if (curOASysNum > 0 && c->airloopNum > int(state.dataSize->FinalSysSizing.size())) {
    1769            2 :         if (!state.dataAirLoopHVACDOAS->airloopDOAS.empty()) {
    1770            2 :             c->oASysNum = curOASysNum; // where should this get set? It's -999 here.
    1771            2 :             int DOASSysNum = state.dataAirLoop->OutsideAirSys(curOASysNum).AirLoopDOASNum;
    1772            2 :             c->coilDesEntTemp = state.dataAirLoopHVACDOAS->airloopDOAS[DOASSysNum].HeatOutTemp;
    1773            2 :             c->coilDesEntHumRat = state.dataAirLoopHVACDOAS->airloopDOAS[DOASSysNum].HeatOutHumRat;
    1774            2 :             if (c->coilDesEntTemp > -999.0 && c->coilDesEntHumRat > -999.0) {
    1775            4 :                 c->coilDesEntWetBulb = Psychrometrics::PsyTwbFnTdbWPb(
    1776            2 :                     state, c->coilDesEntTemp, c->coilDesEntHumRat, state.dataEnvrn->StdBaroPress, "ReportCoilSelection::setCoilHeatingCapacity");
    1777            2 :                 c->coilDesEntEnth = Psychrometrics::PsyHFnTdbW(c->coilDesEntTemp, c->coilDesEntHumRat);
    1778              :             }
    1779            2 :             c->coilDesLvgTemp = state.dataAirLoopHVACDOAS->airloopDOAS[DOASSysNum].PreheatTemp;
    1780            2 :             c->coilDesLvgHumRat = state.dataAirLoopHVACDOAS->airloopDOAS[DOASSysNum].PreheatHumRat;
    1781            2 :             if (c->coilDesLvgTemp > -999.0 && c->coilDesLvgHumRat > -999.0) {
    1782            4 :                 c->coilDesLvgWetBulb = Psychrometrics::PsyTwbFnTdbWPb(
    1783            2 :                     state, c->coilDesLvgTemp, c->coilDesLvgHumRat, state.dataEnvrn->StdBaroPress, "ReportCoilSelection::setCoilHeatingCapacity");
    1784            2 :                 c->coilDesLvgEnth = Psychrometrics::PsyHFnTdbW(c->coilDesLvgTemp, c->coilDesLvgHumRat);
    1785              :             }
    1786            2 :             DataSizing::SizingConcurrence sizMethod = DataSizing::SizingConcurrence::Invalid;
    1787            2 :             bool sizMethodsAreTheSame = true;
    1788            4 :             for (int airLoopNum = 0; airLoopNum < state.dataAirLoopHVACDOAS->airloopDOAS[DOASSysNum].NumOfAirLoops; ++airLoopNum) {
    1789            2 :                 int actualAirLoopNum = state.dataAirLoopHVACDOAS->airloopDOAS[DOASSysNum].m_AirLoopNum[airLoopNum];
    1790            2 :                 if (airLoopNum == 0) {
    1791            2 :                     sizMethod = state.dataSize->FinalSysSizing(actualAirLoopNum).SizingOption;
    1792              :                 } else {
    1793            0 :                     if (sizMethod != state.dataSize->FinalSysSizing(actualAirLoopNum).SizingOption) {
    1794            0 :                         sizMethodsAreTheSame = false;
    1795              :                     }
    1796              :                 }
    1797              :             }
    1798            2 :             if (sizMethodsAreTheSame) {
    1799            2 :                 c->coilSizingMethodConcurrence = static_cast<DataSizing::CoilSizingConcurrence>(sizMethod);
    1800              :             } else {
    1801            0 :                 c->coilSizingMethodConcurrence = DataSizing::CoilSizingConcurrence::Combination;
    1802              :             }
    1803              :         }
    1804              :     } else {
    1805              :         // do nothing
    1806              :     }
    1807              : 
    1808          264 :     if (state.dataSize->DataCoilIsSuppHeater) {
    1809           15 :         c->isSupplementalHeater = true;
    1810              :     }
    1811              :     // some heating coils only use this routine, so set air flow if not yet set
    1812          264 :     if (c->coilDesVolFlow <= 0.0) {
    1813          110 :         if (state.dataSize->DataFlowUsedForSizing > 0.0) { // flow has been set in global, so use it
    1814           21 :             c->coilDesVolFlow = state.dataSize->DataFlowUsedForSizing;
    1815           89 :         } else if (curZoneEqNum > 0 && allocated(state.dataSize->FinalZoneSizing)) {
    1816           36 :             auto const &finalZoneSizing = state.dataSize->FinalZoneSizing(curZoneEqNum);
    1817           36 :             if (finalZoneSizing.DesHeatMassFlow >= HVAC::SmallMassFlow) {
    1818           25 :                 c->coilDesMassFlow = finalZoneSizing.DesHeatMassFlow;
    1819           25 :                 c->coilDesVolFlow = c->coilDesMassFlow / state.dataEnvrn->StdRhoAir;
    1820              :             }
    1821           53 :         } else if (curSysNum > 0 && curSysNum <= int(state.dataSize->FinalSysSizing.size())) {
    1822            5 :             auto const &finalSysSizing = state.dataSize->FinalSysSizing(curSysNum);
    1823            5 :             if (curOASysNum > 0 && allocated(state.dataSize->OASysEqSizing)) {
    1824            0 :                 auto const &oASysEqSizing = state.dataSize->OASysEqSizing(curSysNum);
    1825            0 :                 if (oASysEqSizing.AirFlow) {
    1826            0 :                     c->coilDesVolFlow = oASysEqSizing.AirVolFlow;
    1827            0 :                 } else if (oASysEqSizing.HeatingAirFlow) {
    1828            0 :                     c->coilDesVolFlow = oASysEqSizing.HeatingAirVolFlow;
    1829              :                 } else {
    1830            0 :                     c->coilDesVolFlow = finalSysSizing.DesOutAirVolFlow;
    1831              :                 }
    1832              :             } else {
    1833            5 :                 if (state.dataSize->DataFlowUsedForSizing > 0.0) {
    1834            0 :                     c->coilDesVolFlow = state.dataSize->DataFlowUsedForSizing;
    1835            5 :                 } else if (curSysNum > 0 && allocated(state.dataSize->UnitarySysEqSizing)) {
    1836            5 :                     auto const &unitarySysEqSizing = state.dataSize->UnitarySysEqSizing(curSysNum);
    1837            5 :                     if (unitarySysEqSizing.AirFlow) {
    1838            0 :                         c->coilDesVolFlow = unitarySysEqSizing.AirVolFlow;
    1839            5 :                     } else if (unitarySysEqSizing.HeatingAirFlow) {
    1840            0 :                         c->coilDesVolFlow = unitarySysEqSizing.HeatingAirVolFlow;
    1841              :                     }
    1842              :                 } else {
    1843            0 :                     if (state.dataSize->CurDuctType == HVAC::AirDuctType::Main) {
    1844            0 :                         if (finalSysSizing.SysAirMinFlowRat > 0.0 && !state.dataSize->DataDesicRegCoil) {
    1845            0 :                             c->coilDesVolFlow = finalSysSizing.SysAirMinFlowRat * finalSysSizing.DesMainVolFlow;
    1846              :                         } else {
    1847            0 :                             c->coilDesVolFlow = finalSysSizing.DesMainVolFlow;
    1848              :                         }
    1849            0 :                     } else if (state.dataSize->CurDuctType == HVAC::AirDuctType::Cooling) {
    1850            0 :                         if (finalSysSizing.SysAirMinFlowRat > 0.0 && !state.dataSize->DataDesicRegCoil) {
    1851            0 :                             c->coilDesVolFlow = finalSysSizing.SysAirMinFlowRat * finalSysSizing.DesCoolVolFlow;
    1852              :                         } else {
    1853            0 :                             c->coilDesVolFlow = finalSysSizing.DesCoolVolFlow;
    1854              :                         }
    1855            0 :                     } else if (state.dataSize->CurDuctType == HVAC::AirDuctType::Heating) {
    1856            0 :                         c->coilDesVolFlow = finalSysSizing.DesHeatVolFlow;
    1857            0 :                     } else if (state.dataSize->CurDuctType == HVAC::AirDuctType::Other) {
    1858            0 :                         c->coilDesVolFlow = finalSysSizing.DesMainVolFlow;
    1859              :                     } else {
    1860            0 :                         c->coilDesVolFlow = finalSysSizing.DesMainVolFlow;
    1861              :                     }
    1862              :                 }
    1863              :             }
    1864              :         }
    1865          110 :         c->coilDesMassFlow = c->coilDesVolFlow * state.dataEnvrn->StdRhoAir;
    1866              :     }
    1867              : 
    1868              :     // calc sensible capacity from inlet outlet
    1869          264 :     c->cpMoistAir = Psychrometrics::PsyCpAirFnW(c->coilDesLvgHumRat);
    1870              :     // this is not generally correct but okay for heating coils
    1871          264 :     c->coilSensCapAtPeak = std::abs(c->cpMoistAir * c->coilDesMassFlow * (c->coilDesLvgTemp - c->coilDesEntTemp));
    1872          264 :     c->coilSensCapAtPeak = min(c->coilSensCapAtPeak, c->coilTotCapAtPeak);
    1873          264 : }
    1874              : 
    1875           19 : void ReportCoilSelection::setCoilWaterCoolingCapacity(EnergyPlusData &state,
    1876              :                                                       std::string const &coilName,  // user-defined name of the coil
    1877              :                                                       std::string const &coilType,  // idf input object class name of coil
    1878              :                                                       Real64 const totalCoolingCap, // {W} coil cooling capacity
    1879              :                                                       bool const isAutoSize,        // true if value was autosized
    1880              :                                                       int const inletNodeNum,       // coil chw inlet node num
    1881              :                                                       int const outletNodeNum,      // coil chw outlet node num
    1882              :                                                       int const dataWaterLoopNum    // plant loop structure index
    1883              : )
    1884              : {
    1885           19 :     int index = getIndexForOrCreateDataObjFromCoilName(state, coilName, coilType);
    1886           19 :     auto &c(coilSelectionDataObjs[index]);
    1887           19 :     c->coilTotCapAtPeak = totalCoolingCap;
    1888           19 :     c->capIsAutosized = isAutoSize;
    1889           19 :     if ((state.dataSize->NumPltSizInput > 0) && (inletNodeNum > 0) && (outletNodeNum > 0)) {
    1890           16 :         bool errorsfound = false;
    1891           16 :         c->pltSizNum = PlantUtilities::MyPlantSizingIndex(state, "chilled water coil", coilName, inletNodeNum, outletNodeNum, errorsfound);
    1892              :     } else {
    1893            3 :         c->pltSizNum = -999;
    1894              :     }
    1895           19 :     c->waterLoopNum = dataWaterLoopNum;
    1896           19 : }
    1897              : 
    1898           22 : void ReportCoilSelection::setCoilWaterHeaterCapacityNodeNums(EnergyPlusData &state,
    1899              :                                                              std::string const &coilName,  // user-defined name of the coil
    1900              :                                                              std::string const &coilType,  // idf input object class name of coil
    1901              :                                                              Real64 const totalHeatingCap, // {W} coil Heating capacity
    1902              :                                                              bool const isAutoSize,        // true if value was autosized
    1903              :                                                              int const inletNodeNum,       // coil chw inlet node num
    1904              :                                                              int const outletNodeNum,      // coil chw outlet node num
    1905              :                                                              int const dataWaterLoopNum    // plant loop structure index
    1906              : )
    1907              : {
    1908           22 :     int index = getIndexForOrCreateDataObjFromCoilName(state, coilName, coilType);
    1909           22 :     auto &c(coilSelectionDataObjs[index]);
    1910           22 :     c->coilTotCapAtPeak = totalHeatingCap;
    1911           22 :     c->capIsAutosized = isAutoSize;
    1912           22 :     if ((state.dataSize->NumPltSizInput > 0) && (inletNodeNum > 0) && (outletNodeNum > 0)) {
    1913           19 :         bool errorsfound = false;
    1914           19 :         c->pltSizNum = PlantUtilities::MyPlantSizingIndex(state, "hot water coil", coilName, inletNodeNum, outletNodeNum, errorsfound);
    1915              :     } else {
    1916            3 :         c->pltSizNum = -999;
    1917              :     }
    1918           22 :     c->waterLoopNum = dataWaterLoopNum;
    1919           22 : }
    1920              : 
    1921           30 : void ReportCoilSelection::setCoilWaterHeaterCapacityPltSizNum(EnergyPlusData &state,
    1922              :                                                               std::string const &coilName,  // user-defined name of the coil
    1923              :                                                               std::string const &coilType,  // idf input object class name of coil
    1924              :                                                               Real64 const totalHeatingCap, // {W} coil Heating capacity
    1925              :                                                               bool const isAutoSize,        // true if value was autosized
    1926              :                                                               int const dataPltSizNum,      // plant sizing structure index
    1927              :                                                               int const dataWaterLoopNum    // plant loop structure index
    1928              : )
    1929              : {
    1930           30 :     int index = getIndexForOrCreateDataObjFromCoilName(state, coilName, coilType);
    1931           30 :     auto &c(coilSelectionDataObjs[index]);
    1932           30 :     c->coilTotCapAtPeak = totalHeatingCap;
    1933           30 :     c->capIsAutosized = isAutoSize;
    1934           30 :     c->pltSizNum = dataPltSizNum;
    1935           30 :     c->waterLoopNum = dataWaterLoopNum;
    1936           30 : }
    1937              : 
    1938           41 : void ReportCoilSelection::setCoilUA(EnergyPlusData &state,
    1939              :                                     std::string const &coilName,            // user-defined name of the coil
    1940              :                                     std::string const &coilType,            // idf input object class name of coil
    1941              :                                     Real64 const UAvalue,                   // [W/k] UA value for coil,
    1942              :                                     Real64 const dataCapacityUsedForSizing, // [W] sizing global
    1943              :                                     bool const isAutoSize,                  // true if value was autosized
    1944              :                                     int const curSysNum,                    // airloop system number index, if non zero
    1945              :                                     int const curZoneEqNum                  // zone equipment list index, if non-zero
    1946              : )
    1947              : {
    1948           41 :     int index = getIndexForOrCreateDataObjFromCoilName(state, coilName, coilType);
    1949           41 :     auto &c(coilSelectionDataObjs[index]);
    1950           41 :     c->coilUA = UAvalue;
    1951           41 :     c->coilTotCapAtPeak = dataCapacityUsedForSizing;
    1952           41 :     c->capIsAutosized = isAutoSize;
    1953           41 :     c->airloopNum = curSysNum;
    1954           41 :     doAirLoopSetup(state, index);
    1955           41 :     c->zoneEqNum = curZoneEqNum;
    1956           41 : }
    1957              : 
    1958           60 : void ReportCoilSelection::setCoilReheatMultiplier(EnergyPlusData &state,
    1959              :                                                   std::string const &coilName, // user-defined name of the coil
    1960              :                                                   std::string const &coilType, // idf input object class name of coil
    1961              :                                                   Real64 const multiplierReheatLoad)
    1962              : {
    1963           60 :     int index = getIndexForOrCreateDataObjFromCoilName(state, coilName, coilType);
    1964           60 :     auto &c(coilSelectionDataObjs[index]);
    1965           60 :     c->reheatLoadMult = multiplierReheatLoad;
    1966           60 : }
    1967              : 
    1968          449 : void ReportCoilSelection::setCoilSupplyFanInfo(EnergyPlusData &state,
    1969              :                                                std::string const &coilName, // user-defined name of the coil
    1970              :                                                std::string const &coilType, // idf input object class name of coil
    1971              :                                                std::string const &fanName,
    1972              :                                                HVAC::FanType fanType,
    1973              :                                                int fanIndex)
    1974              : {
    1975          449 :     if (fanName.empty()) {
    1976           60 :         return;
    1977              :     }
    1978          389 :     int index = getIndexForOrCreateDataObjFromCoilName(state, coilName, coilType);
    1979          389 :     auto &c(coilSelectionDataObjs[index]);
    1980          389 :     c->fanAssociatedWithCoilName = fanName;
    1981          389 :     c->supFanType = fanType;
    1982          389 :     c->supFanNum = fanIndex;
    1983          389 :     if (c->supFanNum == 0) {
    1984            0 :         c->supFanNum = Fans::GetFanIndex(state, fanName);
    1985              :     }
    1986              : }
    1987              : 
    1988           40 : void ReportCoilSelection::setCoilEqNum(EnergyPlusData &state,
    1989              :                                        std::string const &coilName,
    1990              :                                        std::string const &coilType,
    1991              :                                        int const curSysNum,
    1992              :                                        int const curOASysNum,
    1993              :                                        int const curZoneEqNum)
    1994              : {
    1995           40 :     int index = getIndexForOrCreateDataObjFromCoilName(state, coilName, coilType);
    1996           40 :     auto &c(coilSelectionDataObjs[index]);
    1997           40 :     c->airloopNum = curSysNum;
    1998           40 :     c->oASysNum = curOASysNum;
    1999           40 :     c->zoneEqNum = curZoneEqNum;
    2000           40 : }
    2001              : 
    2002          361 : std::string ReportCoilSelection::getTimeText(EnergyPlusData &state, int const timeStepAtPeak)
    2003              : {
    2004          361 :     std::string returnString = "";
    2005              : 
    2006          361 :     if (timeStepAtPeak == 0) {
    2007            2 :         return returnString;
    2008              :     }
    2009              : 
    2010              :     // Scan timesteps of 24-hr day to match up correct hour and minute
    2011          359 :     int minutes(0);
    2012          359 :     int timeStepIndex(0);
    2013              :     int hourPrint;
    2014         8975 :     for (int hourCounter = 1; hourCounter <= 24; ++hourCounter) {
    2015        46584 :         for (int timeStepCounter = 1; timeStepCounter <= state.dataGlobal->TimeStepsInHour; ++timeStepCounter) {
    2016        37968 :             ++timeStepIndex;
    2017        37968 :             minutes += state.dataGlobal->MinutesInTimeStep;
    2018        37968 :             if (minutes == 60) {
    2019         8616 :                 minutes = 0;
    2020         8616 :                 hourPrint = hourCounter;
    2021              :             } else {
    2022        29352 :                 hourPrint = hourCounter - 1;
    2023              :             }
    2024        37968 :             if (timeStepIndex == timeStepAtPeak) {
    2025          359 :                 returnString = format(DataSizing::PeakHrMinFmt, hourPrint, minutes);
    2026              :             }
    2027              :         }
    2028              :     }
    2029              : 
    2030          359 :     return returnString;
    2031            0 : }
    2032              : 
    2033          158 : bool ReportCoilSelection::isCompTypeFan(std::string const &compType // string component type, input object class name
    2034              : )
    2035              : {
    2036              :     // if compType name is one of the fan objects, then return true
    2037          158 :     if (Util::SameString(compType, "Fan:SystemModel")) {
    2038           50 :         return true;
    2039          108 :     } else if (Util::SameString(compType, "Fan:ComponentModel")) {
    2040            0 :         return true;
    2041          108 :     } else if (Util::SameString(compType, "Fan:OnOff")) {
    2042           71 :         return true;
    2043           37 :     } else if (Util::SameString(compType, "Fan:ConstantVolume")) {
    2044           17 :         return true;
    2045           20 :     } else if (Util::SameString(compType, "Fan:VariableVolume")) {
    2046           20 :         return true;
    2047              :     } else {
    2048            0 :         return false;
    2049              :     }
    2050              : }
    2051              : 
    2052            7 : bool ReportCoilSelection::isCompTypeCoil(std::string const &compType // string component type, input object class name
    2053              : )
    2054              : {
    2055              :     // if compType name is one of the coil objects, then return true
    2056            7 :     bool found(false);
    2057          125 :     for (int loop = 1; loop <= HVAC::NumAllCoilTypes; ++loop) {
    2058          124 :         if (Util::SameString(compType, HVAC::cAllCoilTypes(loop))) {
    2059            6 :             found = true;
    2060            6 :             break;
    2061              :         }
    2062              :     }
    2063            7 :     return found;
    2064              : }
    2065              : 
    2066           12 : void ReportCoilSelection::setZoneLatentLoadCoolingIdealPeak(int const zoneIndex, Real64 const zoneCoolingLatentLoad)
    2067              : {
    2068              :     // loop over all the coils and the zones in the coils and if this zone index is in the coil
    2069           29 :     for (auto const &c : coilSelectionDataObjs) {
    2070              : 
    2071           17 :         if (c->isCooling) {
    2072           16 :             for (std::size_t zoneInd = 0; zoneInd < c->zoneNum.size(); ++zoneInd) {
    2073           11 :                 if (zoneIndex == c->zoneNum[zoneInd]) {
    2074            7 :                     c->rmLatentAtPeak += zoneCoolingLatentLoad;
    2075            7 :                     break;
    2076              :                 }
    2077              :             }
    2078              :         }
    2079           12 :     }
    2080           12 : }
    2081              : 
    2082           12 : void ReportCoilSelection::setZoneLatentLoadHeatingIdealPeak(int const zoneIndex, Real64 const zoneHeatingLatentLoad)
    2083              : {
    2084              :     // loop over all the coils and the zones in the coils and if this zone index is in the coil
    2085           32 :     for (auto const &c : coilSelectionDataObjs) {
    2086              : 
    2087           20 :         if (c->isHeating) {
    2088           13 :             for (std::size_t zoneInd = 0; zoneInd < c->zoneNum.size(); ++zoneInd) {
    2089           11 :                 if (zoneIndex == c->zoneNum[zoneInd]) {
    2090            7 :                     c->rmLatentAtPeak += zoneHeatingLatentLoad;
    2091            7 :                     break;
    2092              :                 }
    2093              :             }
    2094              :         }
    2095           12 :     }
    2096           12 : }
    2097              : 
    2098              : } // namespace EnergyPlus
        

Generated by: LCOV version 2.0-1