LCOV - code coverage report
Current view: top level - EnergyPlus - ReportCoilSelection.cc (source / functions) Coverage Total Hit
Test: lcov.output.filtered Lines: 89.2 % 1283 1144
Test Date: 2025-06-02 07:23:51 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          801 : void createCoilSelectionReportObj(EnergyPlusData &state)
      77              : {
      78          801 :     state.dataRptCoilSelection->coilSelectionReportObj = std::make_unique<ReportCoilSelection>();
      79          801 : }
      80              : 
      81         6779 : CoilSelectionData::CoilSelectionData( // constructor
      82         6779 :     std::string const &coilName)
      83        20337 :     : isCooling(false), isHeating(false), coilNum(-999), airloopNum(-999), oaControllerNum(-999), zoneEqNum(-999), oASysNum(-999), zoneHVACTypeNum(0),
      84        27116 :       zoneHVACIndex(0), typeof_Coil(-999), coilSizingMethodCapacity(-999), coilSizingMethodAirFlow(-999), isCoilSizingForTotalLoad(false),
      85        33895 :       capIsAutosized(false), volFlowIsAutosized(false), coilWaterFlowUser(-999.0), oaPretreated(false), isSupplementalHeater(false),
      86         6779 :       coilTotCapFinal(-999.0), coilSensCapFinal(-999.0), coilRefAirVolFlowFinal(-999.0), coilRefWaterVolFlowFinal(-999.0), coilTotCapAtPeak(-999.0),
      87         6779 :       coilSensCapAtPeak(-999.0), coilDesMassFlow(-999.0), coilDesVolFlow(-999.0), coilDesEntTemp(-999.0), coilDesEntWetBulb(-999.0),
      88         6779 :       coilDesEntHumRat(-999.0), coilDesEntEnth(-999.0), coilDesLvgTemp(-999.0), coilDesLvgWetBulb(-999.0), coilDesLvgHumRat(-999.0),
      89         6779 :       coilDesLvgEnth(-999.0), coilDesWaterMassFlow(-999.0), coilDesWaterEntTemp(-999.0), coilDesWaterLvgTemp(-999.0), coilDesWaterTempDiff(-999.0),
      90        13558 :       pltSizNum(-999), waterLoopNum(-999), oaPeakTemp(-999.00), oaPeakHumRat(-999.0), oaPeakWetBulb(-999.0), oaPeakVolFlow(-999.0),
      91         6779 :       oaPeakVolFrac(-999.0), oaDoaTemp(-999.0), oaDoaHumRat(-999.0), raPeakTemp(-999.0), raPeakHumRat(-999.0), rmPeakTemp(-999.0),
      92         6779 :       rmPeakHumRat(-999.0), rmPeakRelHum(-999.0), rmSensibleAtPeak(-999.0), rmLatentAtPeak(0.0), coilIdealSizCapOverSimPeakCap(-999.0),
      93         6779 :       coilIdealSizCapUnderSimPeakCap(-999.0), reheatLoadMult(-999.0), minRatio(-999.0), maxRatio(-999.0), cpMoistAir(-999.0), cpDryAir(-999.0),
      94         6779 :       rhoStandAir(-999.0), rhoFluid(-999.0), cpFluid(-999.0), coilCapFTIdealPeak(1.0), coilRatedTotCap(-999.0), coilRatedSensCap(-999.0),
      95         6779 :       ratedAirMassFlow(-999.0), ratedCoilInDb(-999.0), ratedCoilInWb(-999.0), ratedCoilInHumRat(-999.0), ratedCoilInEnth(-999.0),
      96         6779 :       ratedCoilOutDb(-999.0), ratedCoilOutWb(-999.0), ratedCoilOutHumRat(-999.0), ratedCoilOutEnth(-999.0), ratedCoilEff(-999.0),
      97         6779 :       ratedCoilBpFactor(-999.0), ratedCoilAppDewPt(-999.0), ratedCoilOadbRef(-999.0), ratedCoilOawbRef(-999.0),
      98              : 
      99         6779 :       supFanType(HVAC::FanType::Invalid), supFanNum(0), fanSizeMaxAirVolumeFlow(-999.0), fanSizeMaxAirMassFlow(-999.0), fanHeatGainIdealPeak(-999.0),
     100         6779 :       coilAndFanNetTotalCapacityIdealPeak(-999.0), plantDesMaxMassFlowRate(-999.0), plantDesRetTemp(-999.0), plantDesSupTemp(-999.0),
     101         6779 :       plantDesDeltaTemp(-999.0), plantDesCapacity(-999.0), coilCapPrcntPlantCap(-999.0), coilFlowPrcntPlantFlow(-999.0), coilUA(-999.0)
     102              : {
     103         6779 :     coilName_ = coilName;
     104         6779 :     coilLocation = "unknown";
     105         6779 :     desDayNameAtSensPeak = "unknown";
     106         6779 :     coilSensePeakHrMin = "unknown";
     107         6779 :     desDayNameAtTotalPeak = "unknown";
     108         6779 :     coilTotalPeakHrMin = "unknown";
     109         6779 :     desDayNameAtAirFlowPeak = "unknown";
     110         6779 :     airPeakHrMin = "unknown";
     111         6779 :     typeHVACname = "unknown";
     112         6779 :     userNameforHVACsystem = "unknown";
     113         6779 :     coilSizingMethodConcurrenceName = "N/A";
     114         6779 :     coilSizingMethodCapacityName = "N/A";
     115         6779 :     coilSizingMethodAirFlowName = "N/A";
     116         6779 :     coilPeakLoadTypeToSizeOnName = "N/A";
     117         6779 :     coilCapAutoMsg = "unknown";
     118         6779 :     coilVolFlowAutoMsg = "unknown";
     119         6779 :     coilWaterFlowAutoMsg = "unknown";
     120         6779 :     coilOAPretreatMsg = "unknown";
     121         6779 :     plantLoopName = "unknown";
     122         6779 :     fanAssociatedWithCoilName = "unknown";
     123         6779 :     fanTypeName = "unknown";
     124         6779 : }
     125              : 
     126          759 : void ReportCoilSelection::finishCoilSummaryReportTable(EnergyPlusData &state)
     127              : {
     128          759 :     doFinalProcessingOfCoilData(state);
     129          759 :     writeCoilSelectionOutput(state);
     130          759 :     writeCoilSelectionOutput2(state);
     131          759 : }
     132              : 
     133          759 : void ReportCoilSelection::writeCoilSelectionOutput(EnergyPlusData &state)
     134              : {
     135              : 
     136              :     // make calls to fill out predefined tabular report entries for each coil selection report object
     137         7397 :     for (auto &c : coilSelectionDataObjs) {
     138              : 
     139         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilType, c->coilName_, c->coilObjName);
     140         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilLocation, c->coilName_, c->coilLocation);
     141         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilHVACType, c->coilName_, c->typeHVACname);
     142         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilHVACName, c->coilName_, c->userNameforHVACsystem);
     143              : 
     144              :         // begin std 229 existing heating coil table adding new variables
     145         6638 :         if (c->isHeating) {
     146        14157 :             OutputReportPredefined::PreDefTableEntry(
     147        14157 :                 state, state.dataOutRptPredefined->pdchHeatCoilUsedAsSupHeat, c->coilName_, c->isSupplementalHeater ? "Yes" : "No");
     148        14157 :             OutputReportPredefined::PreDefTableEntry(state,
     149         4719 :                                                      state.dataOutRptPredefined->pdchHeatCoilAirloopName,
     150         4719 :                                                      c->coilName_,
     151         1420 :                                                      c->airloopNum > 0 && c->airloopNum <= state.dataHVACGlobal->NumPrimaryAirSys
     152        14157 :                                                          ? state.dataAirSystemsData->PrimaryAirSystems(c->airloopNum).Name
     153              :                                                          : "N/A");
     154        14157 :             OutputReportPredefined::PreDefTableEntry(state,
     155         4719 :                                                      state.dataOutRptPredefined->pdchHeatCoilPlantloopName,
     156         4719 :                                                      c->coilName_,
     157        13498 :                                                      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         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilName_CCs, c->coilName_, c->coilName_);
     163         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilType_CCs, c->coilName_, c->coilObjName);
     164         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilLoc_CCs, c->coilName_, c->coilLocation);
     165         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilHVACType_CCs, c->coilName_, c->typeHVACname);
     166         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilHVACName_CCs, c->coilName_, c->userNameforHVACsystem);
     167              :         // end of std 229 New coil connections table entries
     168              : 
     169         6638 :         if (c->zoneName.size() == 1) {
     170         5320 :             OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilZoneName, c->coilName_, c->zoneName[0]);
     171              :             // begin std 229 New coil connections table entries
     172         5320 :             OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilZoneNames_CCs, c->coilName_, c->zoneName[0]);
     173              :             // end of std 229 New coil connections table entries
     174         1318 :         } else if (c->zoneName.size() > 1) {
     175              :             // make list of zone names
     176         1084 :             std::string tmpZoneList;
     177         8670 :             for (std::size_t vecLoop = 0; vecLoop < c->zoneName.size(); ++vecLoop) {
     178         7586 :                 tmpZoneList += c->zoneName[vecLoop] + "; ";
     179              :             }
     180         1084 :             OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilZoneName, c->coilName_, tmpZoneList);
     181              :             // begin std 229 New coil connections table entries
     182         1084 :             OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilZoneNames_CCs, c->coilName_, tmpZoneList);
     183              :             // end of std 229 New coil connections table entries
     184         1084 :         } else {
     185          234 :             OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilZoneName, c->coilName_, "N/A");
     186              :             // begin std 229 New coil connections table entries
     187          234 :             OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilZoneNames_CCs, c->coilName_, "N/A");
     188              :             // end of std 229 New coil connections table entries
     189              :         }
     190              : 
     191        19914 :         OutputReportPredefined::PreDefTableEntry(
     192        19914 :             state, state.dataOutRptPredefined->pdchSysSizingMethCoinc, c->coilName_, c->coilSizingMethodConcurrenceName);
     193        19914 :         OutputReportPredefined::PreDefTableEntry(
     194        19914 :             state, state.dataOutRptPredefined->pdchSysSizingMethCap, c->coilName_, c->coilSizingMethodCapacityName);
     195        19914 :         OutputReportPredefined::PreDefTableEntry(
     196        19914 :             state, state.dataOutRptPredefined->pdchSysSizingMethAir, c->coilName_, c->coilSizingMethodAirFlowName);
     197         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilIsCapAutosized, c->coilName_, c->coilCapAutoMsg);
     198         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilIsAirFlowAutosized, c->coilName_, c->coilVolFlowAutoMsg);
     199        19914 :         OutputReportPredefined::PreDefTableEntry(
     200        19914 :             state, state.dataOutRptPredefined->pdchCoilIsWaterFlowAutosized, c->coilName_, c->coilWaterFlowAutoMsg);
     201         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilIsOATreated, c->coilName_, c->coilOAPretreatMsg);
     202         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilFinalTotalCap, c->coilName_, c->coilTotCapFinal, 3);
     203         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilFinalSensCap, c->coilName_, c->coilSensCapFinal, 3);
     204         6638 :         if (c->coilRefAirVolFlowFinal == -999.0 || c->coilRefAirVolFlowFinal == -99999.0) {
     205         3522 :             OutputReportPredefined::PreDefTableEntry(
     206         5283 :                 state, state.dataOutRptPredefined->pdchCoilFinalAirVolFlowRate, c->coilName_, c->coilRefAirVolFlowFinal, 1);
     207              :         } else {
     208         9754 :             OutputReportPredefined::PreDefTableEntry(
     209        14631 :                 state, state.dataOutRptPredefined->pdchCoilFinalAirVolFlowRate, c->coilName_, c->coilRefAirVolFlowFinal, 6);
     210              :         }
     211              : 
     212         6638 :         if (c->coilRefWaterVolFlowFinal == -999.0 || c->coilRefWaterVolFlowFinal == -99999.0) {
     213         5932 :             OutputReportPredefined::PreDefTableEntry(
     214         8898 :                 state, state.dataOutRptPredefined->pdchCoilFinalPlantVolFlowRate, c->coilName_, c->coilRefWaterVolFlowFinal, 1);
     215              :         } else {
     216         7344 :             OutputReportPredefined::PreDefTableEntry(
     217        11016 :                 state, state.dataOutRptPredefined->pdchCoilFinalPlantVolFlowRate, c->coilName_, c->coilRefWaterVolFlowFinal, 8);
     218              :         }
     219              : 
     220        19914 :         OutputReportPredefined::PreDefTableEntry(
     221        19914 :             state, state.dataOutRptPredefined->pdchFanAssociatedWithCoilName, c->coilName_, c->fanAssociatedWithCoilName);
     222              :         // begin std 229 New coil connections table entries
     223        19914 :         OutputReportPredefined::PreDefTableEntry(
     224        19914 :             state, state.dataOutRptPredefined->pdchCoilSupFanName_CCs, c->coilName_, c->fanAssociatedWithCoilName);
     225              :         // end of std 229 New coil connections table entries
     226              : 
     227         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchFanAssociatedWithCoilType, c->coilName_, c->fanTypeName);
     228              :         // begin std 229 New coil connections table entries
     229         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilSupFanType_CCs, c->coilName_, c->fanTypeName);
     230              :         // end of std 229 New coil connections table entries
     231              : 
     232         6638 :         if (c->fanSizeMaxAirVolumeFlow == -999.0 || c->fanSizeMaxAirVolumeFlow == -99999.0) {
     233         5672 :             OutputReportPredefined::PreDefTableEntry(
     234         8508 :                 state, state.dataOutRptPredefined->pdchFanAssociatedVdotSize, c->coilName_, c->fanSizeMaxAirVolumeFlow, 1);
     235              :         } else {
     236         7604 :             OutputReportPredefined::PreDefTableEntry(
     237        11406 :                 state, state.dataOutRptPredefined->pdchFanAssociatedVdotSize, c->coilName_, c->fanSizeMaxAirVolumeFlow, 6);
     238              :         }
     239         6638 :         if (c->fanSizeMaxAirMassFlow == -999.0 || c->fanSizeMaxAirMassFlow == -99999.0) {
     240         5672 :             OutputReportPredefined::PreDefTableEntry(
     241         8508 :                 state, state.dataOutRptPredefined->pdchFanAssociatedMdotSize, c->coilName_, c->fanSizeMaxAirMassFlow, 1);
     242              :         } else {
     243         7604 :             OutputReportPredefined::PreDefTableEntry(
     244        11406 :                 state, state.dataOutRptPredefined->pdchFanAssociatedMdotSize, c->coilName_, c->fanSizeMaxAirMassFlow, 8);
     245              :         }
     246              : 
     247              :         // begin std 229 New coil connections table entries
     248         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilPlantName_CCs, c->coilName_, c->plantLoopName);
     249        19914 :         OutputReportPredefined::PreDefTableEntry(state,
     250         6638 :                                                  state.dataOutRptPredefined->pdchCoilAirloopName_CCs,
     251         6638 :                                                  c->coilName_,
     252         2702 :                                                  c->airloopNum > 0 && c->airloopNum <= state.dataHVACGlobal->NumPrimaryAirSys
     253        19914 :                                                      ? state.dataAirSystemsData->PrimaryAirSystems(c->airloopNum).Name
     254              :                                                      : "N/A");
     255         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilPlantloopName_CCs, c->coilName_, c->plantLoopName);
     256              :         // end of std 229 New coil connections table entries
     257              : 
     258        19914 :         OutputReportPredefined::PreDefTableEntry(
     259        19914 :             state, state.dataOutRptPredefined->pdchCoilDDnameSensIdealPeak, c->coilName_, c->desDayNameAtSensPeak);
     260        19914 :         OutputReportPredefined::PreDefTableEntry(
     261        19914 :             state, state.dataOutRptPredefined->pdchCoilDateTimeSensIdealPeak, c->coilName_, c->coilSensePeakHrMin);
     262        19914 :         OutputReportPredefined::PreDefTableEntry(
     263        19914 :             state, state.dataOutRptPredefined->pdchCoilDDnameTotIdealPeak, c->coilName_, c->desDayNameAtTotalPeak);
     264        19914 :         OutputReportPredefined::PreDefTableEntry(
     265        19914 :             state, state.dataOutRptPredefined->pdchCoilDateTimeTotIdealPeak, c->coilName_, c->coilTotalPeakHrMin);
     266        19914 :         OutputReportPredefined::PreDefTableEntry(
     267        19914 :             state, state.dataOutRptPredefined->pdchCoilDDnameAirFlowIdealPeak, c->coilName_, c->desDayNameAtAirFlowPeak);
     268         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilDateTimeAirFlowIdealPeak, c->coilName_, c->airPeakHrMin);
     269              : 
     270        19914 :         OutputReportPredefined::PreDefTableEntry(
     271        19914 :             state, state.dataOutRptPredefined->pdchCoilPeakLoadTypeToSizeOn, c->coilName_, c->coilPeakLoadTypeToSizeOnName);
     272              : 
     273         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilTotalCapIdealPeak, c->coilName_, c->coilTotCapAtPeak, 2);
     274         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilSensCapIdealPeak, c->coilName_, c->coilSensCapAtPeak, 2);
     275         6638 :         if (c->coilDesMassFlow == -999.0 || c->coilDesMassFlow == -99999.0) {
     276          772 :             OutputReportPredefined::PreDefTableEntry(
     277         1158 :                 state, state.dataOutRptPredefined->pdchCoilAirMassFlowIdealPeak, c->coilName_, c->coilDesMassFlow, 1);
     278              :         } else {
     279        12504 :             OutputReportPredefined::PreDefTableEntry(
     280        18756 :                 state, state.dataOutRptPredefined->pdchCoilAirMassFlowIdealPeak, c->coilName_, c->coilDesMassFlow, 8);
     281              :         }
     282         6638 :         if (c->coilDesVolFlow == -999.0 || c->coilDesVolFlow == -99999.0) {
     283         1038 :             OutputReportPredefined::PreDefTableEntry(
     284         1557 :                 state, state.dataOutRptPredefined->pdchCoilAirVolumeFlowIdealPeak, c->coilName_, c->coilDesVolFlow, 1);
     285              :         } else {
     286        12238 :             OutputReportPredefined::PreDefTableEntry(
     287        18357 :                 state, state.dataOutRptPredefined->pdchCoilAirVolumeFlowIdealPeak, c->coilName_, c->coilDesVolFlow, 6);
     288              :         }
     289         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilEntDryBulbIdealPeak, c->coilName_, c->coilDesEntTemp, 2);
     290        13276 :         OutputReportPredefined::PreDefTableEntry(
     291        13276 :             state, state.dataOutRptPredefined->pdchCoilEntWetBulbIdealPeak, c->coilName_, c->coilDesEntWetBulb, 2);
     292         6638 :         if (c->coilDesEntHumRat == -999.0 || c->coilDesEntHumRat == -99999.0) {
     293         1964 :             OutputReportPredefined::PreDefTableEntry(
     294         2946 :                 state, state.dataOutRptPredefined->pdchCoilEntHumRatIdealPeak, c->coilName_, c->coilDesEntHumRat, 1);
     295              :         } else {
     296        11312 :             OutputReportPredefined::PreDefTableEntry(
     297        16968 :                 state, state.dataOutRptPredefined->pdchCoilEntHumRatIdealPeak, c->coilName_, c->coilDesEntHumRat, 8);
     298              :         }
     299         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilEntEnthalpyIdealPeak, c->coilName_, c->coilDesEntEnth, 1);
     300         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilLvgDryBulbIdealPeak, c->coilName_, c->coilDesLvgTemp, 2);
     301        13276 :         OutputReportPredefined::PreDefTableEntry(
     302        13276 :             state, state.dataOutRptPredefined->pdchCoilLvgWetBulbIdealPeak, c->coilName_, c->coilDesLvgWetBulb, 2);
     303         6638 :         if (c->coilDesLvgHumRat == -999.0 || c->coilDesLvgHumRat == -99999.0) {
     304         1960 :             OutputReportPredefined::PreDefTableEntry(
     305         2940 :                 state, state.dataOutRptPredefined->pdchCoilLvgHumRatIdealPeak, c->coilName_, c->coilDesLvgHumRat, 1);
     306              :         } else {
     307        11316 :             OutputReportPredefined::PreDefTableEntry(
     308        16974 :                 state, state.dataOutRptPredefined->pdchCoilLvgHumRatIdealPeak, c->coilName_, c->coilDesLvgHumRat, 8);
     309              :         }
     310         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilLvgEnthalpyIdealPeak, c->coilName_, c->coilDesLvgEnth, 1);
     311         6638 :         if (c->coilDesWaterMassFlow == -999.0 || c->coilDesWaterMassFlow == -99999.0) {
     312         7530 :             OutputReportPredefined::PreDefTableEntry(
     313        11295 :                 state, state.dataOutRptPredefined->pdchCoilWaterMassFlowIdealPeak, c->coilName_, c->coilDesWaterMassFlow, 1);
     314              :         } else {
     315         5746 :             OutputReportPredefined::PreDefTableEntry(
     316         8619 :                 state, state.dataOutRptPredefined->pdchCoilWaterMassFlowIdealPeak, c->coilName_, c->coilDesWaterMassFlow, 8);
     317              :         }
     318              : 
     319        13276 :         OutputReportPredefined::PreDefTableEntry(
     320        13276 :             state, state.dataOutRptPredefined->pdchCoilEntWaterTempIdealPeak, c->coilName_, c->coilDesWaterEntTemp, 2);
     321        13276 :         OutputReportPredefined::PreDefTableEntry(
     322        13276 :             state, state.dataOutRptPredefined->pdchCoilLvgWaterTempIdealPeak, c->coilName_, c->coilDesWaterLvgTemp, 2);
     323        13276 :         OutputReportPredefined::PreDefTableEntry(
     324        13276 :             state, state.dataOutRptPredefined->pdchCoilWaterDeltaTempIdealPeak, c->coilName_, c->coilDesWaterTempDiff, 2);
     325        13276 :         OutputReportPredefined::PreDefTableEntry(
     326        13276 :             state, state.dataOutRptPredefined->pdchFanHeatGainIdealPeak, c->coilName_, c->fanHeatGainIdealPeak, 3);
     327        13276 :         OutputReportPredefined::PreDefTableEntry(
     328        13276 :             state, state.dataOutRptPredefined->pdchCoilNetTotalCapacityIdealPeak, c->coilName_, c->coilAndFanNetTotalCapacityIdealPeak, 2);
     329              : 
     330         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilRatedTotalCap, c->coilName_, c->coilRatedTotCap, 2);
     331         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilRatedSensCap, c->coilName_, c->coilRatedSensCap, 2);
     332        13276 :         OutputReportPredefined::PreDefTableEntry(
     333        13276 :             state, state.dataOutRptPredefined->pdchCoilOffRatingCapacityModifierIdealPeak, c->coilName_, c->coilCapFTIdealPeak, 4);
     334         6638 :         if (c->ratedAirMassFlow == -999.0 || c->ratedAirMassFlow == -99999.0) {
     335         2389 :             OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilRatedAirMass, c->coilName_, c->ratedAirMassFlow, 1);
     336              :         } else {
     337         4249 :             OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilRatedAirMass, c->coilName_, c->ratedAirMassFlow, 8);
     338              :         }
     339              : 
     340         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilRatedEntDryBulb, c->coilName_, c->ratedCoilInDb, 2);
     341         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilRatedEntWetBulb, c->coilName_, c->ratedCoilInWb, 2);
     342         6638 :         if (c->ratedCoilInHumRat == -999.0 || c->ratedCoilInHumRat == -99999.0) {
     343         4778 :             OutputReportPredefined::PreDefTableEntry(
     344         7167 :                 state, state.dataOutRptPredefined->pdchCoilRatedEntHumRat, c->coilName_, c->ratedCoilInHumRat, 1);
     345              :         } else {
     346         8498 :             OutputReportPredefined::PreDefTableEntry(
     347        12747 :                 state, state.dataOutRptPredefined->pdchCoilRatedEntHumRat, c->coilName_, c->ratedCoilInHumRat, 8);
     348              :         }
     349              : 
     350         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilRatedEntEnthalpy, c->coilName_, c->ratedCoilInEnth, 1);
     351         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilRatedLvgDryBulb, c->coilName_, c->ratedCoilOutDb, 2);
     352         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilRatedLvgWetBulb, c->coilName_, c->ratedCoilOutWb, 2);
     353         6638 :         if (c->ratedCoilOutHumRat == -999.0 || c->ratedCoilOutHumRat == -99999.0) {
     354         4778 :             OutputReportPredefined::PreDefTableEntry(
     355         7167 :                 state, state.dataOutRptPredefined->pdchCoilRatedLvgHumRat, c->coilName_, c->ratedCoilOutHumRat, 1);
     356              :         } else {
     357         8498 :             OutputReportPredefined::PreDefTableEntry(
     358        12747 :                 state, state.dataOutRptPredefined->pdchCoilRatedLvgHumRat, c->coilName_, c->ratedCoilOutHumRat, 8);
     359              :         }
     360              : 
     361         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilRatedLvgEnthalpy, c->coilName_, c->ratedCoilOutEnth, 1);
     362              : 
     363         6638 :         if (c->plantDesMaxMassFlowRate == -999.0 || c->plantDesMaxMassFlowRate == -99999.0) {
     364         7476 :             OutputReportPredefined::PreDefTableEntry(
     365        11214 :                 state, state.dataOutRptPredefined->pdchPlantMassFlowMaximum, c->coilName_, c->plantDesMaxMassFlowRate, 1);
     366              :         } else {
     367         5800 :             OutputReportPredefined::PreDefTableEntry(
     368         8700 :                 state, state.dataOutRptPredefined->pdchPlantMassFlowMaximum, c->coilName_, c->plantDesMaxMassFlowRate, 8);
     369              :         }
     370         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchPlantRetTempDesign, c->coilName_, c->plantDesRetTemp, 2);
     371         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchPlantSupTempDesign, c->coilName_, c->plantDesSupTemp, 2);
     372         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchPlantDeltaTempDesign, c->coilName_, c->plantDesDeltaTemp, 2);
     373         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchPlantCapacity, c->coilName_, c->plantDesCapacity, 2);
     374        13276 :         OutputReportPredefined::PreDefTableEntry(
     375        13276 :             state, state.dataOutRptPredefined->pdchCoilCapPrcntPlantCapacity, c->coilName_, c->coilCapPrcntPlantCap, 4);
     376         6638 :         if (c->coilFlowPrcntPlantFlow == -999.0 || c->coilFlowPrcntPlantFlow == -99999.0) {
     377         7596 :             OutputReportPredefined::PreDefTableEntry(
     378        11394 :                 state, state.dataOutRptPredefined->pdchCoilFlowPrcntPlantFlow, c->coilName_, c->coilFlowPrcntPlantFlow, 1);
     379              :         } else {
     380         5680 :             OutputReportPredefined::PreDefTableEntry(
     381         8520 :                 state, state.dataOutRptPredefined->pdchCoilFlowPrcntPlantFlow, c->coilName_, c->coilFlowPrcntPlantFlow, 6);
     382              :         }
     383              : 
     384         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchOADryBulbIdealPeak, c->coilName_, c->oaPeakTemp, 2);
     385         6638 :         if (c->oaPeakHumRat == -999.0 || c->oaPeakHumRat == -99999.0) {
     386         1233 :             OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchOAHumRatIdealPeak, c->coilName_, c->oaPeakHumRat, 1);
     387              :         } else {
     388         5405 :             OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchOAHumRatIdealPeak, c->coilName_, c->oaPeakHumRat, 8);
     389              :         }
     390              : 
     391         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchOAWetBulbatIdealPeak, c->coilName_, c->oaPeakWetBulb, 2);
     392         6638 :         if (c->oaPeakVolFlow == -999.0 || c->oaPeakVolFlow == -99999.0) {
     393         1233 :             OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchOAVolFlowIdealPeak, c->coilName_, c->oaPeakVolFlow, 1);
     394              :         } else {
     395         5405 :             OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchOAVolFlowIdealPeak, c->coilName_, c->oaPeakVolFlow, 8);
     396              :         }
     397              : 
     398         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchOAFlowPrcntIdealPeak, c->coilName_, c->oaPeakVolFrac, 4);
     399         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchAirSysRADryBulbIdealPeak, c->coilName_, c->raPeakTemp, 2);
     400         6638 :         if (c->raPeakHumRat == -999.0 || c->raPeakHumRat == -99999.0) {
     401         2466 :             OutputReportPredefined::PreDefTableEntry(
     402         3699 :                 state, state.dataOutRptPredefined->pdchAirSysRAHumRatIdealPeak, c->coilName_, c->raPeakHumRat, 1);
     403              :         } else {
     404        10810 :             OutputReportPredefined::PreDefTableEntry(
     405        16215 :                 state, state.dataOutRptPredefined->pdchAirSysRAHumRatIdealPeak, c->coilName_, c->raPeakHumRat, 8);
     406              :         }
     407              : 
     408         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchZoneAirDryBulbIdealPeak, c->coilName_, c->rmPeakTemp, 2);
     409         6638 :         if (c->rmPeakHumRat == -999.0 || c->rmPeakHumRat == -99999.0) {
     410         1236 :             OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchZoneAirHumRatIdealPeak, c->coilName_, c->rmPeakHumRat, 1);
     411              :         } else {
     412         5402 :             OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchZoneAirHumRatIdealPeak, c->coilName_, c->rmPeakHumRat, 8);
     413              :         }
     414              : 
     415         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchZoneAirRelHumIdealPeak, c->coilName_, c->rmPeakRelHum, 4);
     416         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchCoilUA, c->coilName_, c->coilUA, 3);
     417        13276 :         OutputReportPredefined::PreDefTableEntry(
     418        13276 :             state, state.dataOutRptPredefined->pdchZoneSensibleLoadIdealPeak, c->coilName_, c->rmSensibleAtPeak, 2);
     419         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchZoneLatentLoadIdealPeak, c->coilName_, c->rmLatentAtPeak);
     420         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchReheatCoilMultiplier, c->coilName_, c->reheatLoadMult, 4);
     421        13276 :         OutputReportPredefined::PreDefTableEntry(
     422        13276 :             state, state.dataOutRptPredefined->pdchFlowCapRatioLowCapIncreaseRatio, c->coilName_, c->maxRatio, 5);
     423         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchFlowCapRatioHiCapDecreaseRatio, c->coilName_, c->minRatio, 5);
     424         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchPlantFluidSpecificHeat, c->coilName_, c->cpFluid, 4);
     425         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchPlantFluidDensity, c->coilName_, c->rhoFluid, 4);
     426         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchMoistAirSpecificHeat, c->coilName_, c->cpMoistAir, 4);
     427         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchDryAirSpecificHeat, c->coilName_, c->cpDryAir, 4);
     428         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdchStandRhoAir, c->coilName_, c->rhoStandAir, 4);
     429          759 :     }
     430          759 : }
     431              : 
     432          759 : void ReportCoilSelection::writeCoilSelectionOutput2(EnergyPlusData &state)
     433              : {
     434              : 
     435              :     // make calls to fill out predefined tabular report entries for each coil selection report object
     436         7397 :     for (auto &c : coilSelectionDataObjs) {
     437         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdch2CoilType, c->coilName_, c->coilObjName);
     438         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdch2CoilHVACType, c->coilName_, c->typeHVACname);
     439         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdch2CoilHVACName, c->coilName_, c->userNameforHVACsystem);
     440              : 
     441         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdch2CoilFinalTotalCap, c->coilName_, c->coilTotCapFinal, 3);
     442         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdch2CoilFinalSensCap, c->coilName_, c->coilSensCapFinal, 3);
     443         6638 :         if (c->coilRefAirVolFlowFinal == -999.0 || c->coilRefAirVolFlowFinal == -99999.0) {
     444         3522 :             OutputReportPredefined::PreDefTableEntry(
     445         5283 :                 state, state.dataOutRptPredefined->pdch2CoilFinalAirVolFlowRate, c->coilName_, c->coilRefAirVolFlowFinal, 1);
     446              :         } else {
     447         9754 :             OutputReportPredefined::PreDefTableEntry(
     448        14631 :                 state, state.dataOutRptPredefined->pdch2CoilFinalAirVolFlowRate, c->coilName_, c->coilRefAirVolFlowFinal, 6);
     449              :         }
     450              : 
     451         6638 :         if (c->coilRefWaterVolFlowFinal == -999.0 || c->coilRefWaterVolFlowFinal == -99999.0) {
     452         5932 :             OutputReportPredefined::PreDefTableEntry(
     453         8898 :                 state, state.dataOutRptPredefined->pdch2CoilFinalPlantVolFlowRate, c->coilName_, c->coilRefWaterVolFlowFinal, 1);
     454              :         } else {
     455         7344 :             OutputReportPredefined::PreDefTableEntry(
     456        11016 :                 state, state.dataOutRptPredefined->pdch2CoilFinalPlantVolFlowRate, c->coilName_, c->coilRefWaterVolFlowFinal, 8);
     457              :         }
     458              : 
     459        19914 :         OutputReportPredefined::PreDefTableEntry(
     460        19914 :             state, state.dataOutRptPredefined->pdch2CoilDDnameSensIdealPeak, c->coilName_, c->desDayNameAtSensPeak);
     461        19914 :         OutputReportPredefined::PreDefTableEntry(
     462        19914 :             state, state.dataOutRptPredefined->pdch2CoilDateTimeSensIdealPeak, c->coilName_, c->coilSensePeakHrMin);
     463        19914 :         OutputReportPredefined::PreDefTableEntry(
     464        19914 :             state, state.dataOutRptPredefined->pdch2CoilDDnameAirFlowIdealPeak, c->coilName_, c->desDayNameAtAirFlowPeak);
     465         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdch2CoilDateTimeAirFlowIdealPeak, c->coilName_, c->airPeakHrMin);
     466         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdch2CoilTotalCapIdealPeak, c->coilName_, c->coilTotCapAtPeak, 2);
     467         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdch2CoilSensCapIdealPeak, c->coilName_, c->coilSensCapAtPeak, 2);
     468         6638 :         if (c->coilDesVolFlow == -999.0 || c->coilDesVolFlow == -99999.0) {
     469         1038 :             OutputReportPredefined::PreDefTableEntry(
     470         1557 :                 state, state.dataOutRptPredefined->pdch2CoilAirVolumeFlowIdealPeak, c->coilName_, c->coilDesVolFlow, 1);
     471              :         } else {
     472        12238 :             OutputReportPredefined::PreDefTableEntry(
     473        18357 :                 state, state.dataOutRptPredefined->pdch2CoilAirVolumeFlowIdealPeak, c->coilName_, c->coilDesVolFlow, 6);
     474              :         }
     475         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdch2CoilEntDryBulbIdealPeak, c->coilName_, c->coilDesEntTemp, 2);
     476        13276 :         OutputReportPredefined::PreDefTableEntry(
     477        13276 :             state, state.dataOutRptPredefined->pdch2CoilEntWetBulbIdealPeak, c->coilName_, c->coilDesEntWetBulb, 2);
     478         6638 :         if (c->coilDesEntHumRat == -999.0 || c->coilDesEntHumRat == -99999.0) {
     479         1964 :             OutputReportPredefined::PreDefTableEntry(
     480         2946 :                 state, state.dataOutRptPredefined->pdch2CoilEntHumRatIdealPeak, c->coilName_, c->coilDesEntHumRat, 1);
     481              :         } else {
     482        11312 :             OutputReportPredefined::PreDefTableEntry(
     483        16968 :                 state, state.dataOutRptPredefined->pdch2CoilEntHumRatIdealPeak, c->coilName_, c->coilDesEntHumRat, 8);
     484              :         }
     485         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdch2CoilLvgDryBulbIdealPeak, c->coilName_, c->coilDesLvgTemp, 2);
     486        13276 :         OutputReportPredefined::PreDefTableEntry(
     487        13276 :             state, state.dataOutRptPredefined->pdch2CoilLvgWetBulbIdealPeak, c->coilName_, c->coilDesLvgWetBulb, 2);
     488         6638 :         if (c->coilDesLvgHumRat == -999.0 || c->coilDesLvgHumRat == -99999.0) {
     489         1960 :             OutputReportPredefined::PreDefTableEntry(
     490         2940 :                 state, state.dataOutRptPredefined->pdch2CoilLvgHumRatIdealPeak, c->coilName_, c->coilDesLvgHumRat, 1);
     491              :         } else {
     492        11316 :             OutputReportPredefined::PreDefTableEntry(
     493        16974 :                 state, state.dataOutRptPredefined->pdch2CoilLvgHumRatIdealPeak, c->coilName_, c->coilDesLvgHumRat, 8);
     494              :         }
     495              : 
     496         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdch2CoilRatedTotalCap, c->coilName_, c->coilRatedTotCap, 2);
     497         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdch2CoilRatedSensCap, c->coilName_, c->coilRatedSensCap, 2);
     498              : 
     499         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdch2OADryBulbIdealPeak, c->coilName_, c->oaPeakTemp, 2);
     500         6638 :         if (c->oaPeakHumRat == -999.0 || c->oaPeakHumRat == -99999.0) {
     501         1233 :             OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdch2OAHumRatIdealPeak, c->coilName_, c->oaPeakHumRat, 1);
     502              :         } else {
     503         5405 :             OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdch2OAHumRatIdealPeak, c->coilName_, c->oaPeakHumRat, 8);
     504              :         }
     505              : 
     506         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdch2OAWetBulbatIdealPeak, c->coilName_, c->oaPeakWetBulb, 2);
     507         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdch2OAFlowPrcntIdealPeak, c->coilName_, c->oaPeakVolFrac, 4);
     508              : 
     509         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdch2ZoneAirDryBulbIdealPeak, c->coilName_, c->rmPeakTemp, 2);
     510         6638 :         if (c->rmPeakHumRat == -999.0 || c->rmPeakHumRat == -99999.0) {
     511         2472 :             OutputReportPredefined::PreDefTableEntry(
     512         3708 :                 state, state.dataOutRptPredefined->pdch2ZoneAirHumRatIdealPeak, c->coilName_, c->rmPeakHumRat, 1);
     513              :         } else {
     514        10804 :             OutputReportPredefined::PreDefTableEntry(
     515        16206 :                 state, state.dataOutRptPredefined->pdch2ZoneAirHumRatIdealPeak, c->coilName_, c->rmPeakHumRat, 8);
     516              :         }
     517              : 
     518         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdch2ZoneAirRelHumIdealPeak, c->coilName_, c->rmPeakRelHum, 4);
     519         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdch2CoilUA, c->coilName_, c->coilUA, 3);
     520        13276 :         OutputReportPredefined::PreDefTableEntry(
     521        13276 :             state, state.dataOutRptPredefined->pdch2ZoneSensibleLoadIdealPeak, c->coilName_, c->rmSensibleAtPeak, 2);
     522         6638 :         OutputReportPredefined::PreDefTableEntry(state, state.dataOutRptPredefined->pdch2ZoneLatentLoadIdealPeak, c->coilName_, c->rmLatentAtPeak);
     523          759 :     }
     524          759 : }
     525              : 
     526         6559 : 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         6559 :     int index = getIndexForOrCreateDataObjFromCoilName(state, coilName, coilObjName);
     536         6559 :     auto &c(coilSelectionDataObjs[index]);
     537         6559 :     if (c != nullptr) {
     538         6559 :         c->coilTotCapFinal = totGrossCap;
     539         6559 :         c->coilSensCapFinal = sensGrossCap;
     540         6559 :         c->coilRefAirVolFlowFinal = airFlowRate;
     541         6559 :         c->coilRefWaterVolFlowFinal = waterFlowRate;
     542              :     }
     543         6559 : }
     544              : 
     545        16326 : 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        16326 :     auto &c(coilSelectionDataObjs[coilVecIndex]);
     549        16326 :     if (c->airloopNum > 0 && c->airloopNum <= int(state.dataAirSystemsData->PrimaryAirSystems.size())) {
     550              :         // see if there is an OA controller
     551         7589 :         if (state.dataAirSystemsData->PrimaryAirSystems(c->airloopNum).OASysExists) {
     552              :             // loop over OA controllers and match node num ?
     553        93485 :             for (int loop = 1; loop <= state.dataMixedAir->NumOAControllers; ++loop) {
     554        86197 :                 if (state.dataAirSystemsData->PrimaryAirSystems(c->airloopNum).OASysInletNodeNum == state.dataMixedAir->OAController(loop).RetNode) {
     555         7248 :                     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         7589 :         if (allocated(state.dataAirLoop->AirToZoneNodeInfo)) {
     562         7589 :             if (state.dataAirLoop->AirToZoneNodeInfo(c->airloopNum).NumZonesCooled > 0) {
     563         7589 :                 int zoneCount = state.dataAirLoop->AirToZoneNodeInfo(c->airloopNum).NumZonesCooled;
     564         7589 :                 c->zoneNum.resize(zoneCount);
     565         7589 :                 c->zoneName.resize(zoneCount);
     566        44493 :                 for (int loopZone = 1; loopZone <= state.dataAirLoop->AirToZoneNodeInfo(c->airloopNum).NumZonesCooled; ++loopZone) {
     567        36904 :                     c->zoneNum[loopZone - 1] = state.dataAirLoop->AirToZoneNodeInfo(c->airloopNum).CoolCtrlZoneNums(loopZone);
     568        36904 :                     c->zoneName[loopZone - 1] = state.dataHeatBal->Zone(c->zoneNum[loopZone - 1]).Name;
     569              :                 }
     570              :             }
     571              : 
     572         7589 :             if (state.dataAirLoop->AirToZoneNodeInfo(c->airloopNum).NumZonesHeated > 0) {
     573           36 :                 int zoneCount = state.dataAirLoop->AirToZoneNodeInfo(c->airloopNum).NumZonesHeated;
     574          209 :                 for (int loopZone = 1; loopZone <= zoneCount; ++loopZone) {
     575          173 :                     int zoneIndex = state.dataAirLoop->AirToZoneNodeInfo(c->airloopNum).HeatCtrlZoneNums(loopZone);
     576              :                     // see if this zone is new or already in list
     577          173 :                     bool found = false;
     578          531 :                     for (auto const &z : c->zoneNum) {
     579          531 :                         if (z == zoneIndex) {
     580          173 :                             found = true;
     581          173 :                             break;
     582              :                         }
     583          173 :                     }
     584          173 :                     if (!found) { // add it
     585            0 :                         c->zoneNum.emplace_back(zoneIndex);
     586            0 :                         c->zoneName.emplace_back(state.dataHeatBal->Zone(zoneIndex).Name);
     587              :                     }
     588              :                 }
     589              :             }
     590              :         }
     591              :     }
     592        16326 : }
     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          759 : void ReportCoilSelection::doFinalProcessingOfCoilData(EnergyPlusData &state)
     633              : {
     634              :     // this routine does some final processing in preparation for writing out results
     635         7397 :     for (auto &c : coilSelectionDataObjs) {
     636              : 
     637              :         // mine final/hard values from coil models
     638              : 
     639         6638 :         if (c->zoneEqNum > 0) {
     640         3811 :             associateZoneCoilWithParent(state, c);
     641              :         }
     642              : 
     643         6638 :         if (c->airloopNum > state.dataHVACGlobal->NumPrimaryAirSys && c->oASysNum > 0) {
     644            2 :             c->coilLocation = "DOAS AirLoop";
     645            2 :             c->typeHVACname = "AirLoopHVAC:DedicatedOutdoorAirSystem";
     646            2 :             int DOASSysNum = state.dataAirLoop->OutsideAirSys(c->oASysNum).AirLoopDOASNum;
     647            2 :             c->userNameforHVACsystem = state.dataAirLoopHVACDOAS->airloopDOAS[DOASSysNum].Name;
     648         6636 :         } else if (c->airloopNum > 0 && c->zoneEqNum == 0) {
     649         2700 :             c->coilLocation = "AirLoop";
     650         2700 :             c->typeHVACname = "AirLoopHVAC";
     651         2700 :             c->userNameforHVACsystem = state.dataAirSystemsData->PrimaryAirSystems(c->airloopNum).Name;
     652         3936 :         } 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         6638 :         if (c->coilDesVolFlow > 0) {
     658         5847 :             c->oaPeakVolFrac = (c->oaPeakVolFlow / c->coilDesVolFlow) * 100.0; // make into percentage
     659              :         } else {
     660          791 :             c->oaPeakVolFrac = -999.0;
     661              :         }
     662              : 
     663         6638 :         c->coilSizingMethodConcurrenceName = DataSizing::CoilSizingConcurrenceNames[(int)c->coilSizingMethodConcurrence];
     664              : 
     665         6638 :         if (c->coilSizingMethodCapacity == DataSizing::CoolingDesignCapacity) {
     666          974 :             c->coilSizingMethodCapacityName = "CoolingDesignCapacity";
     667         5664 :         } else if (c->coilSizingMethodCapacity == DataSizing::HeatingDesignCapacity) {
     668         1161 :             c->coilSizingMethodCapacityName = "HeatingDesignCapacity";
     669         4503 :         } else if (c->coilSizingMethodCapacity == DataSizing::CapacityPerFloorArea) {
     670            0 :             c->coilSizingMethodCapacityName = "CapacityPerFloorArea";
     671         4503 :         } else if (c->coilSizingMethodCapacity == DataSizing::FractionOfAutosizedCoolingCapacity) {
     672            1 :             c->coilSizingMethodCapacityName = "FractionOfAutosizedCoolingCapacity";
     673         4502 :         } else if (c->coilSizingMethodCapacity == DataSizing::FractionOfAutosizedHeatingCapacity) {
     674            1 :             c->coilSizingMethodCapacityName = "FractionOfAutosizedHeatingCapacity";
     675              :         }
     676              : 
     677         6638 :         if (c->coilSizingMethodAirFlow == DataSizing::SupplyAirFlowRate) {
     678            0 :             c->coilSizingMethodAirFlowName = "SupplyAirFlowRate";
     679         6638 :         } else if (c->coilSizingMethodAirFlow == DataSizing::FlowPerFloorArea) {
     680            0 :             c->coilSizingMethodAirFlowName = "FlowPerFloorArea";
     681         6638 :         } else if (c->coilSizingMethodAirFlow == DataSizing::FractionOfAutosizedCoolingAirflow) {
     682            0 :             c->coilSizingMethodAirFlowName = "FractionOfAutosizedCoolingAirflow";
     683         6638 :         } else if (c->coilSizingMethodAirFlow == DataSizing::FractionOfAutosizedHeatingAirflow) {
     684            0 :             c->coilSizingMethodAirFlowName = "FractionOfAutosizedHeatingAirflow";
     685              :         }
     686              : 
     687         6638 :         if (c->isCoilSizingForTotalLoad) {
     688           12 :             c->coilPeakLoadTypeToSizeOnName = "Total";
     689              :         } else {
     690         6626 :             c->coilPeakLoadTypeToSizeOnName = "Sensible";
     691              :         }
     692              : 
     693         6638 :         if (c->capIsAutosized) {
     694         5169 :             c->coilCapAutoMsg = "Yes";
     695              :         } else {
     696         1469 :             c->coilCapAutoMsg = "No";
     697              :         }
     698              : 
     699         6638 :         if (c->volFlowIsAutosized) {
     700         4900 :             c->coilVolFlowAutoMsg = "Yes";
     701              :         } else {
     702         1738 :             c->coilVolFlowAutoMsg = "No";
     703              :         }
     704              : 
     705         6638 :         if (c->oaPretreated) {
     706           58 :             c->coilOAPretreatMsg = "Yes";
     707              :         } else {
     708         6580 :             c->coilOAPretreatMsg = "No";
     709              :         }
     710              : 
     711              :         // call psych routine to flush out moist air metrics from those available
     712         6638 :         if (c->coilDesEntTemp != -999.0 && c->coilDesEntHumRat != -999.0) {
     713        11310 :             c->coilDesEntWetBulb = Psychrometrics::PsyTwbFnTdbWPb(
     714         5655 :                 state, c->coilDesEntTemp, c->coilDesEntHumRat, state.dataEnvrn->StdBaroPress, "ReportCoilSelection::doFinalProcessingOfCoilData");
     715         5655 :             if (c->coilDesEntHumRat != -999.0) {
     716         5655 :                 c->coilDesEntEnth = Psychrometrics::PsyHFnTdbW(c->coilDesEntTemp, c->coilDesEntHumRat);
     717              :             }
     718              :         }
     719         6638 :         if (c->oaPeakTemp != -999.0 && c->oaPeakHumRat != -999.0) {
     720        10810 :             c->oaPeakWetBulb = Psychrometrics::PsyTwbFnTdbWPb(
     721         5405 :                 state, c->oaPeakTemp, c->oaPeakHumRat, state.dataEnvrn->StdBaroPress, "ReportCoilSelection::doFinalProcessingOfCoilData");
     722              :         }
     723              : 
     724         6638 :         if (c->waterLoopNum > 0 && c->pltSizNum > 0) {
     725              : 
     726         2900 :             c->plantLoopName = state.dataPlnt->PlantLoop(c->waterLoopNum).Name;
     727         2900 :             if (state.dataSize->PlantSizData(c->pltSizNum).LoopType != DataSizing::TypeOfPlantLoop::Steam) {
     728         2880 :                 c->rhoFluid = state.dataPlnt->PlantLoop(c->waterLoopNum)
     729         2880 :                                   .glycol->getDensity(state, Constant::InitConvTemp, "ReportCoilSelection::doFinalProcessingOfCoilData");
     730              : 
     731         2880 :                 c->cpFluid = state.dataPlnt->PlantLoop(c->waterLoopNum)
     732         2880 :                                  .glycol->getSpecificHeat(state, Constant::InitConvTemp, "ReportCoilSelection::doFinalProcessingOfCoilData");
     733              :             } else { // steam loop
     734           20 :                 c->rhoFluid = state.dataPlnt->PlantLoop(c->waterLoopNum)
     735           20 :                                   .steam->getSatDensity(state, 100.0, 1.0, "ReportCoilSelection::doFinalProcessingOfCoilData");
     736           20 :                 c->cpFluid = state.dataPlnt->PlantLoop(c->waterLoopNum)
     737           20 :                                  .steam->getSatSpecificHeat(state, 100.0, 0.0, "ReportCoilSelection::doFinalProcessingOfCoilData");
     738              :             }
     739         2900 :             c->plantDesMaxMassFlowRate = state.dataPlnt->PlantLoop(c->waterLoopNum).MaxMassFlowRate;
     740         2900 :             if (c->plantDesMaxMassFlowRate > 0.0 && c->coilDesWaterMassFlow > 0.0) {
     741         2840 :                 c->coilFlowPrcntPlantFlow = (c->coilDesWaterMassFlow / c->plantDesMaxMassFlowRate) * 100.0; // convert to percentage.
     742              :             }
     743              :         }
     744              :         // fill out some fan information
     745         6638 :         HVAC::FanType locFanType = HVAC::FanType::Invalid;
     746         6638 :         if (c->supFanNum == 0) {
     747         3075 :             c->supFanNum = Fans::GetFanIndex(state, c->fanAssociatedWithCoilName);
     748              :         }
     749              : 
     750         6638 :         if (c->supFanNum != 0) {
     751         3802 :             auto *fan = state.dataFans->fans(c->supFanNum);
     752         3802 :             locFanType = fan->type;
     753         3802 :             c->fanTypeName = HVAC::fanTypeNames[(int)locFanType];
     754         3802 :             c->fanSizeMaxAirVolumeFlow = fan->maxAirFlowRate;
     755         3802 :             c->fanSizeMaxAirMassFlow = fan->maxAirMassFlowRate;
     756              :         }
     757              : 
     758         6638 :         c->coilAndFanNetTotalCapacityIdealPeak = c->coilTotCapAtPeak - c->fanHeatGainIdealPeak;
     759              : 
     760              :         // fill out some plant design info
     761         6638 :         if (c->pltSizNum > 0) {
     762         2900 :             c->plantDesSupTemp = state.dataSize->PlantSizData(c->pltSizNum).ExitTemp;
     763         2900 :             c->plantDesDeltaTemp = state.dataSize->PlantSizData(c->pltSizNum).DeltaT;
     764         2900 :             if (state.dataSize->PlantSizData(c->pltSizNum).LoopType == DataSizing::TypeOfPlantLoop::Heating) {
     765         2384 :                 c->plantDesRetTemp = c->plantDesSupTemp - c->plantDesDeltaTemp;
     766          544 :             } else if (state.dataSize->PlantSizData(c->pltSizNum).LoopType == DataSizing::TypeOfPlantLoop::Cooling ||
     767           28 :                        state.dataSize->PlantSizData(c->pltSizNum).LoopType == DataSizing::TypeOfPlantLoop::Condenser) {
     768          496 :                 c->plantDesRetTemp = c->plantDesSupTemp + c->plantDesDeltaTemp;
     769              :             }
     770              : 
     771         2900 :             if (state.dataSize->PlantSizData(c->pltSizNum).LoopType != DataSizing::TypeOfPlantLoop::Steam) {
     772         5760 :                 c->plantDesCapacity = c->cpFluid * c->rhoFluid * state.dataSize->PlantSizData(c->pltSizNum).DeltaT *
     773         2880 :                                       state.dataSize->PlantSizData(c->pltSizNum).DesVolFlowRate;
     774              :             } else {
     775              :                 // find boiler on this plant loop and get capacity from it
     776           20 :                 if (allocated(state.dataBoilerSteam->Boiler)) {
     777           28 :                     for (int boilerIndex = 1; boilerIndex <= (int)state.dataBoilerSteam->Boiler.size(); ++boilerIndex) {
     778           14 :                         if (state.dataBoilerSteam->Boiler(boilerIndex).plantLoc.loopNum == c->waterLoopNum) { // steam boiler on this loop
     779           14 :                             c->plantDesSupTemp = state.dataBoilerSteam->Boiler(boilerIndex).TempUpLimitBoilerOut;
     780           14 :                             c->plantDesRetTemp = state.dataBoilerSteam->Boiler(boilerIndex).TempUpLimitBoilerOut - c->plantDesDeltaTemp;
     781           14 :                             c->plantDesCapacity = state.dataBoilerSteam->Boiler(boilerIndex).NomCap;
     782              :                         }
     783              :                     }
     784              :                 }
     785              :             }
     786              : 
     787         2900 :             if (c->plantDesCapacity > 0.0) {
     788         2894 :                 c->coilCapPrcntPlantCap = (c->coilTotCapAtPeak / c->plantDesCapacity) * 100.0; // convert to percentage.
     789              :             }
     790              :         }
     791              : 
     792         6638 :         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         6638 :         c->cpDryAir = Psychrometrics::PsyCpAirFnW(0.0);
     809         6638 :         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         6638 :         if (c->coilDesEntTemp > c->coilDesLvgTemp) { // cooling coil
     813              :             Real64 CoilADPTemp =
     814         1648 :                 Psychrometrics::PsyTdpFnWPb(state, c->coilDesLvgHumRat, state.dataEnvrn->StdBaroPress); // apparatus dewpoint temperature
     815              :             Real64 CoilADPHumRat =
     816         1648 :                 Psychrometrics::PsyWFnTdpPb(state, CoilADPTemp, state.dataEnvrn->StdBaroPress); // humidity ratio at apparatus dewpoint temperaure
     817         1648 :             Real64 CoilTinwADPEnthalpy = Psychrometrics::PsyHFnTdbW(
     818         1648 :                 c->coilDesEntTemp, CoilADPHumRat); // Enthalpy at inlet drybulb and humidity ratio at apparatus dewpoint temperature
     819              :             Real64 CoilADPEnthalpy =
     820         1648 :                 Psychrometrics::PsyHFnTdbW(CoilADPTemp, CoilADPHumRat); // Enthalpy at apparatus dewpoint, with Tdb set at apparatus dewpoint
     821         1648 :             Real64 SHRatIdealPeak(1.0);
     822         1648 :             if ((c->coilDesEntEnth - CoilADPEnthalpy) > 1.e-10) {
     823         1630 :                 SHRatIdealPeak = min((CoilTinwADPEnthalpy - CoilADPEnthalpy) / (c->coilDesEntEnth - CoilADPEnthalpy), 1.0); // calculate SHR
     824              :             } else {
     825           18 :                 SHRatIdealPeak = 1.0;
     826              :             }
     827         1648 :             c->coilSensCapAtPeak = SHRatIdealPeak * c->coilTotCapAtPeak;
     828              :         }
     829          759 :     } // end for loop over each coil
     830          759 : }
     831              : 
     832        93316 : 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        93316 :     int index(-1);
     838      2682390 :     for (int i = 0; i < numCoilsReported_; i++) {
     839      2675611 :         if (coilSelectionDataObjs[i] != nullptr) {
     840      2675611 :             if (Util::SameString(coilSelectionDataObjs[i]->coilName_, coilName)) {
     841        86537 :                 if (Util::SameString(coilSelectionDataObjs[i]->coilObjName, coilType)) {
     842        86537 :                     return index = i;
     843              :                 } else {
     844              :                     // throw error  coil type does not match coil name, check for unique names across coil types
     845            0 :                     ShowWarningError(state,
     846            0 :                                      format("check for unique coil names across different coil types: {} occurs in both {} and {}",
     847              :                                             coilName,
     848              :                                             coilType,
     849            0 :                                             coilSelectionDataObjs[i]->coilObjName));
     850              :                 }
     851              :             }
     852              :         }
     853              :     }
     854              : 
     855         6779 :     if (index == -1) { // then did not find it
     856              :         // check if really a coil type
     857         6779 :         bool found(false);
     858         6779 :         bool locIsCooling(false);
     859         6779 :         bool locIsHeating(false);
     860        99817 :         for (int loop = 1; loop <= HVAC::NumAllCoilTypes; ++loop) {
     861        99817 :             if (Util::SameString(coilType, HVAC::cAllCoilTypes(loop))) {
     862         6779 :                 found = true;
     863         6779 :                 locIsCooling = Util::SameString(coilType, HVAC::cCoolingCoilTypes(loop));
     864         6779 :                 locIsHeating = Util::SameString(coilType, HVAC::cHeatingCoilTypes(loop));
     865         6779 :                 break;
     866              :             }
     867              :         }
     868         6779 :         if (found) {
     869         6779 :             coilSelectionDataObjs.emplace_back(new CoilSelectionData(coilName));
     870         6779 :             index = coilSelectionDataObjs.size() - 1;
     871         6779 :             coilSelectionDataObjs[index]->coilObjName = coilType;
     872         6779 :             ++numCoilsReported_;
     873         6779 :             coilSelectionDataObjs[index]->isCooling = locIsCooling;
     874         6779 :             coilSelectionDataObjs[index]->isHeating = locIsHeating;
     875              :         }
     876              :     }
     877              : 
     878         6779 :     if (index == -1) {
     879            0 :         ShowFatalError(state, format("getIndexForOrCreateDataObjFromCoilName: Developer error - not a coil: {} = {}", coilType, coilName));
     880              :     }
     881         6779 :     return index;
     882              : }
     883              : 
     884         3811 : void ReportCoilSelection::associateZoneCoilWithParent(EnergyPlusData &state, std::unique_ptr<CoilSelectionData> &c)
     885              : {
     886         3811 :     c->coilLocation = "Unknown";
     887         3811 :     c->typeHVACname = "Unknown";
     888         3811 :     c->userNameforHVACsystem = "Unknown";
     889              :     // now search equipment
     890         3811 :     auto const &zoneEquipList = state.dataZoneEquip->ZoneEquipList(c->zoneEqNum);
     891         3811 :     bool coilFound = false;
     892         3811 :     std::string fanType;
     893         3811 :     std::string fanName;
     894         7044 :     auto thisSubCoilLambda = [&c](const DataZoneEquipment::SubEquipmentData &myCoil) { return myCoil.Name == c->coilName_; };
     895         5910 :     auto thisSubFanLambda = [](const DataZoneEquipment::SubEquipmentData &myFan) { return myFan.TypeOf.rfind("FAN:", 0) == 0; };
     896         2572 :     auto thisSubSubCoilLambda = [&c](const DataZoneEquipment::SubSubEquipmentData &myCoil) { return myCoil.Name == c->coilName_; };
     897         2584 :     auto thisSubSubFanLambda = [](const DataZoneEquipment::SubSubEquipmentData &myFan) { return myFan.TypeOf.rfind("FAN:", 0) == 0; };
     898              : 
     899         4307 :     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         4307 :         bool fanFound = false;
     903         4307 :         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         4307 :         if (std::find_if(thisSubEq.begin(), thisSubEq.end(), thisSubCoilLambda) != thisSubEq.end()) {
     907         1306 :             c->typeHVACname = zoneEquipList.EquipTypeName(equipLoop);
     908         1306 :             c->userNameforHVACsystem = zoneEquipList.EquipName(equipLoop);
     909         1306 :             c->coilLocation = "Zone Equipment";
     910         1306 :             int zoneEqListIndex = Util::FindItemInList(zoneEquipList.Name, state.dataZoneEquip->ZoneEquipList);
     911         1306 :             if (c->zoneNum.empty()) {
     912          193 :                 c->zoneNum.resize(1);
     913              :             }
     914         1306 :             c->zoneNum[0] = zoneEqListIndex;
     915         1306 :             if (c->zoneName.empty()) {
     916          193 :                 c->zoneName.resize(1);
     917              :             }
     918         1306 :             c->zoneName[0] = state.dataHeatBal->Zone(zoneEqListIndex).Name;
     919         1306 :             coilFound = true;
     920              :         }
     921         4307 :         auto const &fanIterator = std::find_if(thisSubEq.begin(), thisSubEq.end(), thisSubFanLambda);
     922         4307 :         if (fanIterator != thisSubEq.end()) {
     923         1331 :             unsigned int fanIndex = fanIterator - thisSubEq.begin();
     924              :             // notice the brackets on the Array1D for [fanIndex]
     925         1331 :             fanType = thisSubEq[fanIndex].TypeOf;
     926         1331 :             fanName = thisSubEq[fanIndex].Name;
     927         1331 :             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         4307 :         if (!coilFound || !fanFound) {
     931         5962 :             for (int subEq = 1; subEq <= zoneEquipList.EquipData(equipLoop).NumSubEquip; ++subEq) {
     932         3038 :                 auto &thisSubSubEq = zoneEquipList.EquipData(equipLoop).SubEquipData(subEq).SubSubEquipData;
     933         3038 :                 if (!coilFound) {
     934         3038 :                     auto const &coilIterator2 = std::find_if(thisSubSubEq.begin(), thisSubSubEq.end(), thisSubSubCoilLambda);
     935         3038 :                     if (coilIterator2 != thisSubSubEq.end()) {
     936         2505 :                         c->typeHVACname = zoneEquipList.EquipTypeName(equipLoop);
     937         2505 :                         c->userNameforHVACsystem = zoneEquipList.EquipName(equipLoop);
     938         2505 :                         c->coilLocation = "Zone Equipment";
     939         2505 :                         int zoneEqListIndex = Util::FindItemInList(zoneEquipList.Name, state.dataZoneEquip->ZoneEquipList);
     940         2505 :                         if (c->zoneNum.empty()) {
     941          350 :                             c->zoneNum.resize(1);
     942              :                         }
     943         2505 :                         c->zoneNum[0] = zoneEqListIndex;
     944         2505 :                         if (c->zoneName.empty()) {
     945          350 :                             c->zoneName.resize(1);
     946              :                         }
     947         2505 :                         c->zoneName[0] = state.dataHeatBal->Zone(zoneEqListIndex).Name;
     948         2505 :                         coilFound = true;
     949              :                     }
     950              :                 }
     951         3038 :                 if (!fanFound) {
     952         2938 :                     auto const &fanIterator2 = std::find_if(thisSubSubEq.begin(), thisSubSubEq.end(), thisSubSubFanLambda);
     953         2938 :                     if (fanIterator2 != thisSubSubEq.end()) {
     954           80 :                         unsigned int fanIndex = fanIterator2 - thisSubSubEq.begin();
     955              :                         // notice the brackets on the Array1D for [fanIndex]
     956           80 :                         fanType = thisSubSubEq[fanIndex].TypeOf;
     957           80 :                         fanName = thisSubSubEq[fanIndex].Name;
     958           80 :                         fanFound = true;
     959              :                     }
     960              :                 }
     961         3038 :                 if (coilFound && fanFound) {
     962           77 :                     break;
     963              :                 }
     964              :             }
     965              :         }
     966         4307 :         if (coilFound) {
     967         3811 :             if (fanFound) {
     968         1383 :                 c->fanTypeName = fanType;
     969         1383 :                 c->fanAssociatedWithCoilName = fanName;
     970              :             }
     971         3811 :             break;
     972              :         }
     973              : 
     974              :     } // for (equipLoop)
     975              : 
     976         3811 :     if (c->typeHVACname == "Unknown") {
     977            0 :         ShowWarningError(state, format("Parent object not found for zone coil = {}", c->coilName_));
     978              :     }
     979         3811 : }
     980              : 
     981         4383 : 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         4383 :     int index = getIndexForOrCreateDataObjFromCoilName(state, coilName, coilObjName);
    1000         4383 :     auto &c(coilSelectionDataObjs[index]);
    1001         4383 :     c->coilRatedTotCap = RatedCoilTotCap;
    1002         4383 :     c->coilRatedSensCap = RatedCoilSensCap;
    1003         4383 :     c->ratedAirMassFlow = RatedAirMassFlow;
    1004         4383 :     c->ratedCoilInDb = RatedCoilInDb;
    1005         4383 :     c->ratedCoilInWb = RatedCoilInWb;
    1006         4383 :     c->ratedCoilInHumRat = RatedCoilInHumRat;
    1007         4383 :     if ((RatedCoilInDb == -999.0) || (RatedCoilInHumRat == -999.0)) {
    1008           20 :         c->ratedCoilInEnth = -999.0;
    1009              :     } else {
    1010         4363 :         c->ratedCoilInEnth = Psychrometrics::PsyHFnTdbW(RatedCoilInDb, RatedCoilInHumRat);
    1011              :     }
    1012              : 
    1013         4383 :     c->ratedCoilOutDb = RatedCoilOutDb;
    1014         4383 :     c->ratedCoilOutWb = RatedCoilOutWb;
    1015         4383 :     c->ratedCoilOutHumRat = RatedCoilOutHumRat;
    1016         4383 :     if ((RatedCoilOutDb == -999.0) || (RatedCoilOutHumRat == -999.0)) {
    1017           20 :         c->ratedCoilOutEnth = -999.0;
    1018              :     } else {
    1019         4363 :         c->ratedCoilOutEnth = Psychrometrics::PsyHFnTdbW(RatedCoilOutDb, RatedCoilOutHumRat);
    1020              :     }
    1021              : 
    1022         4383 :     c->ratedCoilEff = RatedCoilEff;
    1023         4383 :     c->ratedCoilBpFactor = RatedCoilBpFactor;
    1024              :     // TODO    //c->ratedCoilAppDewPt =
    1025         4383 :     c->ratedCoilOadbRef = RatedCoilOadbRef;
    1026         4383 :     c->ratedCoilOawbRef = RatedCoilOawbRef;
    1027         4383 : }
    1028              : 
    1029        10457 : 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        10457 :     int index = getIndexForOrCreateDataObjFromCoilName(state, coilName, coilType);
    1037        10457 :     auto &c(coilSelectionDataObjs[index]);
    1038        10457 :     c->coilDesVolFlow = airVdot;
    1039        10457 :     c->volFlowIsAutosized = isAutoSized;
    1040              : 
    1041        10457 :     c->coilDesMassFlow = airVdot * state.dataEnvrn->StdRhoAir;
    1042        10457 : }
    1043              : 
    1044           26 : 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           26 :     int plantSizNum = -999;
    1055           26 :     if ((state.dataSize->NumPltSizInput > 0) && (inletNodeNum > 0) && (outletNodeNum > 0)) {
    1056           26 :         bool errorsfound = false;
    1057           26 :         plantSizNum = PlantUtilities::MyPlantSizingIndex(state, "water coil", coilName, inletNodeNum, outletNodeNum, errorsfound);
    1058              :     }
    1059           26 :     state.dataRptCoilSelection->coilSelectionReportObj->setCoilWaterFlowPltSizNum(
    1060              :         state, coilName, coilType, waterVdot, isAutoSized, plantSizNum, plantLoopNum);
    1061           26 : }
    1062              : 
    1063         5889 : 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         5889 :     int index = getIndexForOrCreateDataObjFromCoilName(state, coilName, coilType);
    1073         5889 :     auto &c(coilSelectionDataObjs[index]);
    1074         5889 :     c->pltSizNum = plantSizNum;
    1075         5889 :     c->waterLoopNum = plantLoopNum;
    1076         5889 :     if (c->waterLoopNum > 0) {
    1077         5875 :         c->plantLoopName = state.dataPlnt->PlantLoop(c->waterLoopNum).Name;
    1078              :     }
    1079              : 
    1080         5889 :     if (c->waterLoopNum > 0 && c->pltSizNum > 0) {
    1081         5875 :         if (state.dataSize->PlantSizData(c->pltSizNum).LoopType != DataSizing::TypeOfPlantLoop::Steam) {
    1082        11710 :             c->rhoFluid =
    1083         5855 :                 state.dataPlnt->PlantLoop(c->waterLoopNum).glycol->getDensity(state, Constant::InitConvTemp, "ReportCoilSelection::setCoilWaterFlow");
    1084              : 
    1085         5855 :             c->cpFluid = state.dataPlnt->PlantLoop(c->waterLoopNum)
    1086         5855 :                              .glycol->getSpecificHeat(state, Constant::InitConvTemp, "ReportCoilSelection::setCoilWaterFlow");
    1087              :         } else { // steam loop
    1088           20 :             c->rhoFluid = state.dataPlnt->PlantLoop(c->waterLoopNum).steam->getSatDensity(state, 100.0, 1.0, "ReportCoilSelection::setCoilWaterFlow");
    1089           40 :             c->cpFluid =
    1090           20 :                 state.dataPlnt->PlantLoop(c->waterLoopNum).steam->getSatSpecificHeat(state, 100.0, 0.0, "ReportCoilSelection::setCoilWaterFlow");
    1091              :         }
    1092              :     }
    1093         5889 :     if (c->rhoFluid > 0.0) {
    1094         5875 :         c->coilDesWaterMassFlow = waterVdot * c->rhoFluid;
    1095              :     }
    1096         5889 :     if (isAutoSized) {
    1097         5879 :         c->coilWaterFlowAutoMsg = "Yes";
    1098              :     } else {
    1099           10 :         c->coilWaterFlowAutoMsg = "No";
    1100              :     }
    1101         5889 : }
    1102              : 
    1103         6728 : 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         6728 :     int index = getIndexForOrCreateDataObjFromCoilName(state, coilName, coilType);
    1112         6728 :     auto &c(coilSelectionDataObjs[index]);
    1113         6728 :     c->coilDesEntTemp = entAirDryBulbTemp;
    1114         6728 :     c->airloopNum = curSysNum;
    1115         6728 :     doAirLoopSetup(state, index);
    1116         6728 :     c->zoneEqNum = curZoneEqNum;
    1117         6728 : }
    1118              : 
    1119         7223 : 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         7223 :     int index = getIndexForOrCreateDataObjFromCoilName(state, coilName, coilType);
    1126         7223 :     auto &c(coilSelectionDataObjs[index]);
    1127         7223 :     c->coilDesEntHumRat = entAirHumrat;
    1128         7223 : }
    1129              : 
    1130         3954 : 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         3954 :     int index = getIndexForOrCreateDataObjFromCoilName(state, coilName, coilType);
    1137         3954 :     auto &c(coilSelectionDataObjs[index]);
    1138         3954 :     c->coilDesWaterEntTemp = entWaterTemp;
    1139         3954 : }
    1140              : 
    1141         3461 : 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         3461 :     int index = getIndexForOrCreateDataObjFromCoilName(state, coilName, coilType);
    1148         3461 :     auto &c(coilSelectionDataObjs[index]);
    1149         3461 :     c->coilDesWaterLvgTemp = lvgWaterTemp;
    1150         3461 : }
    1151              : 
    1152         3461 : 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         3461 :     int index = getIndexForOrCreateDataObjFromCoilName(state, coilName, coilType);
    1159         3461 :     auto &c(coilSelectionDataObjs[index]);
    1160         3461 :     c->coilDesWaterTempDiff = CoilWaterDeltaT;
    1161         3461 : }
    1162              : 
    1163         4324 : 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         4324 :     int index = getIndexForOrCreateDataObjFromCoilName(state, coilName, coilType);
    1170         4324 :     auto &c(coilSelectionDataObjs[index]);
    1171         4324 :     c->coilDesLvgTemp = lvgAirDryBulbTemp;
    1172         4324 : }
    1173              : 
    1174         4324 : 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         4324 :     int index = getIndexForOrCreateDataObjFromCoilName(state, coilName, coilType);
    1181         4324 :     auto &c(coilSelectionDataObjs[index]);
    1182         4324 :     c->coilDesLvgHumRat = lvgAirHumRat;
    1183         4324 : }
    1184              : 
    1185        14743 : std::string PeakHrMinString(EnergyPlusData &state, const int designDay, const int timeStepAtPeak)
    1186              : {
    1187              :     return fmt::format("{}/{} {}",
    1188        14743 :                        state.dataWeather->DesDayInput(designDay).Month,
    1189        14743 :                        state.dataWeather->DesDayInput(designDay).DayOfMonth,
    1190        29486 :                        ReportCoilSelection::getTimeText(state, timeStepAtPeak));
    1191              : }
    1192              : 
    1193         2182 : 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         2182 :     auto &ZoneEqSizing(state.dataSize->ZoneEqSizing);
    1209         2182 :     auto &SysSizPeakDDNum(state.dataSize->SysSizPeakDDNum);
    1210              : 
    1211         2182 :     int index = getIndexForOrCreateDataObjFromCoilName(state, coilName, coilType);
    1212         2182 :     auto &c(coilSelectionDataObjs[index]);
    1213              :     // no this is adjusted back to ratings    c->coilTotCapAtPeak = TotalCoolingCap;
    1214         2182 :     c->coilCapFTIdealPeak = coilCapFunTempFac;
    1215         2182 :     c->coilTotCapAtPeak = TotalCoolingCap * c->coilCapFTIdealPeak;
    1216         2182 :     c->capIsAutosized = isAutoSize;
    1217         2182 :     c->minRatio = DXFlowPerCapMinRatio;
    1218         2182 :     c->maxRatio = DXFlowPerCapMaxRatio;
    1219              : 
    1220         2182 :     c->fanHeatGainIdealPeak = fanCoolLoad;
    1221         2182 :     c->airloopNum = curSysNum;
    1222         2182 :     doAirLoopSetup(state, index);
    1223         2182 :     c->zoneEqNum = curZoneEqNum;
    1224              :     //    if ( c->zoneEqNum > 0 ) doZoneEqSetup( index );
    1225         2182 :     c->oASysNum = curOASysNum;
    1226              : 
    1227         3679 :     if (curSysNum > 0 && c->zoneEqNum == 0 && allocated(state.dataSize->FinalSysSizing) && allocated(SysSizPeakDDNum) &&
    1228         1497 :         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         1497 :         if (SysSizPeakDDNum(curSysNum).SensCoolPeakDD > 0 && SysSizPeakDDNum(curSysNum).SensCoolPeakDD <= state.dataEnvrn->TotDesDays) {
    1233         1495 :             c->desDayNameAtSensPeak = state.dataWeather->DesDayInput(SysSizPeakDDNum(curSysNum).SensCoolPeakDD).Title;
    1234         2990 :             c->coilSensePeakHrMin = PeakHrMinString(state,
    1235         1495 :                                                     SysSizPeakDDNum(curSysNum).SensCoolPeakDD,
    1236         2990 :                                                     SysSizPeakDDNum(curSysNum).TimeStepAtSensCoolPk(SysSizPeakDDNum(curSysNum).SensCoolPeakDD));
    1237              :         }
    1238         1497 :         if (SysSizPeakDDNum(curSysNum).TotCoolPeakDD > 0 && SysSizPeakDDNum(curSysNum).TotCoolPeakDD <= state.dataEnvrn->TotDesDays) {
    1239         1495 :             c->desDayNameAtTotalPeak = state.dataWeather->DesDayInput(SysSizPeakDDNum(curSysNum).TotCoolPeakDD).Title;
    1240         2990 :             c->coilTotalPeakHrMin = PeakHrMinString(state,
    1241         1495 :                                                     SysSizPeakDDNum(curSysNum).TotCoolPeakDD,
    1242         2990 :                                                     SysSizPeakDDNum(curSysNum).TimeStepAtTotCoolPk(SysSizPeakDDNum(curSysNum).TotCoolPeakDD));
    1243              :         }
    1244              : 
    1245         1497 :         if (SysSizPeakDDNum(curSysNum).CoolFlowPeakDD > 0 && SysSizPeakDDNum(curSysNum).CoolFlowPeakDD <= state.dataEnvrn->TotDesDays) {
    1246         1495 :             c->desDayNameAtAirFlowPeak = state.dataWeather->DesDayInput(SysSizPeakDDNum(curSysNum).CoolFlowPeakDD).Title;
    1247         2990 :             c->airPeakHrMin = PeakHrMinString(state,
    1248         1495 :                                               SysSizPeakDDNum(curSysNum).CoolFlowPeakDD,
    1249         2990 :                                               SysSizPeakDDNum(curSysNum).TimeStepAtCoolFlowPk(SysSizPeakDDNum(curSysNum).CoolFlowPeakDD));
    1250              :         }
    1251              : 
    1252         1497 :         auto const &finalSysSizing = state.dataSize->FinalSysSizing(curSysNum);
    1253         1497 :         c->isCoilSizingForTotalLoad = (finalSysSizing.coolingPeakLoad == DataSizing::PeakLoad::TotalCooling);
    1254         1497 :         c->oaPeakTemp = finalSysSizing.OutTempAtCoolPeak;
    1255         1497 :         c->oaPeakVolFlow = finalSysSizing.DesOutAirVolFlow;
    1256         1497 :         c->oaPeakHumRat = finalSysSizing.OutHumRatAtCoolPeak;
    1257         1497 :         c->raPeakTemp = finalSysSizing.RetTempAtCoolPeak;
    1258         1497 :         c->raPeakHumRat = finalSysSizing.RetHumRatAtCoolPeak;
    1259         1497 :         c->coilSizingMethodConcurrence = static_cast<DataSizing::CoilSizingConcurrence>(finalSysSizing.SizingOption);
    1260         1497 :         c->coilSizingMethodCapacity = finalSysSizing.CoolingCapMethod;
    1261         1497 :         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         1497 :         Real64 sumT_Vdot(0.0);   // numerator for average zone temperature, zone temperature values times zone supply air volume flow rate
    1267         1497 :         Real64 sumW_Vdot(0.0);   // numerator average zone humidity ratio, zone hum rat value times zone supply air volume flow rate
    1268         1497 :         Real64 sumSensLoad(0.0); // straight total for zone design loads
    1269         1497 :         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         1497 :         int SysPeakDDnum(0);
    1273         1497 :         int SysPeakTimeStepInDay(0);
    1274         1497 :         if (finalSysSizing.coolingPeakLoad == DataSizing::PeakLoad::TotalCooling) {
    1275           18 :             SysPeakDDnum = SysSizPeakDDNum(curSysNum).TotCoolPeakDD;
    1276           18 :             if (SysPeakDDnum > 0) {
    1277           18 :                 SysPeakTimeStepInDay = SysSizPeakDDNum(curSysNum).TimeStepAtTotCoolPk(SysSizPeakDDNum(curSysNum).TotCoolPeakDD);
    1278              :             }
    1279         1479 :         } else if (finalSysSizing.coolingPeakLoad == DataSizing::PeakLoad::SensibleCooling) {
    1280         1479 :             SysPeakDDnum = SysSizPeakDDNum(curSysNum).SensCoolPeakDD;
    1281         1479 :             if (SysPeakDDnum > 0) {
    1282         1479 :                 SysPeakTimeStepInDay = SysSizPeakDDNum(curSysNum).TimeStepAtSensCoolPk(SysSizPeakDDNum(curSysNum).SensCoolPeakDD);
    1283              :             }
    1284              :         }
    1285              : 
    1286         1497 :         if (SysPeakDDnum > 0 && SysPeakTimeStepInDay > 0) {
    1287         8004 :             for (auto &z : c->zoneNum) {
    1288         6507 :                 auto const &thisCalcZoneSizing = state.dataSize->CalcZoneSizing(SysPeakDDnum, z);
    1289         6507 :                 auto const &thisFinalZoneSizing = state.dataSize->FinalZoneSizing(z);
    1290         6507 :                 Real64 mult = state.dataHeatBal->Zone(z).Multiplier * state.dataHeatBal->Zone(z).ListMultiplier;
    1291         6507 :                 Real64 Tz = thisCalcZoneSizing.CoolZoneTempSeq(SysPeakTimeStepInDay);
    1292         6507 :                 Real64 Vdot_z = thisCalcZoneSizing.CoolFlowSeq(SysPeakTimeStepInDay);
    1293         6507 :                 if (Vdot_z == 0.0) { // take value from final zone sizing
    1294           78 :                     Vdot_z = thisFinalZoneSizing.CoolMassFlow;
    1295           78 :                     if (Vdot_z == 0.0) {
    1296           78 :                         Vdot_z = finalSysSizing.DesCoolVolFlow * state.dataEnvrn->StdRhoAir / c->zoneNum.size();
    1297              :                     }
    1298              :                 }
    1299         6507 :                 Real64 Wz = thisCalcZoneSizing.CoolZoneHumRatSeq(SysPeakTimeStepInDay);
    1300         6507 :                 sumT_Vdot += Tz * Vdot_z * mult;
    1301         6507 :                 sumW_Vdot += Wz * Vdot_z * mult;
    1302         6507 :                 sumVdot += Vdot_z * mult;
    1303         6507 :                 Real64 Qdot_z = thisCalcZoneSizing.CoolLoadSeq(SysPeakTimeStepInDay);
    1304         6507 :                 if (Qdot_z > 0.0) {
    1305         6429 :                     sumSensLoad += Qdot_z * mult;
    1306              :                 } else {
    1307           78 :                     sumSensLoad += thisFinalZoneSizing.DesCoolLoad * mult;
    1308              :                 }
    1309         1497 :             }
    1310              :         }
    1311         1497 :         if (c->zoneNum.size() > 0 && sumVdot > 0.0) {
    1312         1497 :             c->rmPeakTemp = (sumT_Vdot / sumVdot);
    1313         1497 :             c->rmPeakHumRat = (sumW_Vdot / sumVdot);
    1314         2994 :             c->rmPeakRelHum =
    1315         1497 :                 Psychrometrics::PsyRhFnTdbWPb(state, c->rmPeakTemp, c->rmPeakHumRat, state.dataEnvrn->StdBaroPress) * 100.0; // convert to percentage
    1316              :         } else {
    1317            0 :             c->rmPeakTemp = -999.0;
    1318            0 :             c->rmPeakHumRat = -999.0;
    1319            0 :             c->rmPeakRelHum = -999.0;
    1320              :         }
    1321              : 
    1322         1497 :         if (c->coilSizingMethodConcurrence == DataSizing::CoilSizingConcurrence::Coincident) {
    1323          202 :             c->rmSensibleAtPeak = finalSysSizing.SysCoolCoinSpaceSens;
    1324         1295 :         } else if (c->coilSizingMethodConcurrence == DataSizing::CoilSizingConcurrence::NonCoincident) {
    1325         1295 :             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         1497 :         if (curOASysNum > 0) {                 // then this system coil is part of OA system
    1332           61 :             if (c->coilDesEntTemp == -999.0) { // don't overwrite if already set directly
    1333            0 :                 c->coilDesEntTemp = finalSysSizing.OutTempAtCoolPeak;
    1334              :             }
    1335           61 :             if (c->coilDesEntHumRat == -999.0) { // don't overwrite if already set directly
    1336            0 :                 c->coilDesEntHumRat = finalSysSizing.OutHumRatAtCoolPeak;
    1337              :             }
    1338          122 :             c->coilDesEntWetBulb = Psychrometrics::PsyTwbFnTdbWPb(
    1339           61 :                 state, c->coilDesEntTemp, c->coilDesEntHumRat, state.dataEnvrn->StdBaroPress, "ReportCoilSelection::setCoilCoolingCapacity");
    1340           61 :             c->coilDesEntEnth = Psychrometrics::PsyHFnTdbW(c->coilDesEntTemp, c->coilDesEntHumRat);
    1341           61 :             if (c->coilDesLvgTemp == -999.0) { // don't overwrite if already set directly
    1342            0 :                 c->coilDesLvgTemp = finalSysSizing.PrecoolTemp;
    1343              :             }
    1344           61 :             if (c->coilDesLvgHumRat == -999.0) { // don't overwrite if already set directly
    1345            0 :                 c->coilDesLvgHumRat = finalSysSizing.PrecoolHumRat;
    1346              :             }
    1347          122 :             c->coilDesLvgWetBulb = Psychrometrics::PsyTwbFnTdbWPb(
    1348           61 :                 state, c->coilDesLvgTemp, c->coilDesLvgHumRat, state.dataEnvrn->StdBaroPress, "ReportCoilSelection::setCoilCoolingCapacity");
    1349           61 :             c->coilDesLvgEnth = Psychrometrics::PsyHFnTdbW(c->coilDesLvgTemp, c->coilDesLvgHumRat);
    1350              : 
    1351              :         } else {                               // part of main air loop
    1352         1436 :             if (c->coilDesEntTemp == -999.0) { // don't overwrite if already set directly
    1353            0 :                 c->coilDesEntTemp = finalSysSizing.MixTempAtCoolPeak;
    1354              :             }
    1355         1436 :             if (c->coilDesEntHumRat == -999.0) { // don't overwrite if already set directly
    1356            0 :                 c->coilDesEntHumRat = finalSysSizing.MixHumRatAtCoolPeak;
    1357              :             }
    1358         2872 :             c->coilDesEntWetBulb = Psychrometrics::PsyTwbFnTdbWPb(
    1359         1436 :                 state, c->coilDesEntTemp, c->coilDesEntHumRat, state.dataEnvrn->StdBaroPress, "ReportCoilSelection::setCoilCoolingCapacity");
    1360         1436 :             c->coilDesEntEnth = Psychrometrics::PsyHFnTdbW(c->coilDesEntTemp, c->coilDesEntHumRat);
    1361         1436 :             if (c->coilDesLvgTemp == -999.0) {
    1362            0 :                 c->coilDesLvgTemp = finalSysSizing.CoolSupTemp;
    1363              :             }
    1364         1436 :             if (c->coilDesLvgHumRat == -999.0) { // don't overwrite if already set directly
    1365            0 :                 c->coilDesLvgHumRat = finalSysSizing.CoolSupHumRat;
    1366              :             }
    1367         2872 :             c->coilDesLvgWetBulb = Psychrometrics::PsyTwbFnTdbWPb(
    1368         1436 :                 state, c->coilDesLvgTemp, c->coilDesLvgHumRat, state.dataEnvrn->StdBaroPress, "ReportCoilSelection::setCoilCoolingCapacity");
    1369         1436 :             c->coilDesLvgEnth = Psychrometrics::PsyHFnTdbW(c->coilDesLvgTemp, c->coilDesLvgHumRat);
    1370         1436 :             if (state.dataAirSystemsData->PrimaryAirSystems(curSysNum).NumOACoolCoils > 0) { // there is precooling of the OA stream
    1371           57 :                 c->oaPretreated = true;
    1372              :             }
    1373              :         }
    1374              : 
    1375          685 :     } else if (curZoneEqNum > 0 && allocated(state.dataSize->FinalZoneSizing)) {
    1376          503 :         c->zoneNum.resize(1);
    1377          503 :         c->zoneName.resize(1);
    1378          503 :         c->zoneNum[0] = curZoneEqNum;
    1379          503 :         if (allocated(state.dataZoneEquip->ZoneEquipConfig)) {
    1380          503 :             c->zoneName[0] = state.dataZoneEquip->ZoneEquipConfig(curZoneEqNum).ZoneName;
    1381              :         }
    1382          503 :         auto const &thisFinalZoneSizing = state.dataSize->FinalZoneSizing(curZoneEqNum);
    1383          503 :         c->desDayNameAtSensPeak = thisFinalZoneSizing.CoolDesDay;
    1384          503 :         c->oaPeakTemp = thisFinalZoneSizing.OutTempAtCoolPeak;
    1385          503 :         c->oaPeakHumRat = thisFinalZoneSizing.OutHumRatAtCoolPeak;
    1386          503 :         c->raPeakTemp = thisFinalZoneSizing.ZoneTempAtCoolPeak;
    1387          503 :         c->raPeakHumRat = thisFinalZoneSizing.ZoneHumRatAtCoolPeak;
    1388          503 :         c->rmPeakTemp = thisFinalZoneSizing.ZoneTempAtCoolPeak;
    1389          503 :         c->rmPeakHumRat = thisFinalZoneSizing.ZoneHumRatAtCoolPeak;
    1390         1006 :         c->rmPeakRelHum =
    1391          503 :             Psychrometrics::PsyRhFnTdbWPb(state, c->rmPeakTemp, c->rmPeakHumRat, state.dataEnvrn->StdBaroPress) * 100.0; // convert to percentage
    1392          503 :         if (thisFinalZoneSizing.CoolDDNum > 0 && thisFinalZoneSizing.CoolDDNum <= state.dataEnvrn->TotDesDays) {
    1393          494 :             c->coilSensePeakHrMin = PeakHrMinString(state, thisFinalZoneSizing.CoolDDNum, thisFinalZoneSizing.TimeStepNumAtCoolMax);
    1394          494 :             c->airPeakHrMin = PeakHrMinString(state, thisFinalZoneSizing.CoolDDNum, thisFinalZoneSizing.TimeStepNumAtCoolMax);
    1395              :         }
    1396              : 
    1397          503 :         c->rmSensibleAtPeak = thisFinalZoneSizing.DesCoolLoad;
    1398              : 
    1399          503 :         if (ZoneEqSizing(curZoneEqNum).OAVolFlow > 0.0) {
    1400          267 :             c->oaPeakVolFlow = ZoneEqSizing(curZoneEqNum).OAVolFlow;
    1401              :         } else {
    1402          236 :             c->oaPeakVolFlow = 0.0;
    1403              :         }
    1404              :         // coil entering conditions depend on the type of zone equipment involved
    1405              :         // set typeof_Coil integer
    1406          503 :         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          495 :         } 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          332 :         } else if (state.dataSize->ZoneEqDXCoil) {
    1421          263 :             if (ZoneEqSizing(curZoneEqNum).OAVolFlow > 0.0) {
    1422          206 :                 if (c->coilDesEntTemp == -999.0) { // don't overwrite if already set directly by setCoilEntAirTemp
    1423            0 :                     c->coilDesEntTemp = thisFinalZoneSizing.DesCoolCoilInTemp;
    1424              :                 }
    1425          206 :                 if (c->coilDesEntHumRat == -999.0) { // don't overwrite if already set directly by setCoilEntAirHumRat
    1426            0 :                     c->coilDesEntHumRat = thisFinalZoneSizing.DesCoolCoilInHumRat;
    1427              :                 }
    1428              :             } else {
    1429           57 :                 if (c->coilDesEntTemp == -999.0) { // don't overwrite if already set directly by setCoilEntAirTemp
    1430            0 :                     c->coilDesEntTemp = thisFinalZoneSizing.ZoneTempAtCoolPeak;
    1431              :                 }
    1432           57 :                 if (c->coilDesEntHumRat == -999.0) { // don't overwrite if already set directly by setCoilEntAirHumRat
    1433            0 :                     c->coilDesEntHumRat = thisFinalZoneSizing.ZoneHumRatAtCoolPeak;
    1434              :                 }
    1435              :             }
    1436              :         } else {
    1437           69 :             if (c->coilDesEntTemp == -999.0) { // don't overwrite if already set directly by setCoilEntAirTemp
    1438            0 :                 c->coilDesEntTemp = thisFinalZoneSizing.DesCoolCoilInTemp;
    1439              :             }
    1440           69 :             if (c->coilDesEntHumRat == -999.0) { // don't overwrite if already set directly by setCoilEntAirHumRat
    1441            0 :                 c->coilDesEntHumRat = thisFinalZoneSizing.DesCoolCoilInHumRat;
    1442              :             }
    1443              :         }
    1444              : 
    1445          503 :         if (c->coilDesLvgTemp == -999.0) { // don't overwrite if already set directly by setCoilLvgAirTemp
    1446           85 :             c->coilDesLvgTemp = thisFinalZoneSizing.CoolDesTemp;
    1447              :         }
    1448          503 :         if (c->coilDesLvgHumRat == -999.0) { // don't overwrite if already set directly by setCoilLvgAirHumRat
    1449           85 :             c->coilDesLvgHumRat = thisFinalZoneSizing.CoolDesHumRat;
    1450              :         }
    1451         1006 :         c->coilDesLvgWetBulb = Psychrometrics::PsyTwbFnTdbWPb(
    1452          503 :             state, c->coilDesLvgTemp, c->coilDesLvgHumRat, state.dataEnvrn->StdBaroPress, "ReportCoilSelection::setCoilCoolingCapacity");
    1453          503 :         c->coilDesLvgEnth = Psychrometrics::PsyHFnTdbW(c->coilDesLvgTemp, c->coilDesLvgHumRat);
    1454          182 :     } 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         2182 :     c->cpMoistAir = Psychrometrics::PsyCpAirFnW(c->coilDesEntHumRat);
    1495         2182 : }
    1496              : 
    1497         4968 : 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         4968 :     int index = getIndexForOrCreateDataObjFromCoilName(state, coilName, coilType);
    1513         4968 :     auto &c(coilSelectionDataObjs[index]);
    1514         4968 :     c->capIsAutosized = isAutoSize;
    1515         4968 :     c->coilCapFTIdealPeak = coilCapFunTempFac;
    1516         4968 :     c->coilTotCapAtPeak = totalHeatingCap * c->coilCapFTIdealPeak;
    1517         4968 :     c->minRatio = DXFlowPerCapMinRatio;
    1518         4968 :     c->maxRatio = DXFlowPerCapMaxRatio;
    1519              : 
    1520         4968 :     c->fanHeatGainIdealPeak = fanHeatGain;
    1521         4968 :     c->airloopNum = curSysNum;
    1522         4968 :     doAirLoopSetup(state, index);
    1523         4968 :     c->zoneEqNum = curZoneEqNum;
    1524              :     //    if ( c->zoneEqNum > 0 ) doZoneEqSetup( index );
    1525         4968 :     if (curSysNum > 0 && c->zoneEqNum == 0 && curSysNum <= int(state.dataSize->FinalSysSizing.size())) {
    1526         1652 :         auto &finalSysSizing = state.dataSize->FinalSysSizing(curSysNum);
    1527         1652 :         c->desDayNameAtSensPeak = finalSysSizing.HeatDesDay;
    1528              : 
    1529         1652 :         c->oaPeakTemp = finalSysSizing.HeatOutTemp;
    1530         1652 :         c->oaPeakHumRat = finalSysSizing.HeatOutHumRat;
    1531         1652 :         c->oaPeakVolFlow = finalSysSizing.DesOutAirVolFlow;
    1532         1652 :         c->raPeakTemp = finalSysSizing.HeatRetTemp;
    1533         1652 :         c->raPeakHumRat = finalSysSizing.HeatRetHumRat;
    1534         1652 :         c->coilSizingMethodConcurrence = static_cast<DataSizing::CoilSizingConcurrence>(finalSysSizing.SizingOption);
    1535         1652 :         c->coilSizingMethodCapacity = finalSysSizing.HeatingCapMethod;
    1536         1652 :         c->coilSizingMethodAirFlow = finalSysSizing.ScaleHeatSAFMethod;
    1537              : 
    1538              :         // Central Heating Coils are always sized at the conditions at the peak Sensible Heating Load
    1539         1652 :         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         1652 :         Real64 sumT_Vdot(0.0); // numerator for average zone temperature, zone temperature values times zone air volume
    1546         1652 :         Real64 sumW_Vdot(0.0); // numerator average zone humidity ratio, zone hum rat value times zone air volume
    1547         1652 :         Real64 sumLoad(0.0);   // straight total for zone design loads
    1548         1652 :         Real64 sumVdot(0.0);   // denominator for zone-volume weighted averages
    1549              : 
    1550         1652 :         int SysPeakDDnum = finalSysSizing.HeatDDNum;
    1551         1652 :         int SysPeakTimeStepInDay = finalSysSizing.SysHeatCoilTimeStepPk;
    1552         1652 :         if (SysPeakDDnum > 0 && SysPeakTimeStepInDay > 0) { // may be zero if no peak found because of zero system load
    1553        10023 :             for (auto &z : c->zoneNum) {
    1554         8374 :                 auto const &thisCalcZoneSizing = state.dataSize->CalcZoneSizing(SysPeakDDnum, z);
    1555         8374 :                 auto const &thisFinalZoneSizing = state.dataSize->FinalZoneSizing(z);
    1556         8374 :                 Real64 mult = state.dataHeatBal->Zone(z).Multiplier * state.dataHeatBal->Zone(z).ListMultiplier;
    1557         8374 :                 Real64 Tz = thisCalcZoneSizing.HeatZoneTempSeq(SysPeakTimeStepInDay);
    1558         8374 :                 Real64 Vdot_z = thisCalcZoneSizing.HeatFlowSeq(SysPeakTimeStepInDay);
    1559         8374 :                 if (Vdot_z == 0.0) { // take value from final zone sizing
    1560          977 :                     Vdot_z = thisFinalZoneSizing.HeatMassFlow;
    1561          977 :                     if (Vdot_z == 0.0) {
    1562          977 :                         Vdot_z = finalSysSizing.DesHeatVolFlow * state.dataEnvrn->StdRhoAir / c->zoneNum.size();
    1563              :                     }
    1564              :                 }
    1565         8374 :                 Real64 Wz = thisCalcZoneSizing.HeatZoneHumRatSeq(SysPeakTimeStepInDay);
    1566         8374 :                 sumT_Vdot += Tz * Vdot_z * mult;
    1567         8374 :                 sumW_Vdot += Wz * Vdot_z * mult;
    1568         8374 :                 sumVdot += Vdot_z * mult;
    1569         8374 :                 Real64 Qdot_z = thisCalcZoneSizing.HeatLoadSeq(SysPeakTimeStepInDay);
    1570         8374 :                 if (Qdot_z > 0.0) {
    1571         7397 :                     sumLoad += Qdot_z * mult;
    1572              :                 } else {
    1573          977 :                     sumLoad += thisFinalZoneSizing.DesHeatLoad * mult;
    1574              :                 }
    1575         1649 :             }
    1576              :         }
    1577              : 
    1578         1652 :         if (c->zoneNum.size() > 0 && sumVdot > 0.0) {
    1579         1649 :             c->rmPeakTemp = (sumT_Vdot / sumVdot);
    1580         1649 :             c->rmPeakHumRat = (sumW_Vdot / sumVdot);
    1581         3298 :             c->rmPeakRelHum =
    1582         1649 :                 Psychrometrics::PsyRhFnTdbWPb(state, c->rmPeakTemp, c->rmPeakHumRat, state.dataEnvrn->StdBaroPress) * 100.0; // convert to percentage
    1583              :         } else {
    1584            3 :             c->rmPeakTemp = -999.0;
    1585            3 :             c->rmPeakHumRat = -999.0;
    1586            3 :             c->rmPeakRelHum = -999.0;
    1587              :         }
    1588              : 
    1589         1652 :         if (c->coilSizingMethodConcurrence == DataSizing::CoilSizingConcurrence::Coincident) {
    1590          165 :             c->rmSensibleAtPeak = finalSysSizing.SysHeatCoinSpaceSens;
    1591         1487 :         } else if (c->coilSizingMethodConcurrence == DataSizing::CoilSizingConcurrence::NonCoincident) {
    1592         1487 :             c->rmSensibleAtPeak = sumLoad;
    1593              :         }
    1594              : 
    1595         1652 :         if (finalSysSizing.HeatDDNum > 0 && finalSysSizing.HeatDDNum <= state.dataEnvrn->TotDesDays) {
    1596         1649 :             c->coilSensePeakHrMin = PeakHrMinString(state, finalSysSizing.HeatDDNum, finalSysSizing.SysHeatCoilTimeStepPk);
    1597              : 
    1598         1649 :             c->airPeakHrMin = PeakHrMinString(state, finalSysSizing.HeatDDNum, finalSysSizing.SysHeatAirTimeStepPk);
    1599              : 
    1600         1649 :             c->desDayNameAtAirFlowPeak = state.dataWeather->DesDayInput(finalSysSizing.HeatDDNum).Title;
    1601              :         }
    1602              : 
    1603              :         // now set Coil Ent And Lvg Conditions
    1604              : 
    1605         1652 :         if (curOASysNum > 0) { // then this system coil is part of OA system
    1606           61 :             if (c->coilDesEntTemp == -999.0) {
    1607            0 :                 c->coilDesEntTemp = finalSysSizing.HeatOutTemp;
    1608              :             }
    1609           61 :             if (c->coilDesEntHumRat == -999.0) {
    1610            0 :                 c->coilDesEntHumRat = finalSysSizing.HeatOutHumRat;
    1611              :             }
    1612          122 :             c->coilDesEntWetBulb = Psychrometrics::PsyTwbFnTdbWPb(
    1613           61 :                 state, c->coilDesEntTemp, c->coilDesEntHumRat, state.dataEnvrn->StdBaroPress, "ReportCoilSelection::setCoilHeatingCapacity");
    1614           61 :             c->coilDesEntEnth = Psychrometrics::PsyHFnTdbW(c->coilDesEntTemp, c->coilDesEntHumRat);
    1615           61 :             if (c->coilDesLvgTemp == -999.0) {
    1616            0 :                 c->coilDesLvgTemp = finalSysSizing.PreheatTemp;
    1617              :             }
    1618           61 :             if (c->coilDesLvgHumRat == -999.0) {
    1619            0 :                 c->coilDesLvgHumRat = finalSysSizing.PreheatHumRat;
    1620              :             }
    1621          122 :             c->coilDesLvgWetBulb = Psychrometrics::PsyTwbFnTdbWPb(
    1622           61 :                 state, c->coilDesLvgTemp, c->coilDesLvgHumRat, state.dataEnvrn->StdBaroPress, "ReportCoilSelection::setCoilHeatingCapacity");
    1623           61 :             c->coilDesLvgEnth = Psychrometrics::PsyHFnTdbW(c->coilDesLvgTemp, c->coilDesLvgHumRat);
    1624              : 
    1625              :         } else { // part of main air loop
    1626         1591 :             if (c->coilDesEntTemp == -999.0) {
    1627          103 :                 c->coilDesEntTemp = finalSysSizing.HeatMixTemp;
    1628              :             }
    1629         1591 :             if (c->coilDesEntHumRat == -999.0) {
    1630          103 :                 c->coilDesEntHumRat = finalSysSizing.HeatMixHumRat;
    1631              :             }
    1632         3182 :             c->coilDesEntWetBulb = Psychrometrics::PsyTwbFnTdbWPb(
    1633         1591 :                 state, c->coilDesEntTemp, c->coilDesEntHumRat, state.dataEnvrn->StdBaroPress, "ReportCoilSelection::setCoilHeatingCapacity");
    1634         1591 :             c->coilDesEntEnth = Psychrometrics::PsyHFnTdbW(c->coilDesEntTemp, c->coilDesEntHumRat);
    1635         1591 :             if (c->coilDesLvgTemp == -999.0) {
    1636          103 :                 c->coilDesLvgTemp = finalSysSizing.HeatSupTemp;
    1637              :             }
    1638         1591 :             if (c->coilDesLvgHumRat == -999.0) {
    1639          103 :                 c->coilDesLvgHumRat = finalSysSizing.HeatSupHumRat;
    1640              :             }
    1641         3182 :             c->coilDesLvgWetBulb = Psychrometrics::PsyTwbFnTdbWPb(
    1642         1591 :                 state, c->coilDesLvgTemp, c->coilDesLvgHumRat, state.dataEnvrn->StdBaroPress, "ReportCoilSelection::setCoilHeatingCapacity");
    1643         1591 :             c->coilDesLvgEnth = Psychrometrics::PsyHFnTdbW(c->coilDesLvgTemp, c->coilDesLvgHumRat);
    1644         1591 :             if (state.dataAirSystemsData->PrimaryAirSystems(curSysNum).NumOAHeatCoils > 0) { // there is preHeating of the OA stream
    1645           57 :                 c->oaPretreated = true;
    1646              :             }
    1647              :         }
    1648              : 
    1649         3316 :     } else if (curZoneEqNum > 0 && allocated(state.dataSize->FinalZoneSizing)) {
    1650         2986 :         auto const &finalZoneSizing = state.dataSize->FinalZoneSizing(curZoneEqNum);
    1651         2986 :         c->zoneNum.resize(1);
    1652         2986 :         c->zoneName.resize(1);
    1653         2986 :         c->zoneNum[0] = curZoneEqNum;
    1654         2986 :         if (allocated(state.dataZoneEquip->ZoneEquipConfig)) {
    1655         2986 :             c->zoneName[0] = state.dataZoneEquip->ZoneEquipConfig(curZoneEqNum).ZoneName;
    1656              :         }
    1657         2986 :         c->desDayNameAtSensPeak = finalZoneSizing.HeatDesDay;
    1658         2986 :         c->oaPeakTemp = finalZoneSizing.OutTempAtHeatPeak;
    1659         2986 :         c->oaPeakHumRat = finalZoneSizing.OutHumRatAtHeatPeak;
    1660         2986 :         c->raPeakTemp = finalZoneSizing.ZoneRetTempAtHeatPeak;
    1661         2986 :         c->raPeakHumRat = finalZoneSizing.ZoneHumRatAtHeatPeak;
    1662         2986 :         c->rmPeakTemp = finalZoneSizing.ZoneTempAtHeatPeak;
    1663         2986 :         c->rmPeakHumRat = finalZoneSizing.ZoneHumRatAtHeatPeak;
    1664         5972 :         c->rmPeakRelHum =
    1665         2986 :             Psychrometrics::PsyRhFnTdbWPb(state, c->rmPeakTemp, c->rmPeakHumRat, state.dataEnvrn->StdBaroPress) * 100.0; // convert to percentage
    1666         2986 :         if (finalZoneSizing.HeatDDNum > 0 && finalZoneSizing.HeatDDNum <= state.dataEnvrn->TotDesDays) {
    1667         2986 :             c->coilSensePeakHrMin = PeakHrMinString(state, finalZoneSizing.HeatDDNum, finalZoneSizing.TimeStepNumAtHeatMax);
    1668         2986 :             c->airPeakHrMin = PeakHrMinString(state, finalZoneSizing.HeatDDNum, finalZoneSizing.TimeStepNumAtHeatMax);
    1669              :         }
    1670         2986 :         c->desDayNameAtAirFlowPeak = finalZoneSizing.HeatDesDay;
    1671              : 
    1672         2986 :         c->rmSensibleAtPeak = finalZoneSizing.DesHeatLoad;
    1673              : 
    1674         2986 :         auto const &zoneEqSizing = state.dataSize->ZoneEqSizing(curZoneEqNum);
    1675         2986 :         if (zoneEqSizing.OAVolFlow > 0.0) {
    1676          283 :             c->oaPeakVolFlow = zoneEqSizing.OAVolFlow;
    1677         2703 :         } else if (zoneEqSizing.ATMixerVolFlow > 0.0) {
    1678           48 :             c->oaPeakVolFlow = zoneEqSizing.ATMixerVolFlow;
    1679              :         } else {
    1680         2655 :             c->oaPeakVolFlow = 0.0;
    1681              :         }
    1682              :         // coil entering conditions depend on the type of zone equipment involved
    1683              :         // set typeof_Coil integer
    1684         2986 :         if (state.dataSize->TermUnitIU) {      // an unpowered induction terminal unit
    1685            4 :             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         2982 :         } else if (state.dataSize->TermUnitSingDuct) {
    1691         2165 :             if (c->coilDesEntTemp == -999.0) { // don't overwrite if already set directly by setCoilEntAirTemp
    1692           14 :                 auto const &thisTermUnitFinalZoneSizing = state.dataSize->TermUnitFinalZoneSizing(state.dataSize->CurTermUnitSizingNum);
    1693           14 :                 c->coilDesEntTemp = thisTermUnitFinalZoneSizing.DesHeatCoilInTempTU;
    1694           14 :                 c->coilDesEntHumRat = thisTermUnitFinalZoneSizing.DesHeatCoilInHumRatTU;
    1695              :             }
    1696          817 :         } else if (state.dataSize->TermUnitPIU) {
    1697           57 :             auto const &thisTermUnitSizing = state.dataSize->TermUnitSizing(state.dataSize->CurTermUnitSizingNum);
    1698           57 :             Real64 MinPriFlowFrac = thisTermUnitSizing.MinPriFlowFrac;
    1699           57 :             if (thisTermUnitSizing.InducesPlenumAir) {
    1700           19 :                 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           38 :                 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          760 :         } else if (state.dataSize->ZoneEqFanCoil) {
    1717           82 :             if (c->coilDesEntTemp == -999.0) { // don't overwrite if already set directly by setCoilEntAirTemp
    1718            0 :                 Real64 desOAFlowFrac = 0.0;
    1719            0 :                 if (zoneEqSizing.OAVolFlow > 0.0 && finalZoneSizing.DesHeatMassFlow > 0.0) {
    1720            0 :                     desOAFlowFrac = std::min(state.dataEnvrn->StdRhoAir * zoneEqSizing.OAVolFlow / finalZoneSizing.DesHeatMassFlow, 1.0);
    1721              :                 } else {
    1722            0 :                     desOAFlowFrac = finalZoneSizing.DesHeatOAFlowFrac;
    1723              :                 }
    1724            0 :                 c->coilDesEntTemp = desOAFlowFrac * finalZoneSizing.OutTempAtHeatPeak + (1.0 - desOAFlowFrac) * finalZoneSizing.ZoneTempAtHeatPeak;
    1725            0 :                 c->coilDesEntHumRat =
    1726            0 :                     desOAFlowFrac * finalZoneSizing.OutHumRatAtHeatPeak + (1.0 - desOAFlowFrac) * finalZoneSizing.ZoneHumRatAtHeatPeak;
    1727              :             }
    1728          678 :         } else if (state.dataSize->ZoneEqDXCoil) {
    1729          588 :             if (zoneEqSizing.OAVolFlow > 0.0) {
    1730          236 :                 if (c->coilDesEntTemp == -999.0) { // don't overwrite if already set directly by setCoilEntAirTemp
    1731           90 :                     c->coilDesEntTemp = finalZoneSizing.DesHeatCoilInTemp;
    1732              :                 }
    1733          236 :                 if (c->coilDesEntHumRat == -999.0) { // don't overwrite if already set directly by setCoilEntAirHumRat
    1734           90 :                     c->coilDesEntHumRat = finalZoneSizing.DesHeatCoilInHumRat;
    1735              :                 }
    1736              :             } else {
    1737          352 :                 if (c->coilDesEntTemp == -999.0) { // don't overwrite if already set directly by setCoilEntAirTemp
    1738          329 :                     c->coilDesEntTemp = finalZoneSizing.ZoneTempAtHeatPeak;
    1739              :                 }
    1740          352 :                 if (c->coilDesEntHumRat == -999.0) { // don't overwrite if already set directly by setCoilEntAirHumRat
    1741          329 :                     c->coilDesEntHumRat = finalZoneSizing.ZoneHumRatAtHeatPeak;
    1742              :                 }
    1743              :             }
    1744              :         } else {
    1745           90 :             if (c->coilDesEntTemp == -999.0) { // don't overwrite if already set directly by setCoilEntAirTemp
    1746           17 :                 c->coilDesEntTemp = finalZoneSizing.DesHeatCoilInTemp;
    1747              :             }
    1748           90 :             if (c->coilDesEntHumRat == -999.0) { // don't overwrite if already set directly by setCoilEntAirHumRat
    1749           17 :                 c->coilDesEntHumRat = finalZoneSizing.DesHeatCoilInHumRat;
    1750              :             }
    1751              :         }
    1752              : 
    1753         2986 :         if (c->coilDesEntTemp > -999.0 && c->coilDesEntHumRat > -999.0) {
    1754         5970 :             c->coilDesEntWetBulb = Psychrometrics::PsyTwbFnTdbWPb(
    1755         2985 :                 state, c->coilDesEntTemp, c->coilDesEntHumRat, state.dataEnvrn->StdBaroPress, "ReportCoilSelection::setCoilHeatingCapacity");
    1756         2985 :             c->coilDesEntEnth = Psychrometrics::PsyHFnTdbW(c->coilDesEntTemp, c->coilDesEntHumRat);
    1757              :         }
    1758              : 
    1759         2986 :         if (c->coilDesLvgTemp == -999.0) { // don't overwrite if already set directly by setCoilLvgAirTemp
    1760         2448 :             c->coilDesLvgTemp = finalZoneSizing.HeatDesTemp;
    1761              :         }
    1762         2986 :         if (c->coilDesLvgHumRat == -999.0) { // don't overwrite if already set directly by setCoilLvgAirHumRat
    1763         2448 :             c->coilDesLvgHumRat = finalZoneSizing.HeatDesHumRat;
    1764              :         }
    1765         5972 :         c->coilDesLvgWetBulb = Psychrometrics::PsyTwbFnTdbWPb(
    1766         2986 :             state, c->coilDesLvgTemp, c->coilDesLvgHumRat, state.dataEnvrn->StdBaroPress, "ReportCoilSelection::setCoilHeatingCapacity");
    1767         2986 :         c->coilDesLvgEnth = Psychrometrics::PsyHFnTdbW(c->coilDesLvgTemp, c->coilDesLvgHumRat);
    1768          330 :     } else if (curOASysNum > 0 && c->airloopNum > int(state.dataSize->FinalSysSizing.size())) {
    1769            7 :         if (!state.dataAirLoopHVACDOAS->airloopDOAS.empty()) {
    1770            1 :             c->oASysNum = curOASysNum; // where should this get set? It's -999 here.
    1771            1 :             int DOASSysNum = state.dataAirLoop->OutsideAirSys(curOASysNum).AirLoopDOASNum;
    1772            1 :             c->coilDesEntTemp = state.dataAirLoopHVACDOAS->airloopDOAS[DOASSysNum].HeatOutTemp;
    1773            1 :             c->coilDesEntHumRat = state.dataAirLoopHVACDOAS->airloopDOAS[DOASSysNum].HeatOutHumRat;
    1774            1 :             if (c->coilDesEntTemp > -999.0 && c->coilDesEntHumRat > -999.0) {
    1775            2 :                 c->coilDesEntWetBulb = Psychrometrics::PsyTwbFnTdbWPb(
    1776            1 :                     state, c->coilDesEntTemp, c->coilDesEntHumRat, state.dataEnvrn->StdBaroPress, "ReportCoilSelection::setCoilHeatingCapacity");
    1777            1 :                 c->coilDesEntEnth = Psychrometrics::PsyHFnTdbW(c->coilDesEntTemp, c->coilDesEntHumRat);
    1778              :             }
    1779            1 :             c->coilDesLvgTemp = state.dataAirLoopHVACDOAS->airloopDOAS[DOASSysNum].PreheatTemp;
    1780            1 :             c->coilDesLvgHumRat = state.dataAirLoopHVACDOAS->airloopDOAS[DOASSysNum].PreheatHumRat;
    1781            1 :             if (c->coilDesLvgTemp > -999.0 && c->coilDesLvgHumRat > -999.0) {
    1782            2 :                 c->coilDesLvgWetBulb = Psychrometrics::PsyTwbFnTdbWPb(
    1783            1 :                     state, c->coilDesLvgTemp, c->coilDesLvgHumRat, state.dataEnvrn->StdBaroPress, "ReportCoilSelection::setCoilHeatingCapacity");
    1784            1 :                 c->coilDesLvgEnth = Psychrometrics::PsyHFnTdbW(c->coilDesLvgTemp, c->coilDesLvgHumRat);
    1785              :             }
    1786            1 :             DataSizing::SizingConcurrence sizMethod = DataSizing::SizingConcurrence::Invalid;
    1787            1 :             bool sizMethodsAreTheSame = true;
    1788            6 :             for (int airLoopNum = 0; airLoopNum < state.dataAirLoopHVACDOAS->airloopDOAS[DOASSysNum].NumOfAirLoops; ++airLoopNum) {
    1789            5 :                 int actualAirLoopNum = state.dataAirLoopHVACDOAS->airloopDOAS[DOASSysNum].m_AirLoopNum[airLoopNum];
    1790            5 :                 if (airLoopNum == 0) {
    1791            1 :                     sizMethod = state.dataSize->FinalSysSizing(actualAirLoopNum).SizingOption;
    1792              :                 } else {
    1793            4 :                     if (sizMethod != state.dataSize->FinalSysSizing(actualAirLoopNum).SizingOption) {
    1794            0 :                         sizMethodsAreTheSame = false;
    1795              :                     }
    1796              :                 }
    1797              :             }
    1798            1 :             if (sizMethodsAreTheSame) {
    1799            1 :                 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         4968 :     if (state.dataSize->DataCoilIsSuppHeater) {
    1809          435 :         c->isSupplementalHeater = true;
    1810              :     }
    1811              :     // some heating coils only use this routine, so set air flow if not yet set
    1812         4968 :     if (c->coilDesVolFlow <= 0.0) {
    1813          854 :         if (state.dataSize->DataFlowUsedForSizing > 0.0) { // flow has been set in global, so use it
    1814           63 :             c->coilDesVolFlow = state.dataSize->DataFlowUsedForSizing;
    1815          791 :         } else if (curZoneEqNum > 0 && allocated(state.dataSize->FinalZoneSizing)) {
    1816          365 :             auto const &finalZoneSizing = state.dataSize->FinalZoneSizing(curZoneEqNum);
    1817          365 :             if (finalZoneSizing.DesHeatMassFlow >= HVAC::SmallMassFlow) {
    1818          355 :                 c->coilDesMassFlow = finalZoneSizing.DesHeatMassFlow;
    1819          355 :                 c->coilDesVolFlow = c->coilDesMassFlow / state.dataEnvrn->StdRhoAir;
    1820              :             }
    1821          426 :         } else if (curSysNum > 0 && curSysNum <= int(state.dataSize->FinalSysSizing.size())) {
    1822          134 :             auto const &finalSysSizing = state.dataSize->FinalSysSizing(curSysNum);
    1823          134 :             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          134 :                 if (state.dataSize->DataFlowUsedForSizing > 0.0) {
    1834            0 :                     c->coilDesVolFlow = state.dataSize->DataFlowUsedForSizing;
    1835          134 :                 } else if (curSysNum > 0 && allocated(state.dataSize->UnitarySysEqSizing)) {
    1836          134 :                     auto const &unitarySysEqSizing = state.dataSize->UnitarySysEqSizing(curSysNum);
    1837          134 :                     if (unitarySysEqSizing.AirFlow) {
    1838           32 :                         c->coilDesVolFlow = unitarySysEqSizing.AirVolFlow;
    1839          102 :                     } 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          854 :         c->coilDesMassFlow = c->coilDesVolFlow * state.dataEnvrn->StdRhoAir;
    1866              :     }
    1867              : 
    1868              :     // calc sensible capacity from inlet outlet
    1869         4968 :     c->cpMoistAir = Psychrometrics::PsyCpAirFnW(c->coilDesLvgHumRat);
    1870              :     // this is not generally correct but okay for heating coils
    1871         4968 :     c->coilSensCapAtPeak = std::abs(c->cpMoistAir * c->coilDesMassFlow * (c->coilDesLvgTemp - c->coilDesEntTemp));
    1872         4968 :     c->coilSensCapAtPeak = min(c->coilSensCapAtPeak, c->coilTotCapAtPeak);
    1873         4968 : }
    1874              : 
    1875          596 : 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          596 :     int index = getIndexForOrCreateDataObjFromCoilName(state, coilName, coilType);
    1886          596 :     auto &c(coilSelectionDataObjs[index]);
    1887          596 :     c->coilTotCapAtPeak = totalCoolingCap;
    1888          596 :     c->capIsAutosized = isAutoSize;
    1889          596 :     if ((state.dataSize->NumPltSizInput > 0) && (inletNodeNum > 0) && (outletNodeNum > 0)) {
    1890          505 :         bool errorsfound = false;
    1891          505 :         c->pltSizNum = PlantUtilities::MyPlantSizingIndex(state, "chilled water coil", coilName, inletNodeNum, outletNodeNum, errorsfound);
    1892              :     } else {
    1893           91 :         c->pltSizNum = -999;
    1894              :     }
    1895          596 :     c->waterLoopNum = dataWaterLoopNum;
    1896          596 : }
    1897              : 
    1898         2775 : 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         2775 :     int index = getIndexForOrCreateDataObjFromCoilName(state, coilName, coilType);
    1909         2775 :     auto &c(coilSelectionDataObjs[index]);
    1910         2775 :     c->coilTotCapAtPeak = totalHeatingCap;
    1911         2775 :     c->capIsAutosized = isAutoSize;
    1912         2775 :     if ((state.dataSize->NumPltSizInput > 0) && (inletNodeNum > 0) && (outletNodeNum > 0)) {
    1913         2499 :         bool errorsfound = false;
    1914         2499 :         c->pltSizNum = PlantUtilities::MyPlantSizingIndex(state, "hot water coil", coilName, inletNodeNum, outletNodeNum, errorsfound);
    1915              :     } else {
    1916          276 :         c->pltSizNum = -999;
    1917              :     }
    1918         2775 :     c->waterLoopNum = dataWaterLoopNum;
    1919         2775 : }
    1920              : 
    1921         2033 : 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         2033 :     int index = getIndexForOrCreateDataObjFromCoilName(state, coilName, coilType);
    1931         2033 :     auto &c(coilSelectionDataObjs[index]);
    1932         2033 :     c->coilTotCapAtPeak = totalHeatingCap;
    1933         2033 :     c->capIsAutosized = isAutoSize;
    1934         2033 :     c->pltSizNum = dataPltSizNum;
    1935         2033 :     c->waterLoopNum = dataWaterLoopNum;
    1936         2033 : }
    1937              : 
    1938         2448 : 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         2448 :     int index = getIndexForOrCreateDataObjFromCoilName(state, coilName, coilType);
    1949         2448 :     auto &c(coilSelectionDataObjs[index]);
    1950         2448 :     c->coilUA = UAvalue;
    1951         2448 :     c->coilTotCapAtPeak = dataCapacityUsedForSizing;
    1952         2448 :     c->capIsAutosized = isAutoSize;
    1953         2448 :     c->airloopNum = curSysNum;
    1954         2448 :     doAirLoopSetup(state, index);
    1955         2448 :     c->zoneEqNum = curZoneEqNum;
    1956         2448 : }
    1957              : 
    1958         6412 : 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         6412 :     int index = getIndexForOrCreateDataObjFromCoilName(state, coilName, coilType);
    1964         6412 :     auto &c(coilSelectionDataObjs[index]);
    1965         6412 :     c->reheatLoadMult = multiplierReheatLoad;
    1966         6412 : }
    1967              : 
    1968         8514 : 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         8514 :     if (fanName.empty()) {
    1976          726 :         return;
    1977              :     }
    1978         7788 :     int index = getIndexForOrCreateDataObjFromCoilName(state, coilName, coilType);
    1979         7788 :     auto &c(coilSelectionDataObjs[index]);
    1980         7788 :     c->fanAssociatedWithCoilName = fanName;
    1981         7788 :     c->supFanType = fanType;
    1982         7788 :     c->supFanNum = fanIndex;
    1983         7788 :     if (c->supFanNum == 0) {
    1984           14 :         c->supFanNum = Fans::GetFanIndex(state, fanName);
    1985              :     }
    1986              : }
    1987              : 
    1988         3351 : 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         3351 :     int index = getIndexForOrCreateDataObjFromCoilName(state, coilName, coilType);
    1996         3351 :     auto &c(coilSelectionDataObjs[index]);
    1997         3351 :     c->airloopNum = curSysNum;
    1998         3351 :     c->oASysNum = curOASysNum;
    1999         3351 :     c->zoneEqNum = curZoneEqNum;
    2000         3351 : }
    2001              : 
    2002        18342 : std::string ReportCoilSelection::getTimeText(EnergyPlusData &state, int const timeStepAtPeak)
    2003              : {
    2004        18342 :     std::string returnString = "";
    2005              : 
    2006        18342 :     if (timeStepAtPeak == 0) {
    2007            0 :         return returnString;
    2008              :     }
    2009              : 
    2010              :     // Scan timesteps of 24-hr day to match up correct hour and minute
    2011        18342 :     int minutes(0);
    2012        18342 :     int timeStepIndex(0);
    2013              :     int hourPrint;
    2014       458550 :     for (int hourCounter = 1; hourCounter <= 24; ++hourCounter) {
    2015      2548728 :         for (int timeStepCounter = 1; timeStepCounter <= state.dataGlobal->TimeStepsInHour; ++timeStepCounter) {
    2016      2108520 :             ++timeStepIndex;
    2017      2108520 :             minutes += state.dataGlobal->MinutesInTimeStep;
    2018      2108520 :             if (minutes == 60) {
    2019       440208 :                 minutes = 0;
    2020       440208 :                 hourPrint = hourCounter;
    2021              :             } else {
    2022      1668312 :                 hourPrint = hourCounter - 1;
    2023              :             }
    2024      2108520 :             if (timeStepIndex == timeStepAtPeak) {
    2025        18342 :                 returnString = format(DataSizing::PeakHrMinFmt, hourPrint, minutes);
    2026              :             }
    2027              :         }
    2028              :     }
    2029              : 
    2030        18342 :     return returnString;
    2031            0 : }
    2032              : 
    2033         2215 : 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         2215 :     if (Util::SameString(compType, "Fan:SystemModel")) {
    2038          231 :         return true;
    2039         1984 :     } else if (Util::SameString(compType, "Fan:ComponentModel")) {
    2040            5 :         return true;
    2041         1979 :     } else if (Util::SameString(compType, "Fan:OnOff")) {
    2042         1013 :         return true;
    2043          966 :     } else if (Util::SameString(compType, "Fan:ConstantVolume")) {
    2044          529 :         return true;
    2045          437 :     } else if (Util::SameString(compType, "Fan:VariableVolume")) {
    2046          437 :         return true;
    2047              :     } else {
    2048            0 :         return false;
    2049              :     }
    2050              : }
    2051              : 
    2052          368 : 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          368 :     bool found(false);
    2057        11202 :     for (int loop = 1; loop <= HVAC::NumAllCoilTypes; ++loop) {
    2058        11046 :         if (Util::SameString(compType, HVAC::cAllCoilTypes(loop))) {
    2059          212 :             found = true;
    2060          212 :             break;
    2061              :         }
    2062              :     }
    2063          368 :     return found;
    2064              : }
    2065              : 
    2066          199 : 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         4675 :     for (auto const &c : coilSelectionDataObjs) {
    2070              : 
    2071         4476 :         if (c->isCooling) {
    2072         2637 :             for (std::size_t zoneInd = 0; zoneInd < c->zoneNum.size(); ++zoneInd) {
    2073         2562 :                 if (zoneIndex == c->zoneNum[zoneInd]) {
    2074          383 :                     c->rmLatentAtPeak += zoneCoolingLatentLoad;
    2075          383 :                     break;
    2076              :                 }
    2077              :             }
    2078              :         }
    2079          199 :     }
    2080          199 : }
    2081              : 
    2082          199 : 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         4675 :     for (auto const &c : coilSelectionDataObjs) {
    2086              : 
    2087         4476 :         if (c->isHeating) {
    2088         9523 :             for (std::size_t zoneInd = 0; zoneInd < c->zoneNum.size(); ++zoneInd) {
    2089         5997 :                 if (zoneIndex == c->zoneNum[zoneInd]) {
    2090          492 :                     c->rmLatentAtPeak += zoneHeatingLatentLoad;
    2091          492 :                     break;
    2092              :                 }
    2093              :             }
    2094              :         }
    2095          199 :     }
    2096          199 : }
    2097              : 
    2098              : } // namespace EnergyPlus
        

Generated by: LCOV version 2.0-1